manglano
manglano

Reputation: 844

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

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?

Upvotes: 2

Views: 2481

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109232

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

Upvotes: 1

Related Questions