graphene-0.1.0.4: A minimal Graph Theory library.

Safe Haskell None

Graphene.Graph

Synopsis

# Documentation

data Graph e v Source

Graph with edge type `e` and vertex type `v`

Constructors

 Graph Fields_vertices :: [v] _edges :: [(e, (v, v))]

Instances

 Bifunctor Graph map over both vertices and edges Bifoldable Graph fold over both vertices and edges Functor (Graph e) map over vertices Foldable (Graph e) fold over vertices (Eq e, Eq v) => Eq (Graph e v) (Show e, Show v) => Show (Graph e v) Monoid (Graph v e) identity + binary function (`mappend`)

a graph with no vertices or edges

insertVertex :: Eq v => v -> Graph e v -> Graph e vSource

Insert a vertex into a graph

removeVertex :: Eq v => v -> Graph e v -> Graph e vSource

Remove a vertex V from a graph | (Also removes edges connected to V)

removeVertices :: Eq v => [v] -> Graph e v -> Graph e vSource

Remove a list of vertices from a graph

removeEdge :: Eq e => e -> Graph e v -> Graph e vSource

Remove an edge from a graph

insertEdge :: Eq v => e -> (v, v) -> Graph e v -> Graph e vSource

Inset an edge into a graph connected to two vertices

insertVertices :: Eq b => [b] -> Graph e b -> Graph e bSource

Insert a list of edges into a graph

insertEdges :: Eq v => [(e, v, v)] -> Graph e v -> Graph e vSource

Insert a list of edges into a graph

modifyVertex :: Eq v => (v -> v) -> v -> Graph e v -> Graph e vSource

Modify a vertex in a graph by an automorphism | If such a vertex doesn't exist, modifyVertex = id

modifyEdge :: Eq e => (e -> e) -> e -> Graph e v -> Graph e vSource

Modify an edge in a graph by an automorphism | If such an edge doesn't exist, modifyEdge = id

connections :: Eq v => v -> Graph e v -> [(e, v)]Source

find edge connections and vertex neighbors to a vertex

neighbors :: Eq v => v -> Graph e v -> [v]Source

find all vertices connected to a given vertex

fromLists :: Eq v => [v] -> [(e, v, v)] -> Graph e vSource

Generate a graph froma list of edges and a list of edge / 2 vertex pairs

degree :: Eq v => v -> Graph e v -> IntSource

find the degree of a vertex

subgraph :: Eq v => [v] -> Graph e v -> Graph e vSource

subgraph generated by a list of vertices

moveFromTo :: Eq v => v -> v -> Graph e v -> Maybe vSource

move to a adjacent vertex (returns the next vertex if it really is connected)

moveFromThrough :: (Eq v, Eq e) => v -> e -> Graph e v -> Maybe vSource

follow an edge to a new adjancent vertex (returns the new vertex)