Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Util.Graph

Description

Some functions missing from Data.Graph.

Synopsis

Documentation

roots_of :: Graph -> [Vertex] Source #

Roots are all vertices with no parents.

to_forest :: Graph -> Tree.Forest Vertex Source #

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

toggle_edge :: Edge -> Graph -> Maybe Graph Source #

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_above :: Vertex -> Vertex -> Graph -> Graph Source #

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_below :: Vertex -> Vertex -> Graph -> Graph Source #

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.

lonely_vertex :: Graph -> Vertex -> Bool Source #

A lonely vertex has no edges.

insert_vertex :: Int -> Graph -> Graph Source #

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

remove_vertex :: Int -> Graph -> Graph Source #

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

unlink_vertex :: Int -> Graph -> Graph Source #

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 :: Vertex -> Vertex -> Graph -> Maybe Graph Source #

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