Skip to main content
100%

Weighted nodes and curved links

✓ Published0🌍 Public
BBTKY
Last edited Sep 23, 2017
Created on Sep 23, 2017

A weighted force-directed graph displays words and thematic categories from JSON data, with node size scaled by a square-root transform and colors assigned by category class. Curved links, drawn as SVG paths, connect nodes using a single-arc approximation that produces dual parallel curves between pairs. The example uses D3 v3 with `d3.layout.force` for the physics simulation and `d3.scale.sqrt` for sizing, rendering entirely as SVG within an HTML page.

AI-generated description

This is a quick hack to draw two parallel links between nodes. Yes, you can scale it to more than two nodes, but it gets increasingly awkward. The alternative is to compute the paths manually, say by computing the perpendicular vector of the vector between the node centers, and offsetting the links accordingly.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/3037015'>Weighted nodes</a>

gpl-3.0 Licensed

Similar vizzes