A version of the graph algorithms described in:
Lazy Depth-First Search and Linear Graph Algorithms in Haskell, by David King and John Launchbury.
Ported to Frege from the Haskell library source.
Strongly connected component.
A single vertex that is not in any cycle.
A maximal set of mutually reachable vertices.
The vertices of a list of strongly connected components.
The vertices of a strongly connected component.
Make a (key, [key]) list into one that is accepted by stronglyConnComp
Convenience function to compute topologically sorted strongly connected components of an adjacency list of the form:
[(key, [key])]
The result will be a list of lists of keys, where a singleton indicates no mutual dependency with other keys and a list consisting of several keys means that those are mutually dependent on each other.
In addition, earlier elements will not depend on later ones.
If the result contains only singletons, then the input was an acyclic graph.
The strongly connected components of a directed graph, topologically sorted.
The graph is a list of nodes uniquely identified by keys, with a list of keys of nodes this node has edges to. The latter one may contain keys that don't correspond to nodes of the graph; such edges are ignored.
The strongly connected components of a directed graph, topologically sorted. The function is the same as stronglyConnComp, except that all the information about each node retained.
This interface is used when you expect to apply SCC to (some of) the result of SCC, so you don't want to lose the dependency information.
An edge from the first vertex to the second.
access field from
access field to
All vertices of a graph.
All edges of a graph.
Build a graph from a list of edges.
The graph obtained by reversing all edges.
A table of the count of edges from each node.
A table of the count of edges into each node.
Identical to graphFromEdges, except that the return value does not include the function which maps keys to vertices. This version of graphFromEdges is for backwards compatibility.
Build a graph from a list of nodes uniquely identified by keys, with a list of keys of nodes this node should have edges to. The out-list may contain keys that don't correspond to nodes of the graph; they are ignored.
A spanning forest of the graph, obtained from a depth-first search of the graph starting from each vertex in an unspecified order.
A spanning forest of the part of the graph reachable from the listed vertices, obtained from a depth-first search of the graph starting at each of the listed vertices in order.
A topological sort of the graph.
The order is partially specified by the condition that a vertex i precedes j whenever j is reachable from i but not vice versa.
The connected components of a graph.
Two vertices are connected if there is a path between them, traversing edges in either direction.
The strongly connected components of a graph.
A list of vertices reachable from a given vertex.
Is the second vertex reachable from the first?
The biconnected components of a graph.
An undirected graph is biconnected if the deletion of any vertex leaves it connected.
components, dff, scc