Force Layout with Voronoi Cells and Add/Remove Node functionality
✓ Published0🌍 Public
Aandrew-reid
Last edited Mar 16, 2017
Created on Mar 11, 2017
A force-directed graph renders 15 numbered circles as colored nodes, each clipped to its Voronoi cell so the partition updates as nodes move. Users toggle between add and remove modes via a button; clicking a cell adds a new node at the cursor position, while clicking an existing node removes it. The layout uses d3.forceSimulation for physics, d3.voronoi for cell boundaries, and d3.drag for node interaction, with SVG elements for rendering and a color scale from d3.schemeCategory20.
AI-generated descriptionCreated out of a SO question on force directed graphs with voronoi.
The layout includes:
- Charged force layout,
- Voronoi click based click events for dragging/removing, and
- Dynamic adding/removing of nodes.
The voronoi updates with the force layout, based on:
and