Module

LayeredLayout.Compaction.NetworkSimplexCompaction

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

Phase 3 of the post-routing graph compaction port.

An ICompactionAlgorithm implementation that drives the generic LayeredLayout.NetworkSimplex core. Port of ELK's org.eclipse.elk.alg.layered.intermediate.compaction.NetworkSimplexCompaction.

The ELK version is hard-coded against LNode / VerticalSegment to add edge-length constraints and pick weights for vertical-segment / node pairs. Here that knowledge is supplied by the caller via a CompactionHooks a record so the algorithm stays polymorphic in the origin type. The phase 4 transformer fills in non-default hooks; callers that only need separation constraints can pass defaultHooks.

#CompactionHooks Source

type CompactionHooks a = { edgeLengthEdges :: CGraph a -> Array ExtraEdge, portAnchoredSegment :: CNode a -> Boolean, sameEdgeVerticalSegments :: CNode a -> CNode a -> Boolean, vsLNodePair :: CNode a -> CNode a -> Boolean }

Hooks the layered-graph bridge supplies so this algorithm can reproduce ELK's addEdgeConstraints and the VS-vs-LNode weight bump without knowing anything about LNode / VerticalSegment.

#ExtraEdge Source

type ExtraEdge = { delta :: Int, srcGroup :: CGroupId, tgtGroup :: CGroupId, weight :: Number }

An additional edge the phase 4 transformer wants in the network-simplex graph (e.g. for inverted ports).

#defaultHooks Source

#networkSimplexCompaction Source

networkSimplexCompaction :: forall a. CompactionHooks a -> ICompactionAlgorithm a

The compaction algorithm. Build a network-simplex graph from the constraint graph, run the simplex, and write the resulting layer values back into each CNode's hitbox.x.

#separationWeight Source

separationWeight :: Number

Constants matching ELK's NetworkSimplexCompaction.