Skip to content

Layouting

Arrange the graph automatically with the layouts that ship in the box - BlowLayout.Layered, Grid and Circle, plain C# with no JavaScript layout engine. The layered layout orders each layer to keep edges from crossing, packs layers by their own thickness and points the handles along the flow; grid and circle are there for tidying up and for showing a set of peers.

Node 1
Node 2
Node 3
Node 4
Node 5
Node 6
Node 7
bit Blow

Try it

  • Press Layered, Grid or Circle to rearrange the graph; the second row of the toolbar then shows that layout's options, and every change re-runs it.
  • Layered: pick a Direction, and drag Layer gap and Node gap to space the layers and the nodes within them.
  • Drag Crossing passes to 0: Node 5, which has two parents, drops to the end of its row, and the edge from Node 2 to it crosses the edges to Nodes 6 and 7. One pass or more sorts the row so nothing crosses.
  • Untick Point handles along the flow with the direction left to right: the edges go back to leaving the bottom of each node and entering the top.
  • Grid: drag Columns (leftmost is automatic, roughly square), Column gap and Row gap. Circle: drag Start angle to turn the ring, and Radius to set its size yourself; at auto it is worked out from the node sizes and Node gap.
  • Add branch hangs a new node off a random one and lays the graph out again; Reset goes back to the first seven nodes, keeping the options.

How it works

  • BlowLayout.Layered(nodes, edges, options), BlowLayout.Grid(nodes, options) and BlowLayout.Circle(nodes, options) write each node's Position in place; nothing else changes, so the page follows with FitView().
  • BlowLayeredLayoutOptions: Direction (TopToBottom, also LeftToRight, BottomToTop, RightToLeft), LayerGap (80) and NodeGap (40). Each node sits one layer beyond the furthest node pointing at it, and cycles are handled.
  • CrossingReductionPasses (4) is how many sweeps reorder each layer by the average position of its neighbours; 0 skips them and keeps the order the nodes were reached in.
  • AlignHandlesToDirection (on) points every node's SourcePosition and TargetPosition along the flow; UpdateNodeInternals() then re-measures the handles where they moved to. Only the built-in nodes read the two properties - a custom template places its own handles.
  • BlowGridLayoutOptions: Columns (null for a roughly square grid), ColumnGap and RowGap (40 each). Cells are uniform, sized to the largest node, and filled row by row in list order.
  • BlowCircleLayoutOptions: StartAngle (0, degrees clockwise from twelve o'clock), Radius (null derives one at which neighbours clear each other) and NodeGap (30), the least gap that derivation leaves.
  • Every layout also takes Origin (the top-left of the result), NodeOrigin (match the canvas's) and FallbackSize (150 by 40, for a node with no size yet). These nodes have an explicit Width and Height, so they are laid out at their real size before they are measured.
An unhandled error has occurred. Reload 🗙