igraph is my preferred library for graph manipulation. The core library is written in C and is easy to extend, there are bindings to Python and R, and Gabor and Tamas are really nice and helpful guys. That said, I’ve always noticed that one stumbling block for users has been building the Python bindings with plotting support. Since it’s something I do often, I thought I’d put up a post on installing the dependencies, compiling and installing the igraph trunk, and testing that everything works.
The first step is getting the necessary libraries. These libraries provide a number of numerical libraries, Python headers, and configuration tools to make software development easier.
$ sudo apt-get install build-essential bzr autoconf automake libtool flex bison python-dev python-cairo libgmp3-dev libglpk-dev
The next step is to download the source and the compile the core C library. These lines download the current source from Launchpad, configure the library for installation in /usr, and then compile and install.
$ bzr branch lp:igraph $ cd igraph $ ./configure --prefix=/usr $ make && sudo make install
Now we’re ready to compile and install the Python bindings. These lines also ensure that Python knows where to load the core C library shared extension.
$ cd interfaces/python $ sudo python setup.py install $ sudo updatedb && sudo locate libigraph.so.0
And finally, we’re ready to test that everything works. This simple example creates a dyad and plots it.
$ python >>> import igraph >>> g = igraph.Graph([(0,1)] >>> p = igraph.drawing.plot(g)
If you saw an image pop up after entering the last line, you’ve succeeded! Happy igraph-ing!
Leave A Comment