Visualizing a graph using Graphviz
One can easily draw an image that represents a graph using the graphviz
library. In the world of data analysis, visually interpreting an image can reveal peculiarities about the data that the human eye can easily pick up. This recipe will let us construct a diagram out of the data we are dealing with. More visualization techniques are explained in Chapter 11, Visualizing Data.
Getting ready
Install the graphviz
library from http://www.graphviz.org/Download.php as the Haskell package requires it.
Next, install the package from cabal by running the following command:
$ cabal install graphviz
How to do it...
In a new file, insert the following code. We will name our file Main.hs
:
Import the package:
import Data.GraphViz
Create the graph from nodes and edges:
graph :: DotGraph Int graph = graphElemsToDot graphParams nodes edges
Use the default parameters for creating the graph. This function can be modified to modify the graph's visual parameters:
graphParams :: GraphvizParams...