Visualizing a graph network

Graphical networks of edges and nodes can be difficult to debug or comprehend, and thus, visualization helps tremendously. In this recipe, we will convert a graph data structure into an image of nodes and edges.

Getting ready

To use Graphviz, the graph visualization library, we must first install it on the machine. The official website of Graphviz contains the download and installation instructions (http://www.graphviz.org). On Debian-based operating systems, Graphviz can be installed using apt-get as follows:

$ sudo apt-get install graphviz-dev graphviz

Next, we need to install the Graphviz Haskell bindings from Cabal as follows:

$ cabal install graphviz

How to do it…

  1. Import the relevant libraries as follows:
    import Data.Text.Lazy ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.