Graphviz and the functional graph library

A friend of mine asked how to display a Haskell Functional Graph Library (FGL) graph using graphviz. Turns out it’s really straightforward. Martin Erwig (the author of FGL) considered this when writing the library

$ ghci
> let g=Data.Graph.Inductive.Example.dag4
Use one of the example graphs so that we can print it out.  Then
> import Data.Graph.Inductive.Graphviz
> graphviz g "Foo" (100.0, 100.0) (100, 100) Portrait

where the documentation for the graphviz function is here

Of course, you can do much more complex stuff with the graphviz package…but that’s for another day.

Leave a Reply