Copyright | (c) Ivan Lazar Miljenovic |
---|---|
License | MIT |
Maintainer | Ivan.Miljenovic@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Known limitations:
- Adding edges might not be the same depending on graph construction (if you add then delete a lot of edges, then the next new edge might be higher than expected).
- data Graph et n nl el
- type DirGraph = Graph DirEdge
- type UndirGraph = Graph UndirEdge
- type ValidGraph et n = (Hashable n, Eq n, EdgeType et)
- newtype Edge = Edge {}
- data DirEdge n = DE {}
- newtype UndirEdge n = UE {
- ueElem :: [n]
- class (Functor et, NodeFrom (AdjType et)) => EdgeType et where
- class NodeFrom at where
- getNode :: at n -> n
- data DirAdj n
- newtype Identity a :: * -> * = Identity {
- runIdentity :: a
- data Context at n nl el = Ctxt {}
- type AdjLookup n el = HashMap Edge (n, el)
- class Contextual ctxt where
- type ValidContext et n nl el ctxt = (Contextual ctxt, n ~ CNode ctxt, AdjType et ~ CAType ctxt, nl ~ CNLabel ctxt, el ~ CELabel ctxt)
- class Contextual ctxt => FromContext ctxt where
- class Contextual ctxt => ToContext ctxt where
- isEmpty :: Graph et n nl el -> Bool
- order :: Graph et n nl el -> Int
- hasNode :: ValidGraph et n => Graph et n nl el -> n -> Bool
- ninfo :: ValidGraph et n => Graph et n nl el -> n -> Maybe ([Edge], nl)
- nodes :: Graph et n nl el -> [n]
- nodeDetails :: Graph et n nl el -> [(n, ([Edge], nl))]
- lnodes :: Graph et n nl el -> [(n, nl)]
- nlab :: ValidGraph et n => Graph et n nl el -> n -> Maybe nl
- neighbours :: ValidGraph et n => Graph et n nl el -> n -> [n]
- size :: Graph et n nl el -> Int
- hasEdge :: ValidGraph et n => Graph et n nl el -> Edge -> Bool
- einfo :: ValidGraph et n => Graph et n nl el -> Edge -> Maybe (et n, el)
- edges :: Graph et n nl el -> [Edge]
- edgeDetails :: Graph et n nl el -> [(Edge, (et n, el))]
- ledges :: Graph et n nl el -> [(Edge, el)]
- elab :: ValidGraph et n => Graph et n nl el -> Edge -> Maybe el
- edgePairs :: EdgeType et => Graph et n nl el -> [(n, n)]
- ledgePairs :: EdgeType et => Graph et n nl el -> [(n, n, el)]
- empty :: Graph et n nl el
- mkGraph :: ValidGraph et n => [(n, nl)] -> [(n, n, el)] -> Graph et n nl el
- buildGr :: ValidGraph et n => [Context (AdjType et) n nl el] -> Graph et n nl el
- insNode :: ValidGraph et n => n -> nl -> Graph et n nl el -> Graph et n nl el
- insEdge :: ValidGraph et n => (n, n, el) -> Graph et n nl el -> (Edge, Graph et n nl el)
- type Mergeable et n nl el ctxt = (ValidGraph et n, ToContext ctxt, ValidContext et n nl el ctxt)
- merge :: ValidGraph et n => Context (AdjType et) n nl el -> Graph et n nl el -> Graph et n nl el
- mergeAs :: Mergeable et n nl el ctxt => ctxt -> Graph et n nl el -> Graph et n nl el
- delNode :: ValidGraph et n => n -> Graph et n nl el -> Graph et n nl el
- delEdge :: ValidGraph et n => Edge -> Graph et n nl el -> Graph et n nl el
- delEdgeLabel :: (ValidGraph et n, Eq el) => (n, n, el) -> Graph et n nl el -> Graph et n nl el
- delEdgesBetween :: ValidGraph et n => n -> n -> Graph et n nl el -> Graph et n nl el
- type Matchable et n nl el ctxt = (ValidGraph et n, FromContext ctxt, ValidContext et n nl el ctxt)
- match :: ValidGraph et n => n -> Graph et n nl el -> Maybe (Context (AdjType et) n nl el, Graph et n nl el)
- matchAs :: Matchable et n nl el ctxt => n -> Graph et n nl el -> Maybe (ctxt, Graph et n nl el)
- matchAny :: ValidGraph et n => Graph et n nl el -> Maybe (Context (AdjType et) n nl el, Graph et n nl el)
- matchAnyAs :: Matchable et n nl el ctxt => Graph et n nl el -> Maybe (ctxt, Graph et n nl el)
- nmap :: ValidGraph et n => (nl -> nl') -> Graph et n nl el -> Graph et n nl' el
- nmapFor :: ValidGraph et n => (nl -> nl) -> Graph et n nl el -> n -> Graph et n nl el
- emap :: ValidGraph et n => (el -> el') -> Graph et n nl el -> Graph et n nl el'
- emapFor :: ValidGraph et n => (el -> el) -> Graph et n nl el -> Edge -> Graph et n nl el
Graph datatype
type UndirGraph = Graph UndirEdge Source
type ValidGraph et n = (Hashable n, Eq n, EdgeType et) Source
Edge types
Bounded Edge Source | |
Enum Edge Source | |
Eq Edge Source | |
Ord Edge Source | |
Read Edge Source | |
Show Edge Source | |
NFData Edge Source | |
Hashable Edge Source | |
ToContext (n, nl, AdjLookup (at n) el) Source | |
FromContext (n, nl, AdjLookup (at n) el) Source | |
Contextual (n, nl, AdjLookup (at n) el) Source | |
type CNode (n, nl, AdjLookup (at n) el) = n Source | |
type CAType (n, nl, AdjLookup (at n) el) = at Source | |
type CNLabel (n, nl, AdjLookup (at n) el) = nl Source | |
type CELabel (n, nl, AdjLookup (at n) el) = el Source |
Functor DirEdge Source | |
EdgeType DirEdge Source | Note that for loops, the result of |
EdgeMergeable DirEdge Source | |
Eq n => Eq (DirEdge n) Source | |
Ord n => Ord (DirEdge n) Source | |
Read n => Read (DirEdge n) Source | |
Show n => Show (DirEdge n) Source | |
Generic (DirEdge n) Source | |
NFData n => NFData (DirEdge n) Source | |
type AdjType DirEdge = DirAdj Source | |
type Rep (DirEdge n) Source |
Functor UndirEdge Source | |
EdgeType UndirEdge Source | |
EdgeMergeable UndirEdge Source | |
Eq n => Eq (UndirEdge n) Source | |
Ord n => Ord (UndirEdge n) Source | |
Read n => Read (UndirEdge n) Source | |
Show n => Show (UndirEdge n) Source | |
Generic (UndirEdge n) Source | |
NFData n => NFData (UndirEdge n) Source | |
type AdjType UndirEdge = Identity Source | |
type Rep (UndirEdge n) Source |
class (Functor et, NodeFrom (AdjType et)) => EdgeType et where Source
newtype Identity a :: * -> *
Identity functor and monad. (a non-strict monad)
Since: 4.8.0.0
Identity | |
|
Monad Identity | |
Functor Identity | |
MonadFix Identity | |
Applicative Identity | |
Foldable Identity | |
Traversable Identity | |
Generic1 Identity | |
MonadZip Identity | |
NodeFrom Identity Source | |
Eq a => Eq (Identity a) | |
Data a => Data (Identity a) | |
Ord a => Ord (Identity a) | |
Read a => Read (Identity a) | This instance would be equivalent to the derived instances of the
|
Show a => Show (Identity a) | This instance would be equivalent to the derived instances of the
|
Generic (Identity a) | |
NFData a => NFData (Identity a) | Since: 1.4.0.0 |
type Rep1 Identity = D1 D1Identity (C1 C1_0Identity (S1 S1_0_0Identity Par1)) | |
type Rep (Identity a) = D1 D1Identity (C1 C1_0Identity (S1 S1_0_0Identity (Rec0 a))) |
Graph Context
data Context at n nl el Source
(Eq n, Eq nl, Eq el, Eq (at n)) => Eq (Context at n nl el) Source | |
(Read n, Read nl, Read el, Read (at n)) => Read (Context at n nl el) Source | |
(Show n, Show nl, Show el, Show (at n)) => Show (Context at n nl el) Source | |
Generic (Context at n nl el) Source | |
(NFData n, NFData nl, NFData el, NFData (at n)) => NFData (Context at n nl el) Source | |
ToContext (Context at n nl el) Source | |
FromContext (Context at n nl el) Source | |
Contextual (Context at n nl el) Source | |
type Rep (Context at n nl el) Source | |
type CNode (Context at n nl el) = n Source | |
type CAType (Context at n nl el) = at Source | |
type CNLabel (Context at n nl el) = nl Source | |
type CELabel (Context at n nl el) = el Source |
class Contextual ctxt Source
Contextual (n, nl, [(n, [el])]) Source | |
Contextual (n, nl, AdjLookup (at n) el) Source | |
Contextual (Context at n nl el) Source |
type ValidContext et n nl el ctxt = (Contextual ctxt, n ~ CNode ctxt, AdjType et ~ CAType ctxt, nl ~ CNLabel ctxt, el ~ CELabel ctxt) Source
class Contextual ctxt => FromContext ctxt where Source
Ord n => FromContext (n, nl, [(n, [el])]) Source | |
FromContext (n, nl, AdjLookup (at n) el) Source | |
FromContext (Context at n nl el) Source |
class Contextual ctxt => ToContext ctxt where Source
Graph functions
Graph Information
Node information
hasNode :: ValidGraph et n => Graph et n nl el -> n -> Bool Source
nodeDetails :: Graph et n nl el -> [(n, ([Edge], nl))] Source
nlab :: ValidGraph et n => Graph et n nl el -> n -> Maybe nl Source
neighbours :: ValidGraph et n => Graph et n nl el -> n -> [n] Source
Edge information
edgeDetails :: Graph et n nl el -> [(Edge, (et n, el))] Source
ledgePairs :: EdgeType et => Graph et n nl el -> [(n, n, el)] Source
Graph construction
mkGraph :: ValidGraph et n => [(n, nl)] -> [(n, n, el)] -> Graph et n nl el Source
Assumes all nodes are in the node list.
buildGr :: ValidGraph et n => [Context (AdjType et) n nl el] -> Graph et n nl el Source
Assumes the Contexts describe a graph in total, with the
outermost one first (i.e. buildGr (c:cs) == c
).merge
buildGr
cs
insNode :: ValidGraph et n => n -> nl -> Graph et n nl el -> Graph et n nl el Source
Merging
type Mergeable et n nl el ctxt = (ValidGraph et n, ToContext ctxt, ValidContext et n nl el ctxt) Source
merge :: ValidGraph et n => Context (AdjType et) n nl el -> Graph et n nl el -> Graph et n nl el Source
Graph deconstruction
delNode :: ValidGraph et n => n -> Graph et n nl el -> Graph et n nl el Source
delEdgeLabel :: (ValidGraph et n, Eq el) => (n, n, el) -> Graph et n nl el -> Graph et n nl el Source
delEdgesBetween :: ValidGraph et n => n -> n -> Graph et n nl el -> Graph et n nl el Source
Matching
type Matchable et n nl el ctxt = (ValidGraph et n, FromContext ctxt, ValidContext et n nl el ctxt) Source
match :: ValidGraph et n => n -> Graph et n nl el -> Maybe (Context (AdjType et) n nl el, Graph et n nl el) Source
Note that for any loops, the resultant edge will only appear once
in the output cAdj
field.
matchAs :: Matchable et n nl el ctxt => n -> Graph et n nl el -> Maybe (ctxt, Graph et n nl el) Source
matchAny :: ValidGraph et n => Graph et n nl el -> Maybe (Context (AdjType et) n nl el, Graph et n nl el) Source
matchAnyAs :: Matchable et n nl el ctxt => Graph et n nl el -> Maybe (ctxt, Graph et n nl el) Source
Manipulation
nmap :: ValidGraph et n => (nl -> nl') -> Graph et n nl el -> Graph et n nl' el Source
nmapFor :: ValidGraph et n => (nl -> nl) -> Graph et n nl el -> n -> Graph et n nl el Source
emap :: ValidGraph et n => (el -> el') -> Graph et n nl el -> Graph et n nl el' Source