Library for inductive graphs (port of a Haskell library by Martin Erwig).
In this library, graphs are composed and decomposed in an inductive way.
The key idea is as follows:
            A graph is either empty or it consists of node context 
and a graph g' which 
are put together by a constructor (:&).
          
            This constructor (:&), however, is not a constructor in 
the sense of abstract 
data type, but more basically a defined constructing funtion. 
          
A context is a node together withe the edges to and from this node into the nodes in the graph g'.
            For examples of how to use this library, cf. the module GraphAlgorithms.
          
Author: Bernd Brassel
Version: Janaury 2019
| (:&)
                  :: Show a => ([(b,Int)],Int,a,[(b,Int)]) -> Graph a b -> Graph a b(:&) takes a node-context and a Graph and yields a new graph. | 
| matchAny
                  ::  Graph a b -> (([(b,Int)],Int,a,[(b,Int)]),Graph a b)decompose a graph into the Contextfor an arbitrarily-chosenNodeand the remainingGraph. | 
| empty
                  ::  Graph a bAn empty Graph. | 
| mkGraph
                  :: Show a => [(Int,a)] -> [(Int,Int,b)] -> Graph a bCreate a Graphfrom the list ofLNodes andLEdges. | 
| buildGr
                  :: Show a => [([(b,Int)],Int,a,[(b,Int)])] -> Graph a bBuild a Graphfrom a list ofContexts. | 
| mkUGraph
                  ::  [Int] -> [(Int,Int)] -> Graph () ()Build a quasi-unlabeled Graphfrom the list ofNodes andEdges. | 
| insNode
                  :: Show a => (Int,a) -> Graph a b -> Graph a bInsert a LNodeinto theGraph. | 
| insEdge
                  :: Show a => (Int,Int,b) -> Graph a b -> Graph a bInsert a LEdgeinto theGraph. | 
| delNode
                  ::  Int -> Graph a b -> Graph a bRemove a Nodefrom theGraph. | 
| delEdge
                  :: Show a => (Int,Int) -> Graph a b -> Graph a bRemove an Edgefrom theGraph. | 
| insNodes
                  :: Show a => [(Int,a)] -> Graph a b -> Graph a bInsert multiple LNodes into theGraph. | 
| insEdges
                  :: Show a => [(Int,Int,b)] -> Graph a b -> Graph a bInsert multiple LEdges into theGraph. | 
| delNodes
                  ::  [Int] -> Graph a b -> Graph a bRemove multiple Nodes from theGraph. | 
| delEdges
                  :: Show a => [(Int,Int)] -> Graph a b -> Graph a bRemove multiple Edges from theGraph. | 
| isEmpty
                  ::  Graph a b -> Booltest if the given Graphis empty. | 
| match
                  ::  Int -> Graph a b -> (Maybe ([(b,Int)],Int,a,[(b,Int)]),Graph a b)match is the complement side of (:&), decomposing a Graphinto theMContextfound for the given node and the remainingGraph. | 
| noNodes
                  ::  Graph a b -> IntThe number of Nodes in aGraph. | 
| nodeRange
                  ::  Graph a b -> (Int,Int)The minimum and maximum Nodein aGraph. | 
| context
                  ::  Graph a b -> Int -> ([(b,Int)],Int,a,[(b,Int)])Find the context for the given Node. | 
| lab
                  ::  Graph a b -> Int -> Maybe aFind the label for a Node. | 
| neighbors
                  ::  Graph a b -> Int -> [Int]Find the neighbors for a Node. | 
| suc
                  ::  Graph a b -> Int -> [Int]Find all Nodes that have a link from the givenNode. | 
| pre
                  ::  Graph a b -> Int -> [Int]Find all Nodes that link to to the givenNode. | 
| lsuc
                  ::  Graph a b -> Int -> [(Int,b)]Find all Nodes and their labels, which are linked from the given Node. | 
| lpre
                  ::  Graph a b -> Int -> [(Int,b)]Find all Nodes that link to the givenNodeand the label of each link. | 
| out
                  ::  Graph a b -> Int -> [(Int,Int,b)]Find all outward-bound LEdges for the givenNode. | 
| inn
                  ::  Graph a b -> Int -> [(Int,Int,b)]Find all inward-bound LEdges for the givenNode. | 
| outdeg
                  ::  Graph a b -> Int -> IntThe outward-bound degree of the Node. | 
| indeg
                  ::  Graph a b -> Int -> IntThe inward-bound degree of the Node. | 
| deg
                  ::  Graph a b -> Int -> IntThe degree of the Node. | 
| gelem
                  ::  Int -> Graph a b -> BoolTrueif theNodeis present in theGraph. | 
| equal
                  :: (Eq a, Eq b) => Graph a b -> Graph a b -> Boolgraph equality | 
| node'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> IntThe Nodein aContext. | 
| lab'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> bThe label in a Context. | 
| labNode'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> (Int,b)The LNodefrom aContext. | 
| neighbors'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> [Int]All Nodes linked to or from in aContext. | 
| suc'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> [Int]All Nodes linked to in aContext. | 
| pre'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> [Int]All Nodes linked from in aContext. | 
| lpre'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> [(Int,a)]All Nodes linked from in aContext, and the label of the links. | 
| lsuc'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> [(Int,a)]All Nodes linked from in aContext, and the label of the links. | 
| out'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> [(Int,Int,a)]All outward-directed LEdges in aContext. | 
| inn'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> [(Int,Int,a)]All inward-directed LEdges in aContext. | 
| outdeg'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> IntThe outward degree of a Context. | 
| indeg'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> IntThe inward degree of a Context. | 
| deg'
                  ::  ([(a,Int)],Int,b,[(a,Int)]) -> IntThe degree of a Context. | 
| labNodes
                  ::  Graph a b -> [(Int,a)]A list of all LNodes in theGraph. | 
| labEdges
                  ::  Graph a b -> [(Int,Int,b)]A list of all LEdges in theGraph. | 
| nodes
                  ::  Graph a b -> [Int]List all Nodes in theGraph. | 
| edges
                  ::  Graph a b -> [(Int,Int)]List all Edges in theGraph. | 
| newNodes
                  ::  Int -> Graph a b -> [Int]List N available Nodes, ieNodes that are not used in theGraph. | 
| ufold
                  ::  (([(a,Int)],Int,b,[(a,Int)]) -> c -> c) -> c -> Graph b a -> cFold a function over the graph. | 
| gmap
                  :: Show a => (([(b,Int)],Int,c,[(b,Int)]) -> ([(d,Int)],Int,a,[(d,Int)])) -> Graph c b -> Graph a dMap a function over the graph. | 
| nmap
                  :: Show a => (b -> a) -> Graph b c -> Graph a cMap a function over the Nodelabels in a graph. | 
| emap
                  :: Show a => (b -> c) -> Graph a b -> Graph a cMap a function over the Edgelabels in a graph. | 
| labUEdges
                  ::  [(a,b)] -> [(a,b,())]add label () to list of edges (node,node) | 
| labUNodes
                  ::  [a] -> [(a,())]add label () to list of nodes | 
| showGraph
                  :: (Show a, Show b) => Graph a b -> StringRepresent Graph as String | 
The type variables of Graph are nodeLabel and edgeLabel. The internal representation of Graph is hidden.
Constructors:
Nodes and edges themselves (in contrast to their labels) are coded as integers.
For both of them, there are variants as labeled, unlabelwd and quasi unlabeled (labeled with ()).
Unlabeled node
              Type synonym: Node = Int
            
Labeled node
              Type synonym: LNode a = (Node,a)
            
Quasi-unlabeled node
              Type synonym: UNode = LNode ()
            
Unlabeled edge
              Type synonym: Edge = (Node,Node)
            
Labeled edge
              Type synonym: LEdge a = (Node,Node,a)
            
Quasi-unlabeled edge
              Type synonym: UEdge = LEdge ()
            
The context of a node is the node itself (along with label) and its adjacent nodes. Thus, a context is a quadrupel, for node n it is of the form (edges to n,node n,n's label,edges from n)
              Type synonym: Context a b = (Adj b,Node,a,Adj b)
            
maybe context
              Type synonym: MContext a b = Maybe (Context a b)
            
context with edges and node label only, without the node identifier itself
              Type synonym: Context' a b = (Adj b,a,Adj b)
            
Unlabeled context.
              Type synonym: UContext = ([Node],Node,[Node])
            
A graph decompostion is a context for a node n and the remaining graph without that node.
              Type synonym: GDecomp a b = (Context a b,Graph a b)
            
a decomposition with a maybe context
              Type synonym: Decomp a b = (MContext a b,Graph a b)
            
Unlabeled decomposition.
              Type synonym: UDecomp a = (Maybe UContext,a)
            
Unlabeled path
              Type synonym: Path = [Node]
            
Labeled path
              Type synonym: LPath a = [LNode a]
            
Quasi-unlabeled path
              Type synonym: UPath = [UNode]
            
a graph without any labels
              Type synonym: UGr = Graph () ()
            
| 
                       (:&) takes a node-context and a Graph and yields a new graph. The according key idea is detailed at the beginning. nl is the type of the node labels and el the edge labels. Note that it is an error to induce a context for a node already contained in the graph. 
 | 
| 
                       
                      decompose a graph into the  In order to use graphs as abstract data structures, we also need means to decompose a graph. This decompostion should work as much like pattern matching as possible. The normal matching is done by the function matchAny, which takes a graph and yields a graph decompostion. According to the main idea, matchAny . (:&) should be an identity. 
 | 
| 
                       
                      Build a quasi-unlabeled  | 
| 
                       
                      match is the complement side of (:&), decomposing a  | 
| 
                      The number of  
 | 
| 
                       
                      Find the context for the given  | 
| 
                       
                      Find all Nodes and their labels, which are linked from the given  | 
| 
                       
                      Find all  | 
| 
                       
 | 
| 
                       
                      The label in a  
 | 
| 
                       
 | 
| 
                       | 
| 
                       
                      All  | 
| 
                       
                      All  | 
| 
                       
                      List N available  | 
| 
                       Fold a function over the graph. | 
| 
                       Map a function over the graph. | 
| 
                       
                      Map a function over the  | 
| 
                       
                      Map a function over the  | 
| 
                       add label () to list of edges (node,node) | 
| 
                       add label () to list of nodes |