function highlight_node_links(ev, node) {
var remainingNodes = [],
nextNodes = [];
if (d3.select(this).attr("data-clicked") == "1") {
d3.select(this).attr("data-clicked", "0");
d3.selectAll("path").style("opacity", 1);
d3.selectAll("rect").style("opacity", 1);
d3.selectAll("text")
.style("opacity", 1)
.style("font-size", 12)
.style("font-weight", "normal");
return;
} else {
d3.select(this).attr("data-clicked", "1");
d3.selectAll("path").style("opacity", 0.1);
d3.selectAll("rect").style("opacity", 0.1);
d3.selectAll("text").style("opacity", 0.1);
d3.select(this)
.select("rect")
.style("opacity", 1);
d3.select(this)
.select("text")
.style("opacity", 1)
.style("font-size", 16)
.style("font-weight", "bold");
}
var traverse = [
{
linkType: "sourceLinks",
nodeType: "target"
},
{
linkType: "targetLinks",
nodeType: "source"
}
];
traverse.forEach(function(step) {
node[step.linkType].forEach(function(link) {
remainingNodes.push(link[step.nodeType]);
d3.select("#link-" + link.id).style("opacity", 1);
});
while (remainingNodes.length) {
nextNodes = [];
remainingNodes.forEach(function(node) {
node[step.linkType].forEach(function(link) {
nextNodes.push(link[step.nodeType]);
d3.select("#link-" + link.id).style("opacity", 1);
});
d3.select("#rect-" + node.index).style("opacity", 1);
d3.select("#text-" + node.index).style("opacity", 1);
});
remainingNodes = nextNodes;
}
});
}