Force-Directed Graph, Disjoint / D3 | Observable
When using D3’s force layout with a disconnected graph, you typically want the positioning forces (d3.forceX and d3.forceY) instead of the centering force (d3.forceCenter). The positioning forces, unlike the centering force, prevent detached subgraphs from escaping the viewport.