[Haskell-cafe] What is your favourite graph library?

Ignat Insarov kindaro at gmail.com
Wed Feb 24 12:19:53 UTC 2021


Hello!

I really like graphs. People seem to like thinking in terms of dots
and arrows, and graph theory provides a formalization for this.
(Homogeneous binary) relations, finite state automata, networks and
categories are sorts of graphs too.

But unfortunately it is not possible to represent a graph as an
algebraic type. For example, a list is a fixed point of a maybe tuple,
and every usual linear container _(an array, a vector, a sequence…)_
is isomorphous to a list, so we have an easy time prototyping and
specifying the behaviour of any such thing. With graphs, we have a
hard time!

The most popular library for graphs in Haskell is `fgl`.
Unfortunately, it is really easy to get weird behaviour with it,
because folds tear away the limbs from contexts so that your
observation of said contexts depends on the order of folding. I have
been poking at it, trying to make graphs resemble a comonad… but of
course you can have an empty graph, and a comonad cannot be empty.

There is also `alga` — it seemed promising, but now it is deprecated
for some reason… The usual `containers` also provide something they
call a graph, but it does not offer much in terms of instances and
algorithms — a graph is merely a type alias to an array.

So, is there any cool library that I missed? Or some promising
research? Do you know of any packages that use graphs heavily and in
interesting ways? Are you curious to see progress in this area?


More information about the Haskell-Cafe mailing list