Installing Graphviz in Drupal
I have now install Graphviz on three different Drupal servers and I figure it is time for me to relate my experiences.
First, let me provide a little background. “Graphviz is open source graph visualization software.” Essentially, this allows you to represent a graph in a fairly simply format which then gets displayed as an image.
For example, I might put in:
DIGRAPH {
a -> b;
b -> c;
c -> a;
}
This would create an image with an ‘a’ in a circle, with an arrow leading to a ‘b’ in a circle, which would point to a ‘c’ in a circle, and finally an error from the circle with the ‘c’ in it back to the circle with an ‘a’ in it. Very nice. Very simple. Yes, you could use plenty of graphics programs to produce something like this, but when the graphs get a bit more complicated, it can be especially nice to have a program like Graphviz arrange all of the different pieces.
To get an idea of some of the things you can do with GraphViz, check out the images I produced with GraphViz on Flickr. I’ve created some fun images of social network graphs there.
Drupal is the Content Management System that I like to use for most of my sites. It makes it very easy to add content to a website. So, the combination of Drupal and Graphviz has some great potential.
The first site Drupal site that I installed Graphviz on was on an Ubuntu server on my internal network. Since it is Ubuntu, it is very easy to install packages. To install the graphviz package, I simply entered
sudo apt-get install graphviz
I then tested to make sure that graphviz was working by making a simple graphviz file and running ‘dot’ to convert it to an image.
The Drupal graphviz filter is dependent on the Pear package, Image_GraphViz. I didn’t have Pear installed, so I needed to do that as the next step.
sudo apt-get install php-pear
The best way to check that pear was installed properly was to use it to install Image_GraphViz. So, I executed
sudo pear install Image_GraphViz
At this point, I was ready to test it in Drupal. I downloaded the module, unzipped it and went to module administration to enable it. I then went to Input Formats to add the filter to various input formats. So far, I’ve only had it work nicely with the PHP Input Format.
My first installation was nearly a year ago, and it worked fairly nicely.
My second attempt was to install it on a shared hosting service. However, the commands that I used above weren’t available so, after a little hacking I gave up. I probably could install it in my own directory, change some paths, etc., but it just didn’t seem worth the effort.
My most recent attempt was for Toomre Capital Markets. The TCM site is running on a virtual private server running Ubuntu, so the procedure that I used for my first installation worked simply and easily for the TCM installation. Lars Toomre used GraphViz to create a great Visualization of the Madoff Feeder funds.
Included in the graph is the use of different colors as well as links from the graph into various articles that Lars has written about the Feeder Funds.
So, if you have your own server or a virtual private server, setting up GraphViz to run in Drupal can be fairly simple and straightforward. Building interesting graphs can be as well, and perhaps I’ll offer some of the hints of how to do this in a subsequent post.