Skip to main content

ELK

🔗 Gallery

ELK is a mature layout engine, actively maintained by an academic research group at Christian Albrechts University in Kiel.

Reference​

https://www.eclipse.org/elk/reference.html

Algorithms​

ELK has several layout algorithms. D2 uses layered by default. To choose another one, pass --elk-algorithm along with --layout=elk.

The main choices for connected diagrams are:

AlgorithmDescription
layeredThe default. Arranges shapes in layers, with orthogonal connections.
forceSpreads shapes out using simulated attraction and repulsion.
stressPlaces shapes closer together when there are shorter paths between them.
mrtreeArranges a tree in levels.
radialArranges a tree in circles around its root.

For example:

radial expects a tree. For example, tree.d2 could contain:

The pros and cons below describe the default layered algorithm. Other algorithms have different routing and feature support.

Pros​

  • Clean, orthogonal routes.
  • Highly customizable.
  • Fast.
  • Good at minimizing crossings.
  • Natively supports container to container routing, handling these better than dagre.
  • Undergoing active improvements with regular releases.
  • Routes SQL tables with exact columns.

Cons​

  • Strictly hierarchical, like dagre.
  • Some routes have unnecessary bends.
  • Minimal consideration for symmetry.