I am constructing a D3 force graph to visualize network traffic. Need to link two nodes with more than 2 paths. Is that possible? Help appreciated.
Asked
Active
Viewed 2,226 times
2
-
2Looks like there is a similar question on the same topic. http://stackoverflow.com/questions/11368339/drawing-multiple-edges-between-two-nodes-with-d3 http://jsfiddle.net/7HZcR/3/ Let me give it a try. – user2300875 Apr 19 '13 at 22:38
1 Answers
4
Nothing prevents you from drawing multiple edges between nodes. Then only thing is that the force directed graph layout is made for two nodes to share only one link. Thus I would recommend to do the following:
- From the force directed graph point of view have only one link.
- On the drawing point of view, draw multiple edges if both nodes have multiple edges.
Which give the following data structure for edges:
links = {
source: 0, //index of source node
target: 0 //index of target node
representations : [{color: "red"}, {color:"blue"}]
}
Thus when you give links to the force directed graph, it won't complain. But when you actually draw the link you can iterate through the representations
array to draw the different links.

Christopher Chiche
- 15,075
- 9
- 59
- 98
-
Thanks for the response. But how do I iterate representation while drawing the links. Ex: viz.path.enter().append("path").attr("id","")... I use the above line to render links between nodes. Where in this will I call representations array ? Thanks, – user2300875 Apr 23 '13 at 23:41