Update Force-Directed Layout D3.v4 Different Datasets
This example demonstrates how to update a force-directed graph when a user action loads a new dataset, using D3 v4’s enter-update-exit pattern. A button swaps between two JSON datasets containing nodes and links from a character network. The code uses `d3.forceSimulation`, `d3.forceLink`, and `d3.forceManyBody` to compute layout, while SVG circles and lines are bound to the data. Dragging is enabled via `d3.drag`, and the simulation restarts with new data when the dataset changes.