Skip to main content
100%

Voronoi Spanning tree - short paths

✓ Published0🌍 Public
FFrissAnalytics
Last edited Sep 30, 2018
Created on Sep 30, 2018

This example builds a Voronoi spanning tree on 1,500 random points using d3.voronoi, with SVG rendering. It visualizes short paths by hopping from each cell to its neighbor that is nearest to a moving root point, computed via a custom `diagram.find` function. As the mouse moves, the tree updates in real time, showing only the edges that link sites along efficient routes toward the cursor. The code leverages d3.v4’s voronoi layout and SVG line elements to display the redrawn spanning tree.

AI-generated description

Using <a href='http://bl.ocks.org/Fil/1b7ddbcd71454d685d1259781968aefc'>Voronoi.find(x,y)</a> to create a spanning tree.

The strategy is to hop from any site to the nearest site that is nearer to the designated root (compare to the <a href='http://bl.ocks.org/Fil/82d889261f3b980a932fb9f9ef299c40'>Voronoi spanning tree long path</a>).

See also the colorized version.

Original work by Philippe Rivière for d3-voronoi (issue 17).

forked from <a href='http://bl.ocks.org/Fil/'>Fil</a>'s block: <a href='http://bl.ocks.org/Fil/2d10b09c5c50eee6d311ad5272b95a27'>Voronoi Spanning tree - short paths</a>

gpl-3.0 Licensed

Similar vizzes