Module

LayeredLayout.Compaction.VerticalSegment

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

Port of ELK's VerticalSegment (orthogonal-only — spline tracking omitted because markgraf only routes orthogonal edges).

A vertical segment is a piece of routed edge that runs along the y-axis. Segments at the same x-coordinate are merged before they are handed to the compactor, so the surviving record carries the union of contributing edges, bend points and ignore-spacing flags.

#VerticalSegment Source

type VerticalSegment = { aPort :: Maybe PortRef, affectedBends :: Array GridPos, hitbox :: { height :: Number, width :: Number, x :: Number, y :: Number }, id :: VSId, ignoreSpacing :: Quadruplet, potentialGroupParents :: Array CNodeId, representedEdges :: Array EdgeId }

#PortRef Source

type PortRef = { node :: NodeId, side :: Side }

Minimal port reference used by the compactor: just the side (for the inverted-port edge-constraint logic in NetworkSimplexCompaction) and the owning node id (for adjusting positions back on the LGraph).

#VSId Source

type VSId = Int

#newVerticalSegment Source

newVerticalSegment :: VSId -> GridPos -> GridPos -> Maybe CNodeId -> EdgeId -> VerticalSegment

Construct a vertical segment from two bend points. Mirrors ELK's VerticalSegment(KVector, KVector, CNode, LEdge) constructor.

#intersects Source

intersects :: VerticalSegment -> VerticalSegment -> Boolean

Two segments at the same x-coordinate (fuzzy) and overlapping in y are considered intersecting and will be merged.

#joinWith Source

joinWith :: VerticalSegment -> VerticalSegment -> VerticalSegment

Merge other into survivor. The result keeps survivor's id and unions every contributing list. Matches ELK's joinWith.

#compareVS Source

compareVS :: VerticalSegment -> VerticalSegment -> Ordering

Sort order: fuzzy-equal x coordinates collapse, ties broken by exact y. Port of ELK's compareTo.