**diff options**

author | TillmannVogt <> | 2020-02-11 16:06:00 (GMT) |
---|---|---|

committer | hdiff <hdiff@hdiff.luite.com> | 2020-02-11 16:06:00 (GMT) |

commit | c308f16c0e3e9c890d535dd0215bb9e909b2f0a4 (patch) | |

tree | 273b2aa3df75aafd828fbbc981af249d84490467 | |

parent | e99b981ce4cacc861ce41b09d325978686f8e320 (diff) |

-rw-r--r-- | intmap-graph.cabal | 2 | ||||

-rw-r--r-- | src/Graph/IntMap.hs | 7 |

2 files changed, 7 insertions, 2 deletions

diff --git a/intmap-graph.cabal b/intmap-graph.cabal index 4d35c1c..b06ead2 100644 --- a/intmap-graph.cabal +++ b/intmap-graph.cabal @@ -1,5 +1,5 @@ name: intmap-graph -version: 1.0.0.1 +version: 1.1.0.0 Synopsis: A graph library that allows to explore edges after their type Description: 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. homepage: https://github.com/tkvogt/intmap-graph#readme diff --git a/src/Graph/IntMap.hs b/src/Graph/IntMap.hs index ec7b2b6..046be3c 100644 --- a/src/Graph/IntMap.hs +++ b/src/Graph/IntMap.hs @@ -17,7 +17,7 @@ module Graph.IntMap ( Edge, Edge8(..), -- * Construction empty, fromLists, fromMaps, - insertNode, insertNodes, + insertNode, insertNodes, adjustNode, insertEdge, insertEdges, union, -- * Traversal @@ -188,6 +188,11 @@ insertNodes nodes graph = foldr f graph nodes where f (n, nl) g = insertNode n nl g +-- | Adjust a node label of a specific node. When the node is not a member of the graph, the original graph is returned. +adjustNode :: EdgeAttribute el => (nl -> nl) -> Node -> Graph nl el -> Graph nl el +adjustNode f n graph = -- Debug.Trace.trace "insertNode" $ + graph { nodeLabels = I.adjust f (fromIntegral n) (nodeLabels graph) } + -- | 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 |