Usage guidesLayout

Dagre layout

Arrange nodes in layers based on directed edges.

Overview

Arrange nodes in layers based on directed edges.

When to use it

Use it for workflows, call chains, and dependency graphs.

Basic usage

Set the layout type with layout.type.

const graph = new Graph({
  container,
  data,
  layout: { type: 'dagre' },
});

Options

OptionDescriptionTypeDefault
rankdirLayer direction. 'LR' goes left to right and 'TB' goes top to bottom.'TB' | 'BT' | 'LR' | 'RL''TB'
nodesepGap between nodes on the same layer.number50
ranksepGap between layers.number50
nodeSizeNode dimensions used by the layout.number | [number, number][0, 0]

Common layout options · Layout reference

Code example

The workflow runs left to right, with Review and Check on the same layer.

Loading example…
Drag to pan or scroll to zoom.
const layout = { type: 'dagre', rankdir: 'LR', nodesep: 32, ranksep: 80, nodeSize: [80, 32] };

Compare Grid, Circular, and Dagre