brainrake/elm-arc-diagram/1.0.0

Formerly brainrape/elm-arc-diagram. Search finds this package by either name.

AcyclicDigraph

Type aliases

The following type aliases are used to make type annotations more meaningful.

type alias Node =
Int
type alias Edge =
( Node, Node )
type alias Cycle =
List Node

AcyclicDigraph

Represents a directed graph with no cycles.

fromEdges : Set Edge -> Result (List Cycle) AcyclicDigraph

From a directed graph represented as a set of edges, get an AcyclicDigraph if the graph has no cycles; otherwise, get a list of all its simple cycles.

toEdges : AcyclicDigraph -> Set Edge

From an AcyclicDigraph, get its representation as a set of edges.

Topological sorting

topologicalRank : AcyclicDigraph -> Dict Node Int

Get a dictionary mapping node to topological rank. Rank numbering starts at 1 for all source nodes.

topologicalSortBy : (Node -> comparable) -> Dict Node Int -> List Node

From topologically-ranked nodes, get a well-ordered list of nodes by providing a (Node -> comparable) function to sort same-ranked nodes by.