Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module that provides abstract implementation of graph-like data structure
GenericGraph
and many helpful functions for interaction with GenericGraph
.
Synopsis
- data GenericGraph v e = GenericGraph {}
- addEdges :: Ord v => GenericGraph v e -> [(Int, Int, e)] -> GenericGraph v e
- addVertices :: Ord v => GenericGraph v e -> [v] -> GenericGraph v e
- applyG :: ([(Int, e1)] -> [(Int, e2)]) -> GenericGraph v e1 -> GenericGraph v e2
- applyV :: Ord v2 => (v1 -> v2) -> GenericGraph v1 e -> GenericGraph v2 e
- getVertices :: GenericGraph v e -> [v]
- getEdge :: GenericGraph v e -> Int -> Int -> e
- isConnected :: GenericGraph v e -> Int -> Int -> Bool
- removeEdges :: Ord v => GenericGraph v e -> [(Int, Int)] -> GenericGraph v e
- removeVertices :: Ord v => GenericGraph v e -> [Int] -> GenericGraph v e
- safeAt :: GenericGraph v e -> Int -> [(Int, e)]
- safeIdx :: GenericGraph v e -> Int -> [Int]
- subgraph :: Ord v => GenericGraph v e -> [Int] -> GenericGraph v e
- subgraphWithReindex :: Ord v => GenericGraph v e -> [Int] -> (Bimap Int Int, GenericGraph v e)
- sumGraphs :: Ord v => GenericGraph v e -> GenericGraph v e -> GenericGraph v e
- typeOfEdge :: Ord v => GenericGraph v e -> Int -> Int -> e
Documentation
data GenericGraph v e Source #
Generic undirected graph which stores elements of type v in its vertices (e.g. labels, atoms, states etc) and elements of type e in its edges (e.g. weights, bond types, functions over states etc). Note that loops and multiple edges between two vertices are allowed.
Instances
addEdges :: Ord v => GenericGraph v e -> [(Int, Int, e)] -> GenericGraph v e Source #
Add given edges to the graph.
addVertices :: Ord v => GenericGraph v e -> [v] -> GenericGraph v e Source #
Add given vertices to graph.
applyG :: ([(Int, e1)] -> [(Int, e2)]) -> GenericGraph v e1 -> GenericGraph v e2 Source #
fmap
which acts on adjacency lists of each vertex.
applyV :: Ord v2 => (v1 -> v2) -> GenericGraph v1 e -> GenericGraph v2 e Source #
fmap
which acts on vertices.
getVertices :: GenericGraph v e -> [v] Source #
Get all vertices of the graph.
getEdge :: GenericGraph v e -> Int -> Int -> e Source #
Get edge from graph, which starting and ending indices match given indices.
isConnected :: GenericGraph v e -> Int -> Int -> Bool Source #
Check that two vertices with given indexes have edge between them.
removeEdges :: Ord v => GenericGraph v e -> [(Int, Int)] -> GenericGraph v e Source #
Remove given edges from the graph. Note that isolated vertices are allowed. This will NOT affect indexation.
removeVertices :: Ord v => GenericGraph v e -> [Int] -> GenericGraph v e Source #
Remove given vertices from the graph. Note that indexation will be CHANGED. Be careful with !. and ?. operators.
safeAt :: GenericGraph v e -> Int -> [(Int, e)] Source #
Safe extraction from the graph. If there is no requested key in it, empty list is returned.
safeIdx :: GenericGraph v e -> Int -> [Int] Source #
Safe extraction from the graph. If there is no requested key in it, empty list is returned.
subgraph :: Ord v => GenericGraph v e -> [Int] -> GenericGraph v e Source #
Get subgraph on given vertices. Note that indexation will be CHANGED. Be careful with !. and ?. operators.
subgraphWithReindex :: Ord v => GenericGraph v e -> [Int] -> (Bimap Int Int, GenericGraph v e) Source #
Get subgraph on given vertices and mapping from old toKeep
indices to
new indices of resulting subgraph.
sumGraphs :: Ord v => GenericGraph v e -> GenericGraph v e -> GenericGraph v e Source #
Returns graph that is the sum of two given graphs assuming that they are disjoint.
typeOfEdge :: Ord v => GenericGraph v e -> Int -> Int -> e Source #
Returns type of edge with given starting and ending indices.