The force graph is constrained within the box. Click [here] (http://www.puzzlr.org/bounding-box-force-directed-graph/) for an explanation of this effect.
This is done through the tick function's constraints - one of two simple ways you could do it. The other is through custom forces.
forked from puzzler10's block: Bounding box force directed graph I
forked from newsummit's block: Bounding box force directed graph I
https://d3js.org/d3.v4.min.js