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.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry 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)andBlowLayout.Circle(nodes, options)write each node'sPositionin place; nothing else changes, so the page follows withFitView().BlowLayeredLayoutOptions:Direction(TopToBottom, alsoLeftToRight,BottomToTop,RightToLeft),LayerGap(80) andNodeGap(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'sSourcePositionandTargetPositionalong 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(nullfor a roughly square grid),ColumnGapandRowGap(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(nullderives one at which neighbours clear each other) andNodeGap(30), the least gap that derivation leaves.- Every layout also takes
Origin(the top-left of the result),NodeOrigin(match the canvas's) andFallbackSize(150 by 40, for a node with no size yet). These nodes have an explicitWidthandHeight, so they are laid out at their real size before they are measured.