{-# LANGUAGE TypeFamilies #-}
module Data.Graph.Haggle.EdgeLabelAdapter (
EdgeLabeledMGraph,
EdgeLabeledGraph,
newEdgeLabeledGraph,
newSizedEdgeLabeledGraph,
mapEdgeLabel
) where
import qualified Control.DeepSeq as DS
import qualified Control.Monad.Primitive as P
import qualified Control.Monad.Ref as R
import qualified Data.Graph.Haggle.Classes as I
import qualified Data.Graph.Haggle.Internal.Adapter as A
newtype EdgeLabeledMGraph g el s = ELMG { EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG :: A.LabeledMGraph g () el s }
newtype EdgeLabeledGraph g el = ELG { EdgeLabeledGraph g el -> LabeledGraph g () el
unELG :: A.LabeledGraph g () el }
instance (DS.NFData g, DS.NFData el) => DS.NFData (EdgeLabeledGraph g el) where
rnf :: EdgeLabeledGraph g el -> ()
rnf (ELG LabeledGraph g () el
g) = LabeledGraph g () el
g LabeledGraph g () el -> () -> ()
forall a b. NFData a => a -> b -> b
`DS.deepseq` ()
mapEdgeLabel :: EdgeLabeledGraph g el -> (el -> el') -> EdgeLabeledGraph g el'
mapEdgeLabel :: EdgeLabeledGraph g el -> (el -> el') -> EdgeLabeledGraph g el'
mapEdgeLabel EdgeLabeledGraph g el
g = LabeledGraph g () el' -> EdgeLabeledGraph g el'
forall g el. LabeledGraph g () el -> EdgeLabeledGraph g el
ELG (LabeledGraph g () el' -> EdgeLabeledGraph g el')
-> ((el -> el') -> LabeledGraph g () el')
-> (el -> el')
-> EdgeLabeledGraph g el'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LabeledGraph g () el -> (el -> el') -> LabeledGraph g () el'
forall g nl el el'.
LabeledGraph g nl el -> (el -> el') -> LabeledGraph g nl el'
A.mapEdgeLabel (EdgeLabeledGraph g el -> LabeledGraph g () el
forall g el. EdgeLabeledGraph g el -> LabeledGraph g () el
unELG EdgeLabeledGraph g el
g)
{-# INLINE mapEdgeLabel #-}
vertices :: (I.Graph g) => EdgeLabeledGraph g el -> [I.Vertex]
vertices :: EdgeLabeledGraph g el -> [Vertex]
vertices = LabeledGraph g () el -> [Vertex]
forall g. Graph g => g -> [Vertex]
I.vertices (LabeledGraph g () el -> [Vertex])
-> (EdgeLabeledGraph g el -> LabeledGraph g () el)
-> EdgeLabeledGraph g el
-> [Vertex]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledGraph g el -> LabeledGraph g () el
forall g el. EdgeLabeledGraph g el -> LabeledGraph g () el
unELG
{-# INLINE vertices #-}
edges :: (I.Graph g) => EdgeLabeledGraph g el -> [I.Edge]
edges :: EdgeLabeledGraph g el -> [Edge]
edges = LabeledGraph g () el -> [Edge]
forall g. Graph g => g -> [Edge]
I.edges (LabeledGraph g () el -> [Edge])
-> (EdgeLabeledGraph g el -> LabeledGraph g () el)
-> EdgeLabeledGraph g el
-> [Edge]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledGraph g el -> LabeledGraph g () el
forall g el. EdgeLabeledGraph g el -> LabeledGraph g () el
unELG
{-# INLINE edges #-}
successors :: (I.Graph g) => EdgeLabeledGraph g el -> I.Vertex -> [I.Vertex]
successors :: EdgeLabeledGraph g el -> Vertex -> [Vertex]
successors (ELG LabeledGraph g () el
lg) = LabeledGraph g () el -> Vertex -> [Vertex]
forall g. Graph g => g -> Vertex -> [Vertex]
I.successors LabeledGraph g () el
lg
{-# INLINE successors #-}
outEdges :: (I.Graph g) => EdgeLabeledGraph g el -> I.Vertex -> [I.Edge]
outEdges :: EdgeLabeledGraph g el -> Vertex -> [Edge]
outEdges (ELG LabeledGraph g () el
lg) = LabeledGraph g () el -> Vertex -> [Edge]
forall g. Graph g => g -> Vertex -> [Edge]
I.outEdges LabeledGraph g () el
lg
{-# INLINE outEdges #-}
edgesBetween :: (I.Graph g) => EdgeLabeledGraph g el -> I.Vertex -> I.Vertex -> [I.Edge]
edgesBetween :: EdgeLabeledGraph g el -> Vertex -> Vertex -> [Edge]
edgesBetween (ELG LabeledGraph g () el
lg) = LabeledGraph g () el -> Vertex -> Vertex -> [Edge]
forall g. Graph g => g -> Vertex -> Vertex -> [Edge]
I.edgesBetween LabeledGraph g () el
lg
{-# INLINE edgesBetween #-}
maxVertexId :: (I.Graph g) => EdgeLabeledGraph g el -> Int
maxVertexId :: EdgeLabeledGraph g el -> Int
maxVertexId = LabeledGraph g () el -> Int
forall g. Graph g => g -> Int
I.maxVertexId (LabeledGraph g () el -> Int)
-> (EdgeLabeledGraph g el -> LabeledGraph g () el)
-> EdgeLabeledGraph g el
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledGraph g el -> LabeledGraph g () el
forall g el. EdgeLabeledGraph g el -> LabeledGraph g () el
unELG
{-# INLINE maxVertexId #-}
isEmpty :: (I.Graph g) => EdgeLabeledGraph g el -> Bool
isEmpty :: EdgeLabeledGraph g el -> Bool
isEmpty = LabeledGraph g () el -> Bool
forall g. Graph g => g -> Bool
I.isEmpty (LabeledGraph g () el -> Bool)
-> (EdgeLabeledGraph g el -> LabeledGraph g () el)
-> EdgeLabeledGraph g el
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledGraph g el -> LabeledGraph g () el
forall g el. EdgeLabeledGraph g el -> LabeledGraph g () el
unELG
{-# INLINE isEmpty #-}
instance (I.Graph g) => I.Graph (EdgeLabeledGraph g el) where
vertices :: EdgeLabeledGraph g el -> [Vertex]
vertices = EdgeLabeledGraph g el -> [Vertex]
forall g el. Graph g => EdgeLabeledGraph g el -> [Vertex]
vertices
edges :: EdgeLabeledGraph g el -> [Edge]
edges = EdgeLabeledGraph g el -> [Edge]
forall g el. Graph g => EdgeLabeledGraph g el -> [Edge]
edges
successors :: EdgeLabeledGraph g el -> Vertex -> [Vertex]
successors = EdgeLabeledGraph g el -> Vertex -> [Vertex]
forall g el. Graph g => EdgeLabeledGraph g el -> Vertex -> [Vertex]
successors
outEdges :: EdgeLabeledGraph g el -> Vertex -> [Edge]
outEdges = EdgeLabeledGraph g el -> Vertex -> [Edge]
forall g el. Graph g => EdgeLabeledGraph g el -> Vertex -> [Edge]
outEdges
edgesBetween :: EdgeLabeledGraph g el -> Vertex -> Vertex -> [Edge]
edgesBetween = EdgeLabeledGraph g el -> Vertex -> Vertex -> [Edge]
forall g el.
Graph g =>
EdgeLabeledGraph g el -> Vertex -> Vertex -> [Edge]
edgesBetween
maxVertexId :: EdgeLabeledGraph g el -> Int
maxVertexId = EdgeLabeledGraph g el -> Int
forall g el. Graph g => EdgeLabeledGraph g el -> Int
maxVertexId
isEmpty :: EdgeLabeledGraph g el -> Bool
isEmpty = EdgeLabeledGraph g el -> Bool
forall g el. Graph g => EdgeLabeledGraph g el -> Bool
isEmpty
instance (I.Thawable g) => I.Thawable (EdgeLabeledGraph g el) where
type MutableGraph (EdgeLabeledGraph g el) =
EdgeLabeledMGraph (I.MutableGraph g) el
thaw :: EdgeLabeledGraph g el -> m (MutableGraph (EdgeLabeledGraph g el) m)
thaw (ELG LabeledGraph g () el
lg) = do
LabeledMGraph (MutableGraph g) () el m
g' <- LabeledGraph g () el -> m (MutableGraph (LabeledGraph g () el) m)
forall g (m :: * -> *).
(Thawable g, PrimMonad m, MonadRef m) =>
g -> m (MutableGraph g m)
I.thaw LabeledGraph g () el
lg
EdgeLabeledMGraph (MutableGraph g) el m
-> m (EdgeLabeledMGraph (MutableGraph g) el m)
forall (m :: * -> *) a. Monad m => a -> m a
return (EdgeLabeledMGraph (MutableGraph g) el m
-> m (EdgeLabeledMGraph (MutableGraph g) el m))
-> EdgeLabeledMGraph (MutableGraph g) el m
-> m (EdgeLabeledMGraph (MutableGraph g) el m)
forall a b. (a -> b) -> a -> b
$ LabeledMGraph (MutableGraph g) () el m
-> EdgeLabeledMGraph (MutableGraph g) el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
LabeledMGraph g () el s -> EdgeLabeledMGraph g el s
ELMG LabeledMGraph (MutableGraph g) () el m
g'
predecessors :: (I.Bidirectional g) => EdgeLabeledGraph g el -> I.Vertex -> [I.Vertex]
predecessors :: EdgeLabeledGraph g el -> Vertex -> [Vertex]
predecessors (ELG LabeledGraph g () el
lg) = LabeledGraph g () el -> Vertex -> [Vertex]
forall g. Bidirectional g => g -> Vertex -> [Vertex]
I.predecessors LabeledGraph g () el
lg
{-# INLINE predecessors #-}
inEdges :: (I.Bidirectional g) => EdgeLabeledGraph g el -> I.Vertex -> [I.Edge]
inEdges :: EdgeLabeledGraph g el -> Vertex -> [Edge]
inEdges (ELG LabeledGraph g () el
lg) = LabeledGraph g () el -> Vertex -> [Edge]
forall g. Bidirectional g => g -> Vertex -> [Edge]
I.inEdges LabeledGraph g () el
lg
{-# INLINE inEdges #-}
instance (I.Bidirectional g) => I.Bidirectional (EdgeLabeledGraph g el) where
predecessors :: EdgeLabeledGraph g el -> Vertex -> [Vertex]
predecessors = EdgeLabeledGraph g el -> Vertex -> [Vertex]
forall g el.
Bidirectional g =>
EdgeLabeledGraph g el -> Vertex -> [Vertex]
predecessors
inEdges :: EdgeLabeledGraph g el -> Vertex -> [Edge]
inEdges = EdgeLabeledGraph g el -> Vertex -> [Edge]
forall g el.
Bidirectional g =>
EdgeLabeledGraph g el -> Vertex -> [Edge]
inEdges
instance (I.Bidirectional g) => I.BidirectionalEdgeLabel (EdgeLabeledGraph g el)
edgeLabel :: (I.Graph g) => EdgeLabeledGraph g el -> I.Edge -> Maybe el
edgeLabel :: EdgeLabeledGraph g el -> Edge -> Maybe el
edgeLabel (ELG LabeledGraph g () el
lg) = LabeledGraph g () el
-> Edge -> Maybe (EdgeLabel (LabeledGraph g () el))
forall g. HasEdgeLabel g => g -> Edge -> Maybe (EdgeLabel g)
I.edgeLabel LabeledGraph g () el
lg
{-# INLINE edgeLabel #-}
labeledEdges :: (I.Graph g) => EdgeLabeledGraph g el -> [(I.Edge, el)]
labeledEdges :: EdgeLabeledGraph g el -> [(Edge, el)]
labeledEdges = LabeledGraph g () el -> [(Edge, el)]
forall g. HasEdgeLabel g => g -> [(Edge, EdgeLabel g)]
I.labeledEdges (LabeledGraph g () el -> [(Edge, el)])
-> (EdgeLabeledGraph g el -> LabeledGraph g () el)
-> EdgeLabeledGraph g el
-> [(Edge, el)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledGraph g el -> LabeledGraph g () el
forall g el. EdgeLabeledGraph g el -> LabeledGraph g () el
unELG
{-# INLINE labeledEdges #-}
instance (I.Graph g) => I.HasEdgeLabel (EdgeLabeledGraph g el) where
type EdgeLabel (EdgeLabeledGraph g el) = el
edgeLabel :: EdgeLabeledGraph g el
-> Edge -> Maybe (EdgeLabel (EdgeLabeledGraph g el))
edgeLabel = EdgeLabeledGraph g el
-> Edge -> Maybe (EdgeLabel (EdgeLabeledGraph g el))
forall g el. Graph g => EdgeLabeledGraph g el -> Edge -> Maybe el
edgeLabel
labeledEdges :: EdgeLabeledGraph g el
-> [(Edge, EdgeLabel (EdgeLabeledGraph g el))]
labeledEdges = EdgeLabeledGraph g el
-> [(Edge, EdgeLabel (EdgeLabeledGraph g el))]
forall g el. Graph g => EdgeLabeledGraph g el -> [(Edge, el)]
labeledEdges
newEdgeLabeledGraph :: (I.MGraph g, P.PrimMonad m, R.MonadRef m)
=> m (g m)
-> m (EdgeLabeledMGraph g nl m)
newEdgeLabeledGraph :: m (g m) -> m (EdgeLabeledMGraph g nl m)
newEdgeLabeledGraph m (g m)
newG = do
LabeledMGraph g () nl m
g <- m (g m) -> m (LabeledMGraph g () nl m)
forall (g :: (* -> *) -> *) (m :: * -> *) nl el.
(MGraph g, PrimMonad m, MonadRef m) =>
m (g m) -> m (LabeledMGraph g nl el m)
A.newLabeledGraph m (g m)
newG
EdgeLabeledMGraph g nl m -> m (EdgeLabeledMGraph g nl m)
forall (m :: * -> *) a. Monad m => a -> m a
return (EdgeLabeledMGraph g nl m -> m (EdgeLabeledMGraph g nl m))
-> EdgeLabeledMGraph g nl m -> m (EdgeLabeledMGraph g nl m)
forall a b. (a -> b) -> a -> b
$ LabeledMGraph g () nl m -> EdgeLabeledMGraph g nl m
forall (g :: (* -> *) -> *) el (s :: * -> *).
LabeledMGraph g () el s -> EdgeLabeledMGraph g el s
ELMG LabeledMGraph g () nl m
g
{-# INLINE newEdgeLabeledGraph #-}
newSizedEdgeLabeledGraph :: (I.MGraph g, P.PrimMonad m, R.MonadRef m)
=> (Int -> Int -> m (g m))
-> Int
-> Int
-> m (EdgeLabeledMGraph g el m)
newSizedEdgeLabeledGraph :: (Int -> Int -> m (g m))
-> Int -> Int -> m (EdgeLabeledMGraph g el m)
newSizedEdgeLabeledGraph Int -> Int -> m (g m)
newG Int
szV Int
szE = do
LabeledMGraph g () el m
g <- (Int -> Int -> m (g m))
-> Int -> Int -> m (LabeledMGraph g () el m)
forall (g :: (* -> *) -> *) (m :: * -> *) nl el.
(MGraph g, PrimMonad m, MonadRef m) =>
(Int -> Int -> m (g m))
-> Int -> Int -> m (LabeledMGraph g nl el m)
A.newSizedLabeledGraph Int -> Int -> m (g m)
newG Int
szV Int
szE
EdgeLabeledMGraph g el m -> m (EdgeLabeledMGraph g el m)
forall (m :: * -> *) a. Monad m => a -> m a
return (EdgeLabeledMGraph g el m -> m (EdgeLabeledMGraph g el m))
-> EdgeLabeledMGraph g el m -> m (EdgeLabeledMGraph g el m)
forall a b. (a -> b) -> a -> b
$ LabeledMGraph g () el m -> EdgeLabeledMGraph g el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
LabeledMGraph g () el s -> EdgeLabeledMGraph g el s
ELMG LabeledMGraph g () el m
g
{-# INLINE newSizedEdgeLabeledGraph #-}
addLabeledEdge :: (I.MGraph g, I.MAddEdge g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m
-> I.Vertex
-> I.Vertex
-> el
-> m (Maybe I.Edge)
addLabeledEdge :: EdgeLabeledMGraph g el m
-> Vertex -> Vertex -> el -> m (Maybe Edge)
addLabeledEdge EdgeLabeledMGraph g el m
lg = LabeledMGraph g () el m
-> Vertex
-> Vertex
-> MEdgeLabel (LabeledMGraph g () el)
-> m (Maybe Edge)
forall (g :: (* -> *) -> *) (m :: * -> *).
(MLabeledEdge g, PrimMonad m, MonadRef m) =>
g m -> Vertex -> Vertex -> MEdgeLabel g -> m (Maybe Edge)
I.addLabeledEdge (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg)
{-# INLINE addLabeledEdge #-}
addVertex :: (I.MGraph g, I.MAddVertex g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m
-> m I.Vertex
addVertex :: EdgeLabeledMGraph g el m -> m Vertex
addVertex EdgeLabeledMGraph g el m
lg = g m -> m Vertex
forall (g :: (* -> *) -> *) (m :: * -> *).
(MAddVertex g, PrimMonad m, MonadRef m) =>
g m -> m Vertex
I.addVertex (LabeledMGraph g () el m -> g m
forall (g :: (* -> *) -> *) nl el (m :: * -> *).
LabeledMGraph g nl el m -> g m
A.rawMGraph (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg))
{-# INLINE addVertex #-}
unsafeGetEdgeLabel :: (I.MGraph g, I.MAddEdge g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m
-> I.Edge
-> m el
unsafeGetEdgeLabel :: EdgeLabeledMGraph g el m -> Edge -> m el
unsafeGetEdgeLabel (ELMG LabeledMGraph g () el m
g) Edge
e =
LabeledMGraph g () el m
-> Edge -> m (MEdgeLabel (LabeledMGraph g () el))
forall (g :: (* -> *) -> *) (m :: * -> *).
(MLabeledEdge g, PrimMonad m, MonadRef m) =>
g m -> Edge -> m (MEdgeLabel g)
I.unsafeGetEdgeLabel LabeledMGraph g () el m
g Edge
e
{-# INLINE unsafeGetEdgeLabel #-}
getSuccessors :: (I.MGraph g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m
-> I.Vertex
-> m [I.Vertex]
getSuccessors :: EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
getSuccessors EdgeLabeledMGraph g el m
lg = LabeledMGraph g () el m -> Vertex -> m [Vertex]
forall (g :: (* -> *) -> *) (m :: * -> *).
(MGraph g, PrimMonad m, MonadRef m) =>
g m -> Vertex -> m [Vertex]
I.getSuccessors (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg)
{-# INLINE getSuccessors #-}
getOutEdges :: (I.MGraph g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m -> I.Vertex -> m [I.Edge]
getOutEdges :: EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
getOutEdges EdgeLabeledMGraph g el m
lg = LabeledMGraph g () el m -> Vertex -> m [Edge]
forall (g :: (* -> *) -> *) (m :: * -> *).
(MGraph g, PrimMonad m, MonadRef m) =>
g m -> Vertex -> m [Edge]
I.getOutEdges (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg)
{-# INLINE getOutEdges #-}
countVertices :: (I.MGraph g, P.PrimMonad m, R.MonadRef m) => EdgeLabeledMGraph g el m -> m Int
countVertices :: EdgeLabeledMGraph g el m -> m Int
countVertices = LabeledMGraph g () el m -> m Int
forall (g :: (* -> *) -> *) (m :: * -> *).
(MGraph g, PrimMonad m, MonadRef m) =>
g m -> m Int
I.countVertices (LabeledMGraph g () el m -> m Int)
-> (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m)
-> EdgeLabeledMGraph g el m
-> m Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG
{-# INLINE countVertices #-}
getVertices :: (I.MGraph g, P.PrimMonad m, R.MonadRef m) => EdgeLabeledMGraph g el m -> m [I.Vertex]
getVertices :: EdgeLabeledMGraph g el m -> m [Vertex]
getVertices = LabeledMGraph g () el m -> m [Vertex]
forall (g :: (* -> *) -> *) (m :: * -> *).
(MGraph g, PrimMonad m, MonadRef m) =>
g m -> m [Vertex]
I.getVertices (LabeledMGraph g () el m -> m [Vertex])
-> (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m)
-> EdgeLabeledMGraph g el m
-> m [Vertex]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG
{-# INLINE getVertices #-}
countEdges :: (I.MGraph g, P.PrimMonad m, R.MonadRef m) => EdgeLabeledMGraph g el m -> m Int
countEdges :: EdgeLabeledMGraph g el m -> m Int
countEdges = LabeledMGraph g () el m -> m Int
forall (g :: (* -> *) -> *) (m :: * -> *).
(MGraph g, PrimMonad m, MonadRef m) =>
g m -> m Int
I.countEdges (LabeledMGraph g () el m -> m Int)
-> (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m)
-> EdgeLabeledMGraph g el m
-> m Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG
{-# INLINE countEdges #-}
getPredecessors :: (I.MBidirectional g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m -> I.Vertex -> m [I.Vertex]
getPredecessors :: EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
getPredecessors EdgeLabeledMGraph g el m
lg = LabeledMGraph g () el m -> Vertex -> m [Vertex]
forall (g :: (* -> *) -> *) (m :: * -> *).
(MBidirectional g, PrimMonad m, MonadRef m) =>
g m -> Vertex -> m [Vertex]
I.getPredecessors (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg)
{-# INLINE getPredecessors #-}
getInEdges :: (I.MBidirectional g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m -> I.Vertex -> m [I.Edge]
getInEdges :: EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
getInEdges EdgeLabeledMGraph g el m
lg = LabeledMGraph g () el m -> Vertex -> m [Edge]
forall (g :: (* -> *) -> *) (m :: * -> *).
(MBidirectional g, PrimMonad m, MonadRef m) =>
g m -> Vertex -> m [Edge]
I.getInEdges (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg)
{-# INLINE getInEdges #-}
checkEdgeExists :: (I.MGraph g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m
-> I.Vertex
-> I.Vertex
-> m Bool
checkEdgeExists :: EdgeLabeledMGraph g el m -> Vertex -> Vertex -> m Bool
checkEdgeExists EdgeLabeledMGraph g el m
lg = LabeledMGraph g () el m -> Vertex -> Vertex -> m Bool
forall (g :: (* -> *) -> *) (m :: * -> *).
(MGraph g, PrimMonad m, MonadRef m) =>
g m -> Vertex -> Vertex -> m Bool
I.checkEdgeExists (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg)
{-# INLINE checkEdgeExists #-}
freeze :: (I.MGraph g, P.PrimMonad m, R.MonadRef m)
=> EdgeLabeledMGraph g el m
-> m (EdgeLabeledGraph (I.ImmutableGraph g) el)
freeze :: EdgeLabeledMGraph g el m
-> m (EdgeLabeledGraph (ImmutableGraph g) el)
freeze EdgeLabeledMGraph g el m
lg = do
LabeledGraph (ImmutableGraph g) () el
g' <- LabeledMGraph g () el m
-> m (ImmutableGraph (LabeledMGraph g () el))
forall (g :: (* -> *) -> *) (m :: * -> *).
(MGraph g, PrimMonad m, MonadRef m) =>
g m -> m (ImmutableGraph g)
I.freeze (EdgeLabeledMGraph g el m -> LabeledMGraph g () el m
forall (g :: (* -> *) -> *) el (s :: * -> *).
EdgeLabeledMGraph g el s -> LabeledMGraph g () el s
unELMG EdgeLabeledMGraph g el m
lg)
EdgeLabeledGraph (ImmutableGraph g) el
-> m (EdgeLabeledGraph (ImmutableGraph g) el)
forall (m :: * -> *) a. Monad m => a -> m a
return (EdgeLabeledGraph (ImmutableGraph g) el
-> m (EdgeLabeledGraph (ImmutableGraph g) el))
-> EdgeLabeledGraph (ImmutableGraph g) el
-> m (EdgeLabeledGraph (ImmutableGraph g) el)
forall a b. (a -> b) -> a -> b
$ LabeledGraph (ImmutableGraph g) () el
-> EdgeLabeledGraph (ImmutableGraph g) el
forall g el. LabeledGraph g () el -> EdgeLabeledGraph g el
ELG LabeledGraph (ImmutableGraph g) () el
g'
{-# INLINE freeze #-}
instance (I.MGraph g) => I.MGraph (EdgeLabeledMGraph g el) where
type ImmutableGraph (EdgeLabeledMGraph g el) =
EdgeLabeledGraph (I.ImmutableGraph g) el
getVertices :: EdgeLabeledMGraph g el m -> m [Vertex]
getVertices = EdgeLabeledMGraph g el m -> m [Vertex]
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> m [Vertex]
getVertices
getSuccessors :: EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
getSuccessors = EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
getSuccessors
getOutEdges :: EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
getOutEdges = EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
getOutEdges
countVertices :: EdgeLabeledMGraph g el m -> m Int
countVertices = EdgeLabeledMGraph g el m -> m Int
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> m Int
countVertices
countEdges :: EdgeLabeledMGraph g el m -> m Int
countEdges = EdgeLabeledMGraph g el m -> m Int
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> m Int
countEdges
checkEdgeExists :: EdgeLabeledMGraph g el m -> Vertex -> Vertex -> m Bool
checkEdgeExists = EdgeLabeledMGraph g el m -> Vertex -> Vertex -> m Bool
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> Vertex -> Vertex -> m Bool
checkEdgeExists
freeze :: EdgeLabeledMGraph g el m
-> m (ImmutableGraph (EdgeLabeledMGraph g el))
freeze = EdgeLabeledMGraph g el m
-> m (ImmutableGraph (EdgeLabeledMGraph g el))
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m
-> m (EdgeLabeledGraph (ImmutableGraph g) el)
freeze
instance (I.MBidirectional g) => I.MBidirectional (EdgeLabeledMGraph g el) where
getPredecessors :: EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
getPredecessors = EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MBidirectional g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> Vertex -> m [Vertex]
getPredecessors
getInEdges :: EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
getInEdges = EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MBidirectional g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> Vertex -> m [Edge]
getInEdges
instance (I.MAddVertex g) => I.MAddVertex (EdgeLabeledMGraph g el) where
addVertex :: EdgeLabeledMGraph g el m -> m Vertex
addVertex = EdgeLabeledMGraph g el m -> m Vertex
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, MAddVertex g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> m Vertex
addVertex
instance (I.MAddEdge g) => I.MLabeledEdge (EdgeLabeledMGraph g el) where
type MEdgeLabel (EdgeLabeledMGraph g el) = el
unsafeGetEdgeLabel :: EdgeLabeledMGraph g el m
-> Edge -> m (MEdgeLabel (EdgeLabeledMGraph g el))
unsafeGetEdgeLabel = EdgeLabeledMGraph g el m
-> Edge -> m (MEdgeLabel (EdgeLabeledMGraph g el))
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, MAddEdge g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m -> Edge -> m el
unsafeGetEdgeLabel
addLabeledEdge :: EdgeLabeledMGraph g el m
-> Vertex
-> Vertex
-> MEdgeLabel (EdgeLabeledMGraph g el)
-> m (Maybe Edge)
addLabeledEdge = EdgeLabeledMGraph g el m
-> Vertex
-> Vertex
-> MEdgeLabel (EdgeLabeledMGraph g el)
-> m (Maybe Edge)
forall (g :: (* -> *) -> *) (m :: * -> *) el.
(MGraph g, MAddEdge g, PrimMonad m, MonadRef m) =>
EdgeLabeledMGraph g el m
-> Vertex -> Vertex -> el -> m (Maybe Edge)
addLabeledEdge