.source.index},${d.target.index}`] = 1;
        });

        function isConnected(a, b) {
            return linkedByIndex[`${a.index},${b.index}`] || linkedByIndex[`${b.index},${a.index}`] || a.index === b.index;
        }

        function fade(opacity) {
            return d => {
                node.style('opacity', function(o) {
                    return isConnected(d, o) ? 1 : opacity
                });
                link.style('stroke-opacity', o => (o.source === d || o.target === d ? 1 : opacity