Simple Force-Directed Graph
✓ Published0🌍 Public
This example demonstrates a simple force-directed graph with three nodes and two edges. The simulation uses D3’s `forceSimulation` API, chaining `forceManyBody`, `forceLink`, and `forceCenter` forces to position the nodes. The data is defined as hard-coded JavaScript arrays of node and link objects, with links referencing nodes by index. The code imports the simulation functions directly from the `d3` module and registers a tick event handler, though the handler’s logging statement contains a typo. The HTML page loads D3 version 6.2.0 from a CDN.
AI-generated descriptionMIT Licensed