dynamic-graphs: Dynamic graph algorithms

[ bsd3, data, library ] [ Propose Tags ]

A library for dynamic graph algorithms, and in particular dynamic connectivity.

[Skip to Readme]
Versions [faq],,
Change log CHANGELOG.md
Dependencies base (>=4.9 && <4.12), containers (>=0.3 && <0.7), criterion, deepseq, dynamic-graphs, hashable (>=1.0 && <1.3), hashtables (==1.2.*), mwc-random (>=0.12 && <0.14), primitive (>=0.5 && <0.7), QuickCheck, text, unordered-containers (==0.2.*), vector (>=0.10 && <0.13) [details]
License BSD-3-Clause
Copyright 2018 Alex Lang, Jasper Van der Jeugt
Author Alex Lang, Jasper Van der Jeugt
Maintainer me@alang.ca
Revised Revision 1 made by HerbertValerioRiedel at Fri Jan 11 22:35:36 UTC 2019
Category Data
Uploaded by JasperVanDerJeugt at Fri Jan 11 12:32:53 UTC 2019
Distributions NixOS:
Executables gen-program, bench-program, dynamic-graphs-simple
Downloads 352 total (36 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs not available [build log]
All reported builds failed as of 2019-01-11 [all 3 reports]


  • Data
    • Graph
      • Dynamic
        • Data.Graph.Dynamic.EulerTour
        • Internal
          • Data.Graph.Dynamic.Internal.Avl
          • Data.Graph.Dynamic.Internal.HashTable
          • Data.Graph.Dynamic.Internal.Random
          • Data.Graph.Dynamic.Internal.Splay
          • Data.Graph.Dynamic.Internal.Tree
        • Data.Graph.Dynamic.Levels



Build the auxiliary executables, including benchmarks, tools and examples


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Readme for dynamic-graphs-

[back to package description]



A Haskell library for dealing with the dynamic connectivity problem. Consider an undirected graph, where edges may be added and removed. This library allows you to answer the question "are the nodes X and Y connected" at any point in time.

This blogpost has some more information about this library: https://jaspervdj.be/posts/2019-01-11-dynamic-graphs.html.


dynamic-graphs is available on hackage. You can install it using Stack, Cabal, Nix, or whichever tool you prefer.


import qualified Data.Graph.Dynamic.Levels as GD
import qualified Data.Tree as T

main :: IO ()
main = do
    graph <- GD.empty'
    mapM_ (GD.insert_ graph) ["Akanu", "Kanoa", "Kekoa", "Kaiwi", "Onakea"]
    GD.link_ graph "Akanu" "Kanoa"
    GD.link_ graph "Akanu" "Kaiwi"
    GD.link_ graph "Akanu" "Onakea"
    GD.link_ graph "Kaiwi" "Onakea"
    GD.link_ graph "Onakea" "Kanoa"
    GD.link_ graph "Kanoa" "Kekoa"

    GD.connected graph "Kaiwi" "Kekoa" >>= print
    GD.cut_ graph "Kaiwi" "Akanu"
    GD.cut_ graph "Onakea" "Akanu"
    GD.cut_ graph "Onakea" "Kanoa"
    GD.connected graph "Kaiwi" "Kekoa" >>= print
    GD.link_ graph "Akanu" "Kaiwi"
    GD.connected graph "Kaiwi" "Kekoa" >>= print