Skip to main content

Module graph

Module graph 

Source
Expand description

The run graph’s layout: a layered (Sugiyama) layout of our own (decision 22A), top to bottom.

  1. Layers: each task one layer below its lowest upstream task (the longest path from a task without upstream ones).
  2. Long edges get a point in every layer they cross (dummy nodes), so they are routed between the tasks rather than through them.
  3. Crossings: layers are reordered by the mean position of their neighbours (barycenters), sweeping down and up; the order with the fewest crossings seen is kept, the tasks’ own order first, so the result is never worse than that.
  4. x: each node as near its neighbours’ mean as the order and the gaps allow (a least-squares fit under those constraints, by pool-adjacent-violators), sweeping down and up; then shifted so the leftmost node starts at the margin.

Groups (decision 65): a group’s tasks stay together. Every layer is ordered group by group (a group’s place is its members’ mean; nested groups inside their parent), a long edge’s points belong to the innermost group both its ends are in, and after the x fit any other task is pushed clear of a group’s box in every layer the box spans. A box is its members’ extent and its nested boxes’, with padding and a band for its label on top; the space between layers grows with the deepest nesting, so labels never meet.

Resources beside the tasks: a resource’s setup and cleanup are taken out of the layers’ order and drawn in a box of their own on the left, each resource in a lane, its setup and cleanup in the layers they would have had (so every row stays where it was). Their edges run in a channel between the box and the tasks (a track per resource and direction), reaching it through the space below their upstream node’s layer and leaving it through the space above their downstream node’s: never through a box.

Deterministic: the same graph always gets the same layout.

Structs§

GroupBox
A group’s box, drawn around its nodes.
GroupSpec
A group of nodes, for layout_grouped.
Layout
A graph laid out.
Placed
A node placed: its box’s centre.
Route
An edge’s route: from the bottom of from’s box, straight down through each layer it crosses (beside that layer’s boxes, from the top of their band to its bottom), to the top of to’s box. Between layers it bends; within a layer it never does, so it can’t cut a box.
SideBox
The box of the nodes put aside: the resources’ section, left of the tasks.

Constants§

GROUP_LABEL
A group box’s band for its label, above its contents.
GROUP_PAD
A group box’s padding around its contents (sides and bottom).
MARGIN
The space around the drawing.
NODE_HEIGHT
A task’s box: height.
NODE_WIDTH
A task’s box: width.

Functions§

layout
Lays out count nodes joined by edges ((from, to) indices; to runs after from).
layout_grouped
layout, with groups and each node’s innermost group (node_group, by index into groups) kept together and boxed.
layout_sided
layout_grouped, with the nodes of sides (each a resource’s setup and cleanup) put in a box of their own on the left, a lane per resource (see the module’s docs).