Module

LayeredLayout.PortDistribution

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

Turn the physical port order selected by crossing minimization into offsets shared by BK and routing. A rank identifies a physical port: several edges at the same rank occupy one slot, not several slots.

#PortOrder Source

Re-exports from LayeredLayout.EdgeRouting.PortAssignment

#EdgePortOffsets Source

type EdgePortOffsets = Map (EdgeId /\ Side) Number

Port-distribution result: per-edge x-offset on a node side, in fine-grid coordinates relative to the node's left edge. Built by LayeredLayout.PortDistribution.distributePorts (post-BK) and consumed by assignPorts (edge routing) so the recorded offset overrides the per-call distributeAlongSide re-derivation.

#distributeAlongSide Source

distributeAlongSide :: { hi :: Number, lo :: Number } -> Array EdgeId -> Map EdgeId Number

Even-distribution port-spacing formula from ELK's LGraphUtil.placePorts.

position_i = lo + (i + 1) * width / (n + 1)

with i ∈ [0, n), so 1 sibling sits at center; 2 at thirds; 3 at quarters. The order of the input array decides which sibling lands at which slot — callers sort by their preferred criterion (target layer-index, source barycenter, etc.) before passing in.