Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Vertex
- vertexId :: Vertex -> Int
- data Edge
- edgeSource :: Edge -> Vertex
- edgeDest :: Edge -> Vertex
- class MGraph g where
- type ImmutableGraph g
- getVertices :: (PrimMonad m, MonadRef m) => g m -> m [Vertex]
- getSuccessors :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Vertex]
- getOutEdges :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Edge]
- countVertices :: (PrimMonad m, MonadRef m) => g m -> m Int
- countEdges :: (PrimMonad m, MonadRef m) => g m -> m Int
- checkEdgeExists :: (PrimMonad m, MonadRef m) => g m -> Vertex -> Vertex -> m Bool
- freeze :: (PrimMonad m, MonadRef m) => g m -> m (ImmutableGraph g)
- class MGraph g => MAddEdge g where
- class MGraph g => MAddVertex g where
- class MGraph g => MRemovable g where
- removeVertex :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m ()
- removeEdgesBetween :: (PrimMonad m, MonadRef m) => g m -> Vertex -> Vertex -> m ()
- removeEdge :: (PrimMonad m, MonadRef m) => g m -> Edge -> m ()
- class MGraph g => MBidirectional g where
- getPredecessors :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Vertex]
- getInEdges :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Edge]
- class MGraph g => MLabeledEdge g where
- type MEdgeLabel g
- getEdgeLabel :: (PrimMonad m, MonadRef m) => g m -> Edge -> m (Maybe (MEdgeLabel g))
- unsafeGetEdgeLabel :: (PrimMonad m, MonadRef m) => g m -> Edge -> m (MEdgeLabel g)
- addLabeledEdge :: (PrimMonad m, MonadRef m) => g m -> Vertex -> Vertex -> MEdgeLabel g -> m (Maybe Edge)
- class MGraph g => MLabeledVertex g where
- type MVertexLabel g
- getVertexLabel :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m (Maybe (MVertexLabel g))
- addLabeledVertex :: (PrimMonad m, MonadRef m) => g m -> MVertexLabel g -> m Vertex
- getLabeledVertices :: (PrimMonad m, MonadRef m) => g m -> m [(Vertex, MVertexLabel g)]
- class Graph g where
- edgeExists :: Graph g => g -> Vertex -> Vertex -> Bool
- class Graph g => Thawable g where
- type MutableGraph g :: (Type -> Type) -> Type
- thaw :: (PrimMonad m, MonadRef m) => g -> m (MutableGraph g m)
- class Graph g => Bidirectional g where
- class Graph g => HasEdgeLabel g where
- class Graph g => HasVertexLabel g where
- type VertexLabel g
- vertexLabel :: g -> Vertex -> Maybe (VertexLabel g)
- labeledVertices :: g -> [(Vertex, VertexLabel g)]
- class (HasEdgeLabel g, Bidirectional g) => BidirectionalEdgeLabel g where
- labeledInEdges :: g -> Vertex -> [(Edge, EdgeLabel g)]
- class (Graph g, HasEdgeLabel g, HasVertexLabel g) => InductiveGraph g where
- emptyGraph :: g
- match :: g -> Vertex -> Maybe (Context g, g)
- context :: g -> Vertex -> Maybe (Context g)
- insertLabeledVertex :: g -> VertexLabel g -> (Vertex, g)
- insertLabeledEdge :: g -> Vertex -> Vertex -> EdgeLabel g -> Maybe (Edge, g)
- deleteEdge :: g -> Edge -> g
- deleteEdgesBetween :: g -> Vertex -> Vertex -> g
- replaceLabeledEdge :: g -> Vertex -> Vertex -> EdgeLabel g -> Maybe (Edge, g)
- deleteVertex :: g -> Vertex -> g
- data Context g = Context [(EdgeLabel g, Vertex)] (VertexLabel g) [(EdgeLabel g, Vertex)]
Basic Types
An abstract representation of a vertex.
Note that the representation is currently exposed. Do not rely on this, as it is subject to change.
Instances
An edge between two vertices.
Instances
edgeSource :: Edge -> Vertex Source #
Mutable Graphs
The interface supported by a mutable graph.
type ImmutableGraph g Source #
The type generated by freeze
ing a mutable graph
getVertices :: (PrimMonad m, MonadRef m) => g m -> m [Vertex] Source #
List all of the vertices in the graph.
getSuccessors :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Vertex] Source #
List the successors for the given Vertex
.
getOutEdges :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Edge] Source #
countVertices :: (PrimMonad m, MonadRef m) => g m -> m Int Source #
Return the number of vertices in the graph
countEdges :: (PrimMonad m, MonadRef m) => g m -> m Int Source #
Return the number of edges in the graph
checkEdgeExists :: (PrimMonad m, MonadRef m) => g m -> Vertex -> Vertex -> m Bool Source #
Edge existence test; this has a default implementation, but can be overridden if an implementation can support a better-than-linear version.
freeze :: (PrimMonad m, MonadRef m) => g m -> m (ImmutableGraph g) Source #
Freeze the mutable graph into an immutable graph.
Instances
class MGraph g => MAddVertex g where Source #
addVertex :: (PrimMonad m, MonadRef m) => g m -> m Vertex Source #
Add a new Vertex
to the graph, returning its handle.
Instances
MAddVertex MDigraph Source # | |
MAddVertex MBiDigraph Source # | |
Defined in Data.Graph.Haggle.BiDigraph | |
MAddVertex MSimpleBiDigraph Source # | |
Defined in Data.Graph.Haggle.SimpleBiDigraph | |
MAddVertex g => MAddVertex (EdgeLabeledMGraph g el) Source # | |
Defined in Data.Graph.Haggle.EdgeLabelAdapter |
class MGraph g => MRemovable g where Source #
An interface for graphs that allow vertex and edge removal. Note that implementations are not required to reclaim storage from removed vertices (just make them inaccessible).
class MGraph g => MBidirectional g where Source #
An interface for graphs that support looking at predecessor (incoming edges) efficiently.
getPredecessors :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Vertex] Source #
getInEdges :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m [Edge] Source #
Instances
class MGraph g => MLabeledEdge g where Source #
type MEdgeLabel g Source #
getEdgeLabel :: (PrimMonad m, MonadRef m) => g m -> Edge -> m (Maybe (MEdgeLabel g)) Source #
unsafeGetEdgeLabel :: (PrimMonad m, MonadRef m) => g m -> Edge -> m (MEdgeLabel g) Source #
addLabeledEdge :: (PrimMonad m, MonadRef m) => g m -> Vertex -> Vertex -> MEdgeLabel g -> m (Maybe Edge) Source #
Instances
class MGraph g => MLabeledVertex g where Source #
type MVertexLabel g Source #
getVertexLabel :: (PrimMonad m, MonadRef m) => g m -> Vertex -> m (Maybe (MVertexLabel g)) Source #
addLabeledVertex :: (PrimMonad m, MonadRef m) => g m -> MVertexLabel g -> m Vertex Source #
getLabeledVertices :: (PrimMonad m, MonadRef m) => g m -> m [(Vertex, MVertexLabel g)] Source #
Instances
Immutable Graphs
The basic interface of immutable graphs.
vertices :: g -> [Vertex] Source #
successors :: g -> Vertex -> [Vertex] Source #
outEdges :: g -> Vertex -> [Edge] Source #
maxVertexId :: g -> Int Source #
edgesBetween :: g -> Vertex -> Vertex -> [Edge] Source #
This has a default implementation in terms of outEdges
, but is part
of the class so that instances can offer a more efficient implementation
when possible.
Instances
class Graph g => Thawable g where Source #
Instances
class Graph g => Bidirectional g where Source #
The interface for immutable graphs with efficient access to incoming edges.
Instances
class Graph g => HasEdgeLabel g where Source #
The interface for immutable graphs with labeled edges.
edgeLabel :: g -> Edge -> Maybe (EdgeLabel g) Source #
labeledEdges :: g -> [(Edge, EdgeLabel g)] Source #
labeledOutEdges :: g -> Vertex -> [(Edge, EdgeLabel g)] Source #
Instances
class Graph g => HasVertexLabel g where Source #
The interface for immutable graphs with labeled vertices.
type VertexLabel g Source #
vertexLabel :: g -> Vertex -> Maybe (VertexLabel g) Source #
labeledVertices :: g -> [(Vertex, VertexLabel g)] Source #
Instances
class (HasEdgeLabel g, Bidirectional g) => BidirectionalEdgeLabel g where Source #
Nothing
Instances
BidirectionalEdgeLabel (PatriciaTree nl el) Source # | |
Defined in Data.Graph.Haggle.PatriciaTree labeledInEdges :: PatriciaTree nl el -> Vertex -> [(Edge, EdgeLabel (PatriciaTree nl el))] Source # | |
Bidirectional g => BidirectionalEdgeLabel (EdgeLabeledGraph g el) Source # | |
Defined in Data.Graph.Haggle.EdgeLabelAdapter labeledInEdges :: EdgeLabeledGraph g el -> Vertex -> [(Edge, EdgeLabel (EdgeLabeledGraph g el))] Source # | |
Bidirectional g => BidirectionalEdgeLabel (LabeledGraph g nl el) Source # | |
Defined in Data.Graph.Haggle.Internal.Adapter labeledInEdges :: LabeledGraph g nl el -> Vertex -> [(Edge, EdgeLabel (LabeledGraph g nl el))] Source # |
Inductive Graphs
class (Graph g, HasEdgeLabel g, HasVertexLabel g) => InductiveGraph g where Source #
emptyGraph :: g Source #
The empty inductive graph
match :: g -> Vertex -> Maybe (Context g, g) Source #
The call
let (c, g') = match g v
decomposes the graph into the Context
c of v
and the rest of
the graph g'
.
context :: g -> Vertex -> Maybe (Context g) Source #
Return the context of a Vertex
insertLabeledVertex :: g -> VertexLabel g -> (Vertex, g) Source #
Insert a new labeled Vertex
into the graph.
insertLabeledEdge :: g -> Vertex -> Vertex -> EdgeLabel g -> Maybe (Edge, g) Source #
Must return Nothing
if either the source or destination Vertex
is not
in the graph. Also returns Nothing
if the edge already exists and the
underlying graph does not support parallel edges.
Otherwise return the inserted Edge
and updated graph.
deleteEdge :: g -> Edge -> g Source #
Delete the given Edge
. In a multigraph, this lets you remove
a single parallel edge between two vertices.
deleteEdgesBetween :: g -> Vertex -> Vertex -> g Source #
Delete all edges between a pair of vertices.
replaceLabeledEdge :: g -> Vertex -> Vertex -> EdgeLabel g -> Maybe (Edge, g) Source #
Like insertLabeledEdge
, but overwrite any existing edges. Equivalent
to:
let g' = deleteEdgesBetween g v1 v2 in insertLabeledEdge g v1 v2 lbl
deleteVertex :: g -> Vertex -> g Source #
Remove a Vertex
from the graph
Instances
InductiveGraph (PatriciaTree nl el) Source # | |
Defined in Data.Graph.Haggle.PatriciaTree emptyGraph :: PatriciaTree nl el Source # match :: PatriciaTree nl el -> Vertex -> Maybe (Context (PatriciaTree nl el), PatriciaTree nl el) Source # context :: PatriciaTree nl el -> Vertex -> Maybe (Context (PatriciaTree nl el)) Source # insertLabeledVertex :: PatriciaTree nl el -> VertexLabel (PatriciaTree nl el) -> (Vertex, PatriciaTree nl el) Source # insertLabeledEdge :: PatriciaTree nl el -> Vertex -> Vertex -> EdgeLabel (PatriciaTree nl el) -> Maybe (Edge, PatriciaTree nl el) Source # deleteEdge :: PatriciaTree nl el -> Edge -> PatriciaTree nl el Source # deleteEdgesBetween :: PatriciaTree nl el -> Vertex -> Vertex -> PatriciaTree nl el Source # replaceLabeledEdge :: PatriciaTree nl el -> Vertex -> Vertex -> EdgeLabel (PatriciaTree nl el) -> Maybe (Edge, PatriciaTree nl el) Source # deleteVertex :: PatriciaTree nl el -> Vertex -> PatriciaTree nl el Source # |