Accepted answer

If you don't need simulation, you can use the force layout statically. After calling force.start, call force.tick some number of times followed by force.stop to cease the simulation:

// Run the layout a fixed number of times.
// The ideal number of times scales with graph complexity.
// Of course, don't run too long—you'll hang the page!
for (var i = n; i > 0; --i) force.tick();

In some cases, it may help to initialize the node positions deterministically to encourage the simulation to converge quickly on a good solution. If you don't initialize the positions, the force layout will initialize them randomly, so it can be a bit unpredictable. For example, here I initialize the nodes along the diagonal:

// Initialize the positions deterministically, for better results.
var n = nodes.length;
nodes.forEach(function(d, i) { d.x = d.y = width / n * i; });

Lastly, if you're using a static layout, consider using fisheye distortion to still allow interactive exploration.

Related Query

More Query from same tag