Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Util.Graph

Description

Some functions missing from Data.Graph.

Synopsis

# Documentation

roots_of :: Graph -> [Vertex] Source #

Roots are all vertices with no parents.

This is like dfs, except it allows duplicated vertices. So don't use it one a graph with cycles.

Remove the edge if it already exists, create a new one of it doesn't. Return Nothing if adding an edge would create a cycle.

Splice new into the graph above to. The parents of to are detached from it and re-attached to new. Then new is attached above to.

This operation should be idempotent.

Splice new into the graph below to. The children of to are detached and re-attached to new. Then to is attached above new.

This operation should be idempotent.

parents :: Graph -> Vertex -> [Vertex] Source #

Get the parents of a Vertex.

A lonely vertex has no edges.

Increment all vertices at and above, insert new empty vertex.

Remove a vertex. All vertices pointing to the removed vertex instead point to what pointed to it.

All vertices pointing to the removed vertex instead point to what pointed to it. It will be removed from the list of roots.

map_vertices :: (Vertex -> Vertex) -> Graph -> Graph Source #

Transform all the vertices by the given function. If multiple vertices are transformed to the same value, the one with the originally highest vertex wins.

strip_indices :: a -> [(Int, a)] -> [a] Source #

Move a vertex. The graph remains the same, but the from vertex number will be changed to to and vice versa.