Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Import the package:

    import Data.GraphViz
  2. Create the graph from nodes and edges:

    graph :: DotGraph Int
    
    graph = graphElemsToDot graphParams nodes edges
  3. Use the default parameters for creating the graph. This function can be modified to modify the graph's visual parameters:

    graphParams :: GraphvizParams...