diff options
authorTillmannVogt <>2019-12-22 22:51:00 (GMT)
committerhdiff <>2019-12-22 22:51:00 (GMT)
commite99b981ce4cacc861ce41b09d325978686f8e320 (patch)
parentcfbd55a8b49a0348cc91140a6786561a8328d796 (diff)
2 files changed, 9 insertions, 5 deletions
diff --git a/intmap-graph.cabal b/intmap-graph.cabal
index 4002451..4d35c1c 100644
--- a/intmap-graph.cabal
+++ b/intmap-graph.cabal
@@ -1,5 +1,5 @@
name: intmap-graph
-version: 1.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.
@@ -8,7 +8,7 @@ license-file: LICENSE
author: Tillmann Vogt
copyright: 2019 Tillmann Vogt
-category: Web
+category: graphs
build-type: Simple
cabal-version: >=1.10
diff --git a/src/Graph/IntMap.hs b/src/Graph/IntMap.hs
index 97a50ac..ec7b2b6 100644
--- a/src/Graph/IntMap.hs
+++ b/src/Graph/IntMap.hs
@@ -5,8 +5,11 @@ Copyright : (C) 2019 Tillmann Vogt
License : BSD-style (see the file LICENSE)
Maintainer : Tillmann Vogt <>
-Stability : provisional
-Portability : POSIX
+Stability : stable
+Portability : GHC
+The general idea of this library is that edges can put into classes.
+As it is faster to lookup a 32/64-bit integer in an intmap than a tuple of integers in a Data.Map-map, we construct a graph by putting a node (24 bit) and its class (8 bit) of adjacent nodes into a 32 bit integer. We need to restrict it to 32 bit, because Javascript (and therefore GHCJS) only has 32 bit integers. If you want to use this library outside of a browser, use 64 bit and set the bool arg of some functions to False. Then there are 32 bits for the node and 32 bits for the edge class.
module Graph.IntMap (
@@ -105,7 +108,8 @@ instance (EdgeAttribute el, Show nl, ExtractNodeType nl, Show el, Enum nl) =>
"}\n" ++
"\nincoming\ndigraph graphviz {\n"++
concat (zipWith3 lines nodeOrigins1 edges1 nodeDests1) ++
- "}\n\n nodes\n" ++ show nlGraph ++ "\n\n edges\n" ++ show elGraph
+ "}\n\n nodes\n" ++ concat (map ((++"\n"). show) (I.toList nlGraph)) ++
+ "\n\n edges\n" ++ concat (map ((++"\n"). show) (Map.toList elGraph))
nodeOrigins0 = map (if b then extractFirstWord24 . fromIntegral
else extractFirstWord32 . fromIntegral)