vasturiano / force-graph

Force-directed graph rendered on HTML5 canvas
https://vasturiano.github.io/force-graph/example/directional-links-particles/
MIT License
1.55k stars 246 forks source link

unconnected nodes drifting infinitely away #354

Open RealmX1 opened 4 months ago

RealmX1 commented 4 months ago

When dragging any node, all other nodes unconnected to it drift away without any bounding force pulling back together.

It seems that most if not all of the examples shows such property. (especially obvious when trying the final example where you can create node and edges by yourself.

Is this intentional by design? Is there a way to set a bounding force that prevent unconnected nodes from drifting too far?

jodyphelan commented 3 months ago

Try setting x and y forces: https://d3js.org/d3-force/center#center_x. For example:

    Graph
      .d3Force('x', d3.forceX(0).strength(0.02))
      .d3Force('y', d3.forceY(0).strength(0.02))