D3.js: Force-directed graph, edge length proportional to edge weight

时间:2015-09-14 16:01:37

标签: javascript d3.js graph

I have a complete, undirected, weighted graph. I would like to visualize this graph in such a way that the visualized edge lengths are proportional to the edge weights, which represent distances between locations (the nodes).

My understanding of the force-directed graph model is that the node charge determines the distance between the nodes, and thus the edge length. Since no node can have more than one charge, it seems logical that (for the complete graph), the distance between all nodes adjacent to some node must be the same.

Is there a way to accomplish such a visualization of a complete graph in D3.js?

1 个答案:

答案 0 :(得分:2)

No. You can set the linkDistance() for each edge, but this is really only a guideline -- D3 doesn't enforce exactly that length.