Module

DataViz.Layout.TidyDag

Package
purescript-hylograph-layout
Repository
afcondon/purescript-hylograph-layout

DataViz.Layout.TidyDag

Layout for shallow, sparse DAGs (build graphs, dependency cones): prune the DAG to a spanning tree, lay the tree out with the Reingold–Tilford Hierarchy.Tree, then hand back the pruned edges as cross-links for the renderer to draw faint.

The pruning heuristic: each node's tree-parent is its LONGEST-PATH parent — the dependent that determines the node's layer — so the tree backbone agrees with the DAG's natural stages and cross-links stay short and lateral. Ties break by the caller's mass (e.g. transitive leaf mass), then lexically for determinism.

Edges are parent depends-on child (build: target → input), so roots are the goals and leaves are the sources. Self-edges are ignored; cycles cannot capture the depth pass (it is a bounded fixpoint), and back-edges simply become cross-links.

#TidyDagConfig Source

type TidyDagConfig = { layerSeparation :: Maybe Number, minSeparation :: Number, size :: { height :: Number, width :: Number } }

#DagEdge Source

type DagEdge = { child :: String, parent :: String }

parent depends on child (a build target and one of its inputs).

#LinkKind Source

#PlacedNode Source

type PlacedNode = { depth :: Int, id :: String, x :: Number, y :: Number }

#TidyDagLayout Source

type TidyDagLayout = { links :: Array PlacedLink, nodes :: Array PlacedNode }

#tidyDag Source

tidyDag :: TidyDagConfig -> { edges :: Array DagEdge, mass :: String -> Number, roots :: Array String } -> TidyDagLayout

Lay out a DAG. roots are the entry points (goals); ids appearing only in edges are picked up automatically. mass breaks tree-parent ties (bigger wins); const 1.0 is fine.