Module

LayeredLayout.CoordAssignment

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

Brandes-Köpf node placement algorithm.

#assign Source

assign :: Random -> CoordConfig -> Array Constraints -> Array (Array NodeId) -> Map NodeId GridSize -> NodeMargins -> Map NodeId (Array Port) -> Array Edge -> Array { edgeId :: EdgeId, nodes :: Array NodeId } -> EdgePortOffsets -> { placements :: Array NodePlacement, random :: Random, slots :: Map EdgeId SlotInfo }

Assign coordinates in grid units without rounding.

The chains argument carries the dummy-edge groupings produced by DummyNodes.insertDummies; we need them to estimate inter-layer routing widths via the same hyperedge segment pipeline that the router itself runs (ports of OrthogonalRoutingGenerator and OrthogonalEdgeRouter.process).

#assignFine Source

assignFine :: CoordConfig -> Array (Array NodeId) -> Map NodeId GridSize -> NodeMargins -> Map NodeId (Array Port) -> Array Edge -> EdgePortOffsets -> Map NodeId Number

Assign coordinates in fine-grid resolution (no rounding).

#assignFineDiag Source

assignFineDiag :: CoordConfig -> Array (Array NodeId) -> Map NodeId GridSize -> NodeMargins -> Map NodeId (Array Port) -> Array Edge -> EdgePortOffsets -> Diag

Same as assignFine but returns rich per-pass diagnostics for inspection. Used only by debug specs.

#CoordConfig Source

type CoordConfig = { layerGap :: Int, nodeGap :: Int }

#NodeMargins Source

type NodeMargins = Map NodeId { bottom :: Number, left :: Number, right :: Number, top :: Number }

Reserved space around physical nodes, in fine units. sizeMap includes these margins; port offsets use the same reserved frame.

#Diag Source

type Diag = { balanced :: Map NodeId Number, chosen :: Map NodeId Number, chosenLabel :: Chosen, layers :: Array (Array NodeId), markedEdges :: Array MarkedEdge, passes :: Array PassDiag }

Top-level diagnostic returned by assignFineDiag. Captures the inputs (layers, dummy-augmented edges) and the per-pass + balanced output so external code can inspect BK's intermediate state without needing access to internals.

#PassDiag Source

type PassDiag = { align :: Map NodeId NodeId, hdir :: HDir, innerShift :: Map NodeId Number, postProcessTrace :: Array PostProcessTrace, queue :: Array Postprocessable, root :: Map NodeId NodeId, vdir :: VDir, x :: Map NodeId Number }

Per-pass diagnostic: aligned blocks (root,align maps), inner shifts, and final x map for one of the four BK passes. Also includes the accumulated Postprocessable queue (after placeBlock, before postProcess) and a per-item trace of what postProcess did.

#Postprocessable Source

type Postprocessable = { free :: NodeId, isRoot :: Boolean }

Port of ThresholdStrategy.Postprocessable: a deferred edge-straighten candidate. free is the block-side node (root or last); isRoot mirrors ELK's flag so pickEdge knows which incident-edge set to scan during the post-process pass.

#PostProcessTrace Source

type PostProcessTrace = { avail :: Number, candCount :: Int, delta :: Number, edgeId :: Maybe EdgeId, freeSu :: Boolean, hasEdges :: Boolean, phase :: PostProcessPhase, ppFree :: NodeId, ppIsRoot :: Boolean, shift :: Number }

Trace entry for one Postprocessable processed by postProcess. shift is the actual delta applied to the block (zero when no movement happened). freeSu, hasEdges, candCount expose why a given pp couldn't be straightened (skipped due to su, or no valid edges, etc.).

#PostProcessPhase Source

data PostProcessPhase

Which drain phase a PostProcessTrace entry came from. ELK's _.postProcess first drains the FIFO queue (forward), pushing failed items onto a stack, then drains the stack in reverse.

Constructors

Instances

#VDir Source

data VDir

Direction within a layer (Down = left-to-right, Up = right-to-left)

Constructors

Instances

#HDir Source

data HDir

Direction across layers (HRight = top-to-bottom, HLeft = bottom-to-top)

Constructors

Instances

#Chosen Source

data Chosen

Which of the four candidate layouts was picked. Balanced is the median-of-four; SmallestFeasible is the smallest-width directional layout when the median violates order constraints; FirstFallback is the last-resort first directional layout when none were feasible.

Constructors

Instances

#MarkedEdge Source

newtype MarkedEdge

Synthetic key identifying a marked (type-1 conflict) edge. Built from the two endpoint NodeIds by edgeKey; opaque otherwise.

Constructors

Instances