LayeredLayout.NetworkSimplex
- Package
- purescript-layered-layout
- Repository
- markgrafhq/purescript-layered-layout
Generic Gansner-Koutsofios-North-Vo network simplex algorithm, shared between layer assignment and the post-routing graph compactor.
Port of ELK's org.eclipse.elk.alg.common.networksimplex.NetworkSimplex.
The algorithm is parameterised over the node identifier type
(any Ord n) and accepts per-edge delta (minimum span) and
weight (importance for shortness). Cutvalues are stored as
Number (mirroring ELK's double) and compared against
fuzzyStZero to track ELK's tolerance for floating-point
imprecision.
Connected-component splitting and layer balancing are left to callers.
#NEdge Source
type NEdge n = { delta :: Int, eid :: Int, src :: n, tgt :: n, weight :: Number }An edge for the network simplex algorithm.
delta– the minimum span (target.layer − source.layer ≥ delta).weight– contribution to the optimisation objective. Network simplex minimises the weighted sum ofweight * (layer span)across all edges, so heavier edges are kept shorter.eid– a per-edge integer index, unique within the input array; the algorithm uses it as a key into cutvalue / visited sets.
#runNetworkSimplex Source
runNetworkSimplex :: forall n. Ord n => Array n -> Array (NEdge n) -> Map n IntRun the network simplex over the given nodes and edges.
The caller is responsible for ensuring the input is weakly- connected (split into components, or inject an artificial root that dominates all sources). When the input is disconnected the algorithm still terminates, but the layering of the unreached component(s) is not optimised.
#fuzzyStZero Source
fuzzyStZero :: NumberTolerance for floating-point imprecision when checking whether a
cut value is negative. Port of ELK's FUZZY_ST_ZERO = -1e-10.
- Modules
- LayeredLayout
- LayeredLayout.
Aesthetics - LayeredLayout.
Compaction. EdgeAwareScanlineConstraints - LayeredLayout.
Compaction. HorizontalGraphCompactor - LayeredLayout.
Compaction. LGraphToCGraphTransformer - LayeredLayout.
Compaction. NetworkSimplexCompaction - LayeredLayout.
Compaction. OneD - LayeredLayout.
Compaction. VerticalSegment - LayeredLayout.
Components - LayeredLayout.
CoordAssignment - LayeredLayout.
CrossingMin - LayeredLayout.
CrossingMin. Constraints - LayeredLayout.
CrossingMin. NorthSouth - LayeredLayout.
CrossingMin. Ports - LayeredLayout.
CycleRemoval - LayeredLayout.
DummyNodes - LayeredLayout.
EdgeLabels - LayeredLayout.
EdgeLabels. SelfLoops - LayeredLayout.
EdgeLabels. SelfLoops. Model - LayeredLayout.
EdgeLabels. SelfLoops. Routing - LayeredLayout.
EdgeRouting - LayeredLayout.
EdgeRouting. HyperEdgeCycleDetector - LayeredLayout.
EdgeRouting. HyperEdges - LayeredLayout.
EdgeRouting. LineJump - LayeredLayout.
EdgeRouting. Orthogonal - LayeredLayout.
EdgeRouting. PortAssignment - LayeredLayout.
Graph - LayeredLayout.
Grid - LayeredLayout.
JavaRandom - LayeredLayout.
LayerAssignment - LayeredLayout.
LayerAssignment. NetworkSimplex - LayeredLayout.
NetworkSimplex - LayeredLayout.
PortDistribution - LayeredLayout.
PortDummies - LayeredLayout.
Result