Adjustable Link Strength
A force-directed network graph of character co-occurrences in Les Misérables visualizes the social structure of the novel. A slider labeled "Link Strength" directly adjusts the `strength` parameter of the `d3.forceLink` force within the `d3.forceSimulation` API. Dragging the slider triggers a callback that updates the force’s strength and calls `simulation.alpha(1).restart()`, reheating the simulation to re-layout the nodes. The Canvas-based rendering draws nodes as small circles and links as lines, with the graph’s layout responding in real time to the user’s input.
AI-generated descriptionThis example demonstrates how to modify the parameters of a force-directed graph. After modifying the desired parameter (here link.strength), you should reheat the simulation using simulation.alpha and simulation.restart. Alternatively, you can prevent the simulation from cooling by setting simulation.alphaDecay to 0, or by setting simulation.alphaTarget to a positive value.