-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A graph library that allows to explore edges after their type -- -- It is easiest to explain this library with an example: A node has 300 -- outgoing edges, 100 red, 100 green, 100 blue. If you want to explore -- all green edges, most of the other graph libraries force you to look -- up all 300 edges and then filter after the property green. This means -- 300 O(log n) calls. With this library there is only one (log n) call -- necessary that gives a list of all green edges. @package intmap-graph @version 1.0 module Graph.IntMap -- | Convert a complex edge label to an attribute with 8 bits How to do -- this depends on which edges have to be filtered fast class EdgeAttribute el fastEdgeAttr :: EdgeAttribute el => el -> Word8 edgeFromAttr :: EdgeAttribute el => Map Word8 el show_e :: EdgeAttribute el => Maybe el -> String bases :: EdgeAttribute el => el -> [Edge8] -- | The edges are enumerated, because sometimes the edge attrs are not -- continuous and it is impossible to try all possible 32 bit attrs data Graph nl el Graph :: IntMap (Set Node) -> IntMap (Set Node) -> IntMap nl -> Map (Node, Node) el -> Bool -> Map Word8 el -> Graph nl el -- | A Graph of outgoing 32 bit nodeEdges with 24 bit nodes and 8 bit edges [outgoingNodes] :: Graph nl el -> IntMap (Set Node) -- | A Graph of incoming 32 bit nodeEdges with 24 bit nodes and 8 bit edges [incomingNodes] :: Graph nl el -> IntMap (Set Node) [nodeLabels] :: Graph nl el -> IntMap nl [edgeLabels] :: Graph nl el -> Map (Node, Node) el [is32BitInt] :: Graph nl el -> Bool [showEdge] :: Graph nl el -> Map Word8 el -- | if a node label is complicated, specify a short string to understand -- its type class ExtractNodeType nl extractNodeType :: ExtractNodeType nl => nl -> String -- | A tuple of nodes type Edge = (Node, Node) -- | In Javascript there are only 32 bit integers. If we want to squeeze a -- node and an edge into this we use 24 bits for the node and 8 bits for -- the edge newtype Edge8 Edge8 :: Word8 -> Edge8 -- | Generate an empty graph with 32 bit node-edges (24 bit for the node) -- that can be used with code that ghcjs compiled to javascript empty :: EdgeAttribute el => Graph nl el -- | Construct a graph from a list of nodes, undirected edges and directed -- edges, the bool has to be true it uses 32 bit integers, if false it -- uses 64 bit integers fromLists :: (EdgeAttribute el, Enum nl, Show nl, Show el) => Bool -> [(Node, nl)] -> [((Node, Node), el)] -> [((Node, Node), el)] -> Graph nl el -- | Construct a graph from a node map, undirected edges map and directed -- edges map, b = True means 32 bit integers fromMaps :: (EdgeAttribute el, Show nl, Show el, Enum nl) => Bool -> IntMap nl -> Map (Node, Node) el -> Map (Node, Node) el -> Bool -> Graph nl el -- | Insert node with node label insertNode :: EdgeAttribute el => Node -> nl -> Graph nl el -> Graph nl el -- | Insert nodes with their label insertNodes :: EdgeAttribute el => [(Node, nl)] -> Graph nl el -> Graph nl el -- | Inserting an edge If maybeIsBack is Nothing only one directed is edge -- from n0 to n1 is inserted If maybeIsBack is Just then a second -- directed edge from n1 to n0 is inserted isBack = True means an -- opposite directed edge that can be explored in both directions isBack -- = False means a undirected edge that also can be explored in both -- directions insertEdge :: EdgeAttribute el => Maybe Bool -> Edge -> el -> Graph nl el -> Graph nl el -- | Inserting an edge If maybeIsBack is Nothing only one directed is edge -- from n0 to n1 is inserted If maybeIsBack is Just then a second -- directed edge from n1 to n0 is inserted isBack = True means an -- opposite directed edge that can be explored in both directions isBack -- = False means a undirected edge that also can be explored in both -- directions insertEdges :: EdgeAttribute el => Maybe Bool -> [(Edge, el)] -> Graph nl el -> Graph nl el -- | Makes a union over all components of the graph union :: () => Graph nl el -> Graph nl el -> Graph nl el -- | Mapping a function over the node labels mapNode :: EdgeAttribute el => (nl0 -> nl1) -> Graph nl0 el -> Graph nl1 el -- | Mapping a function over the node labels with node key mapNodeWithKey :: EdgeAttribute el => (Key -> nl0 -> nl1) -> Graph nl0 el -> Graph nl1 el -- | Delete node with its nodelabel and also all outgoing and incoming -- edges with their edgeLabels deleteNode :: (EdgeAttribute el, Show nl, Show el, Enum nl) => el -> Node -> Graph nl el -> Graph nl el -- | Delete nodes with their label deleteNodes :: (Foldable t, EdgeAttribute el, Show nl, Show el, Enum nl) => el -> t Node -> Graph nl el -> Graph nl el -- | "deleteEdge (n0, n1) graph" deletes the edgelabel of (n0,n1) and the -- nodeEdge that points from n0 to n1 If maybeIsBack is Just then a -- second directed edge from n1 to n0 is deleted isBack = True means an -- opposite directed edge that can be explored in both directions isBack -- = False means a undirected edge that also can be explored in both -- directions deleteEdge :: EdgeAttribute el => Maybe Bool -> Edge -> Graph nl el -> Graph nl el -- | Delete a list of (Node,Node) edges from the graph deleteEdges :: (Foldable t, EdgeAttribute el) => Maybe Bool -> t Edge -> Graph nl el -> Graph nl el -- | Are the node-/edge-maps of the graph all empty? isNull :: () => Graph a1 a2 -> Bool -- | The word32 keys of the node labels nodes :: () => Graph a el -> [Key] -- | List of (Node, Node) edges :: () => Graph nl a -> [(Node, Node)] -- | The nodelabel of the given node lookupNode :: (Show nl, EdgeAttribute el) => Node -> Graph nl el -> Maybe nl -- | The edgelabel of the given edge of type (Node, Node) lookupEdge :: (EdgeAttribute el, Show el) => Edge -> Graph nl el -> Maybe el -- | The list of adjacent edges can be divided with 8 bit attributes and -- all edges with a certain attribute selected adjacentNodesByAttr :: EdgeAttribute el => Graph nl el -> Bool -> Node -> Edge8 -> Vector Node -- | Looking at all incoming and outgoing edges we get all adjacent nodes adjacentNodes :: EdgeAttribute el => Graph nl el -> Node -> el -> [Node] -- | Following the incoming edges parents :: EdgeAttribute el => Graph nl el -> Node -> el -> Vector Node -- | Following the outgoing edges children :: EdgeAttribute el => Graph nl el -> Node -> el -> Vector Node -- | Concatenate two Word32 to a Word (64 bit) buildWord64 :: Word32 -> Word32 -> Word -- | Extract the first 32 bit of a 64 bit word extractFirstWord32 :: Word -> Word32 -- | Extract the second 32 bit of a 64 bit word extractSecondWord32 :: Word -> Word32 -- | Nodes can use 24 bits, edges 8 bits buildWord32 :: Word32 -> Word8 -> Word32 -- | Extract the first 24 bit of a 32 bit word extractFirstWord24 :: Word32 -> Word32 -- | Extract the last 8 bit of a 32 bit word extractSecondWord8 :: Word32 -> Word8 -- | Display a 64 bit word so that we can see the bits better showHex :: Word -> String -- | Display a 32 bit word so that we can see the bits better showHex32 :: Word32 -> String instance GHC.Generics.Generic (Graph.IntMap.Graph nl el) instance (Graph.IntMap.EdgeAttribute el, GHC.Show.Show nl, Graph.IntMap.ExtractNodeType nl, GHC.Show.Show el, GHC.Enum.Enum nl) => GHC.Show.Show (Graph.IntMap.Graph nl el) instance (Graph.IntMap.EdgeAttribute el, GHC.Classes.Eq el, GHC.Classes.Eq nl) => GHC.Classes.Eq (Graph.IntMap.Graph nl el) instance GHC.Show.Show Graph.IntMap.Edge8