Layouting
Arrange large graphs automatically with dagre or ELK and keep them readable.
Intermediate · 10 min read · Updated Oct 31, 2026
When to auto-layout
Hand-placed nodes break down past a few dozen elements or when graphs are generated from data. Layout engines compute positions from the graph's structure.
Choosing an engine
Each engine trades simplicity for control.
- dagre — small, fast, great for top-down trees and pipelines.
- ELK — highly configurable, supports ports and compound nodes.
- d3-force — organic layouts for knowledge graphs.
Measure first
Run layout after nodes have been measured so the engine knows their real width and height. useNodesInitialized tells you when that has happened.