Safe Haskell | Safe-Inferred |
---|

Some functions missing from Data.Graph.

## Synopsis

- build :: [Edge] -> Graph
- roots_of :: Graph -> [Vertex]
- to_forest :: Graph -> Tree.Forest Vertex
- draw :: Graph -> String
- toggle_edge :: Edge -> Graph -> Maybe Graph
- splice_above :: Vertex -> Vertex -> Graph -> Graph
- splice_below :: Vertex -> Vertex -> Graph -> Graph
- parents :: Graph -> Vertex -> [Vertex]
- children :: Graph -> Vertex -> [Vertex]
- would_make_cycle :: Edge -> Graph -> Bool
- has_cycle :: Graph -> Bool
- has_edge :: Graph -> Edge -> Bool
- lonely_vertex :: Graph -> Vertex -> Bool
- add_edges :: [Edge] -> Graph -> Graph
- remove_edges :: [Edge] -> Graph -> Graph
- insert_vertex :: Int -> Graph -> Graph
- remove_vertex :: Int -> Graph -> Graph
- unlink_vertex :: Int -> Graph -> Graph
- map_vertices :: (Vertex -> Vertex) -> Graph -> Graph
- strip_indices :: a -> [(Int, a)] -> [a]
- move :: Vertex -> Vertex -> Graph -> Maybe Graph

# Documentation

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.

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 #