When building a force-directed knowledge graph with D3.js, the default force settings cluster everything into an unreadable blob. The key parameters to tune for readable cluster separation:
Charge strength (-120): Repulsive force between all nodes. More negative = more spacing. distanceMax(400) caps the influence range so distant clusters do not push each other to infinity.
Link distance (60) + strength (0.3): How far apart linked nodes want to be. Lower strength makes the links springier, letting clusters breathe.
Center strength (0.05): Very weak pull toward center. Prevents drift without collapsing the graph.
Collision radius (+4 padding): Physical collision boundary. strength(0.7) means nodes push each other away firmly but not rigidly.
forceX/forceY (0.03): Gentle gravity toward center on each axis independently. Works with center force to keep things on screen.
alphaDecay (0.02): Slower cooldown. Default is 0.0228. Lower values let the simulation settle longer, producing better final positions.
The defaults (charge: -30, linkDistance: 30, no forceX/Y) are designed for small graphs. For 500+ nodes with multiple types, you need 3-4x stronger repulsion and explicit centering forces.
D3 Force Simulation Tuning for Knowledge Graphs
When building a force-directed knowledge graph with D3.js, the default force settings cluster everything into an unreadable blob. The key parameters to tune for readable cluster separation:
What each does:
-120): Repulsive force between all nodes. More negative = more spacing.distanceMax(400)caps the influence range so distant clusters do not push each other to infinity.60) + strength (0.3): How far apart linked nodes want to be. Lower strength makes the links springier, letting clusters breathe.0.05): Very weak pull toward center. Prevents drift without collapsing the graph.+4padding): Physical collision boundary.strength(0.7)means nodes push each other away firmly but not rigidly.0.03): Gentle gravity toward center on each axis independently. Works with center force to keep things on screen.0.02): Slower cooldown. Default is0.0228. Lower values let the simulation settle longer, producing better final positions.The defaults (
charge: -30,linkDistance: 30, no forceX/Y) are designed for small graphs. For 500+ nodes with multiple types, you need 3-4x stronger repulsion and explicit centering forces.