Module

LayeredLayout.Compaction.HorizontalGraphCompactor

Package
purescript-layered-layout
Repository
markgrafhq/purescript-layered-layout

Phase 5 of the post-routing graph compaction port: the orchestrator that wires the phase 4 transformer, the phase 2 OneDimensionalCompactor lifecycle and the phase 3 NetworkSimplexCompaction algorithm together. Port of ELK's org.eclipse.elk.alg.layered.intermediate.compaction.HorizontalGraphCompactor.

ELK's compactor compresses the X-axis (perpendicular to layers which grow horizontally in ELK). Markgraf runs DOWN internally, so the analogous "compress the layer-growth axis" operates on Y. We achieve that by transposing the routed layout (x↔y, w↔h, V↔H segments) before feeding it to the transformer, running the compactor with its default LEFT direction, and transposing the result back when applying the new positions.

#CompactionStrategy Source

data CompactionStrategy

Which compaction algorithm to drive. Only EdgeLength is wired so far — it uses NetworkSimplexCompaction with the transformer's hooks.

Constructors

Instances

#WithinLayerSpacings Source

type WithinLayerSpacings = { edgeEdge :: Number, nodeNode :: Number }

Global perpendicular-axis spacings in fine-grid units. These drive the scanline hitboxes independently of the between-layer matrix.

#BetweenLayersSpacings Source

type BetweenLayersSpacings = { edgeEdge :: Number, edgeNode :: Number, nodeNode :: Number }

The BETWEEN_LAYERS spacing matrix the compactor's spacings handler hands back per node-type pair. Mirrors ELK's nodeTypeSpacingOptionsHorizontal (BETWEEN_LAYERS column): the three pairs markgraf models are node↔node, edge↔node and edge↔edge. Values are in router-grid units (the unit every CNode is promoted to inside the compactor), which equal ELK's option values directly:

  • nodeNode = layered.spacing.nodeNodeBetweenLayers
  • edgeNode = layered.spacing.edgeNodeBetweenLayers
  • edgeEdge = layered.spacing.edgeEdgeBetweenLayers LABEL/LABEL is the source matrix exception: it uses global edge-edge spacing even along the between-layer axis.

#defaultBetweenLayersSpacings Source

defaultBetweenLayersSpacings :: BetweenLayersSpacings

The values the current test graphs (hugeGraph + ElkDiff panels) are validated against: hugeGraph overrides node-node and edge-node downward from ELK's 20/10 defaults, and edge-edge stays at ELK's SPACING_EDGE_EDGE_BETWEEN_LAYERS default of 10.

#compactPostRouting Source

compactPostRouting :: CompactionStrategy -> WithinLayerSpacings -> BetweenLayersSpacings -> { edges :: Array Edge, nodes :: Array NodePlacement, paths :: Array EdgePath, ports :: Map NodeId (Array Port) } -> { boundingBox :: GridRect, edges :: Array EdgePath, nodes :: Array NodePlacement }

Run post-routing compaction along markgraf's layer-growth axis (Y). Returns placements, paths, and the complete coarse DOWN layout frame.