Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data Graph edge node edgeLabel nodeLabel
- type LabeledNode n label = (n, label)
- type LabeledEdge edge node label = (edge node, label)
- class (Foldable edge, Ord1 edge) => Edge edge where
- defaultEdgeFoldMap :: (Edge edge, Monoid a) => edge a -> a
- data DirEdge node = DirEdge node node
- data UndirEdge node = UndirEdge node node
- undirEdge :: Ord node => node -> node -> UndirEdge node
- data EitherEdge node
- = EDirEdge (DirEdge node)
- | EUndirEdge (UndirEdge node)
- empty :: Graph edge node edgeLabel nodeLabel
- fromList :: (Edge e, Ord n) => [LabeledNode n nl] -> [LabeledEdge e n el] -> Graph e n el nl
- fromMap :: (Edge e, Ord n) => Map n nl -> Map (e n) el -> Graph e n el nl
- graphMap :: Graph edge node edgeLabel nodeLabel -> Map node (InOutMap edge node edgeLabel nodeLabel)
- nodeLabels :: (Edge e, Ord n) => Graph e n el nl -> Map n nl
- nodeSet :: Graph e n el nl -> Set n
- nodes :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> [node]
- nodeEdges :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> Map node (Set (edge node), nodeLabel, Set (edge node))
- edgeLabels :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> Map (edge node) edgeLabel
- edgeSet :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> Set (edge node)
- edges :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> [edge node]
- isEmpty :: Graph e n el nl -> Bool
- lookupNode :: Ord n => n -> Graph e n el nl -> Maybe nl
- lookupEdge :: (Edge e, Ord n) => e n -> Graph e n el nl -> Maybe el
- adjacentEdges :: (Edge e, Ord n) => Graph e n el nl -> n -> Set (e n)
- isLoop :: (Edge edge, Eq node) => edge node -> Bool
- pathExists :: (Edge edge, Ord node) => node -> node -> Graph edge node edgeLabel nodeLabel -> Bool
- isConsistent :: (Ord n, Eq el) => Graph DirEdge n el nl -> Bool
- mapNode :: (nl0 -> nl1) -> Graph e n el nl0 -> Graph e n el nl1
- mapNodeWithKey :: (n -> nl0 -> nl1) -> Graph e n el nl0 -> Graph e n el nl1
- mapEdge :: (el0 -> el1) -> Graph e n el0 nl -> Graph e n el1 nl
- mapEdgeWithKey :: (e n -> el0 -> el1) -> Graph e n el0 nl -> Graph e n el1 nl
- mapNodeWithInOut :: (Edge e, Ord n) => (InOut e n el nl0 -> nl1) -> Graph e n el nl0 -> Graph e n el nl1
- type InOut e n el nl = ([LabeledEdge e n el], LabeledNode n nl, [LabeledEdge e n el])
- filterEdgeWithKey :: (Edge e, Ord n) => (e n -> el -> Bool) -> Graph e n el nl -> Graph e n el nl
- traverseNode :: (Applicative f, Edge e, Ord n) => (nl0 -> f nl1) -> Graph e n el nl0 -> f (Graph e n el nl1)
- traverseEdge :: (Applicative f, Edge e, Ord n) => (el0 -> f el1) -> Graph e n el0 nl -> f (Graph e n el1 nl)
- traverse :: (Applicative f, Edge e, Ord n) => (nl0 -> f nl1) -> (el0 -> f el1) -> Graph e n el0 nl0 -> f (Graph e n el1 nl1)
- checkedZipWith :: (Edge edge, Ord node) => Caller -> (nodeLabel0 -> nodeLabel1 -> nodeLabel2) -> (edgeLabel0 -> edgeLabel1 -> edgeLabel2) -> Graph edge node edgeLabel0 nodeLabel0 -> Graph edge node edgeLabel1 nodeLabel1 -> Graph edge node edgeLabel2 nodeLabel2
- union :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> Graph edge node edgeLabel nodeLabel -> Graph edge node edgeLabel nodeLabel
- class Edge edge => Reverse edge where
- reverse :: (Reverse e, Ord n) => Graph e n el nl -> Graph e n el nl
- reverseEdge :: Reverse edge => edge node -> edge node
- mapKeys :: (Edge edge1, Ord node0, Ord node1) => (node0 -> node1) -> (edge0 node0 -> edge1 node1) -> Graph edge0 node0 edgeLabel nodeLabel -> Graph edge1 node1 edgeLabel nodeLabel
- mapMaybeEdgeKeys :: (Edge e1, Ord n) => (e0 n -> Maybe (e1 n)) -> Graph e0 n el nl -> Graph e1 n el nl
- mapEdgeKeys :: (Edge e1, Ord n) => (e0 n -> e1 n) -> Graph e0 n el nl -> Graph e1 n el nl
- deleteNode :: (Edge e, Ord n) => n -> Graph e n el nl -> Graph e n el nl
- deleteNodeSet :: (Edge e, Ord n) => Set n -> Graph e n el nl -> Graph e n el nl
- deleteEdge :: (Edge e, Ord n) => e n -> Graph e n el nl -> Graph e n el nl
- insertNode :: Ord n => n -> nl -> Graph e n el nl -> Graph e n el nl
- insertEdge :: (Edge e, Ord n) => e n -> el -> Graph e n el nl -> Graph e n el nl
- insertEdgeSet :: (Edge e, Ord n) => Map (e n) el -> Graph e n el nl -> Graph e n el nl
types
data Graph edge node edgeLabel nodeLabel Source #
(Eq nodeLabel, Eq edgeLabel, Eq node, Eq1 edge) => Eq (Graph edge node edgeLabel nodeLabel) Source # | |
(Ord nodeLabel, Ord edgeLabel, Ord node, Ord1 edge) => Ord (Graph edge node edgeLabel nodeLabel) Source # | |
(Edge e, Ord n, Show1 e, Show n, Show el, Show nl) => Show (Graph e n el nl) Source # | |
(Edge edge, Ord node) => Monoid (Graph edge node edgeLabel nodeLabel) Source # | |
type LabeledNode n label = (n, label) Source #
type LabeledEdge edge node label = (edge node, label) Source #
defaultEdgeFoldMap :: (Edge edge, Monoid a) => edge a -> a Source #
DirEdge node node |
Functor DirEdge Source # | |
Foldable DirEdge Source # | |
Eq1 DirEdge Source # | |
Ord1 DirEdge Source # | |
Show1 DirEdge Source # | |
Reverse DirEdge Source # | |
Edge DirEdge Source # | |
Eq node => Eq (DirEdge node) Source # | |
Ord node => Ord (DirEdge node) Source # | |
Show node => Show (DirEdge node) Source # | |
Arbitrary n => Arbitrary (DirEdge n) Source # | |
UndirEdge node node |
Foldable UndirEdge Source # | |
Eq1 UndirEdge Source # | |
Ord1 UndirEdge Source # | |
Show1 UndirEdge Source # | |
Edge UndirEdge Source # | |
Eq node => Eq (UndirEdge node) Source # | |
Ord node => Ord (UndirEdge node) Source # | |
Show node => Show (UndirEdge node) Source # | |
(Arbitrary n, Ord n) => Arbitrary (UndirEdge n) Source # | |
data EitherEdge node Source #
EDirEdge (DirEdge node) | |
EUndirEdge (UndirEdge node) |
Foldable EitherEdge Source # | |
Eq1 EitherEdge Source # | |
Ord1 EitherEdge Source # | |
Show1 EitherEdge Source # | |
Edge EitherEdge Source # | |
Eq node => Eq (EitherEdge node) Source # | |
Ord node => Ord (EitherEdge node) Source # | |
Show node => Show (EitherEdge node) Source # | |
construction
fromList :: (Edge e, Ord n) => [LabeledNode n nl] -> [LabeledEdge e n el] -> Graph e n el nl Source #
extract large portions of the graph
graphMap :: Graph edge node edgeLabel nodeLabel -> Map node (InOutMap edge node edgeLabel nodeLabel) Source #
nodeEdges :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> Map node (Set (edge node), nodeLabel, Set (edge node)) Source #
edgeLabels :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> Map (edge node) edgeLabel Source #
queries
pathExists :: (Edge edge, Ord node) => node -> node -> Graph edge node edgeLabel nodeLabel -> Bool Source #
manipulate labels
mapNodeWithKey :: (n -> nl0 -> nl1) -> Graph e n el nl0 -> Graph e n el nl1 Source #
mapEdgeWithKey :: (e n -> el0 -> el1) -> Graph e n el0 nl -> Graph e n el1 nl Source #
mapNodeWithInOut :: (Edge e, Ord n) => (InOut e n el nl0 -> nl1) -> Graph e n el nl0 -> Graph e n el nl1 Source #
type InOut e n el nl = ([LabeledEdge e n el], LabeledNode n nl, [LabeledEdge e n el]) Source #
filterEdgeWithKey :: (Edge e, Ord n) => (e n -> el -> Bool) -> Graph e n el nl -> Graph e n el nl Source #
traverseNode :: (Applicative f, Edge e, Ord n) => (nl0 -> f nl1) -> Graph e n el nl0 -> f (Graph e n el nl1) Source #
Same restrictions as in traverse
.
traverseEdge :: (Applicative f, Edge e, Ord n) => (el0 -> f el1) -> Graph e n el0 nl -> f (Graph e n el1 nl) Source #
Same restrictions as in traverse
.
traverse :: (Applicative f, Edge e, Ord n) => (nl0 -> f nl1) -> (el0 -> f el1) -> Graph e n el0 nl0 -> f (Graph e n el1 nl1) Source #
Don't rely on a particular order of traversal!
combine graphs
checkedZipWith :: (Edge edge, Ord node) => Caller -> (nodeLabel0 -> nodeLabel1 -> nodeLabel2) -> (edgeLabel0 -> edgeLabel1 -> edgeLabel2) -> Graph edge node edgeLabel0 nodeLabel0 -> Graph edge node edgeLabel1 nodeLabel1 -> Graph edge node edgeLabel2 nodeLabel2 Source #
Node and edge sets must be equal.
union :: (Edge edge, Ord node) => Graph edge node edgeLabel nodeLabel -> Graph edge node edgeLabel nodeLabel -> Graph edge node edgeLabel nodeLabel Source #
The node sets must be disjoint.
manipulate indices
reverseEdge :: Reverse edge => edge node -> edge node Source #
mapKeys :: (Edge edge1, Ord node0, Ord node1) => (node0 -> node1) -> (edge0 node0 -> edge1 node1) -> Graph edge0 node0 edgeLabel nodeLabel -> Graph edge1 node1 edgeLabel nodeLabel Source #
The index map must be an injection, that is, nodes must not collaps. Also the node and edge index maps must be consistent, i.e.
from (edgeMap e) == nodeMap (from e) to (edgeMap e) == nodeMap (to e)
Strictly spoken, we would need the node map only for isolated nodes, but we use it for all nodes for simplicity.
mapMaybeEdgeKeys :: (Edge e1, Ord n) => (e0 n -> Maybe (e1 n)) -> Graph e0 n el nl -> Graph e1 n el nl Source #
You may only use this for filtering edges and use more specialised types as a result. You must not alter source and target nodes of edges.
mapEdgeKeys :: (Edge e1, Ord n) => (e0 n -> e1 n) -> Graph e0 n el nl -> Graph e1 n el nl Source #
Same restrictions as in mapMaybeEdgeKeys
.
insertion and removal
deleteNode :: (Edge e, Ord n) => n -> Graph e n el nl -> Graph e n el nl Source #
Node to be deleted must be contained in the graph.
deleteNodeSet :: (Edge e, Ord n) => Set n -> Graph e n el nl -> Graph e n el nl Source #
Could be implemented more efficiently.
insertNode :: Ord n => n -> nl -> Graph e n el nl -> Graph e n el nl Source #
In the current implementation existing nodes are replaced with new labels and existing edges are maintained. However, I think we should better have an extra function for this purpose and you should not rely on this behavior.
insertEdgeSet :: (Edge e, Ord n) => Map (e n) el -> Graph e n el nl -> Graph e n el nl Source #
In the current implementation existing edges are replaced with new labels. However, I think we should better have an extra function for this purpose and you should not rely on this behavior. It is an unchecked error if edges between non-existing nodes are inserted.