diff options
authorTillmannVogt <>2020-02-11 16:06:00 (GMT)
committerhdiff <>2020-02-11 16:06:00 (GMT)
commitc308f16c0e3e9c890d535dd0215bb9e909b2f0a4 (patch)
parente99b981ce4cacc861ce41b09d325978686f8e320 (diff)
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
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.
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,
-- * 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