igraph 0.6 issues: Changed numbering of Vertices

September 10, 2012
By

(This article was first published on 0xCAFEBABE, and kindly contributed to R-bloggers)

I have tried one of my previous scripts with an updated igraph version and I got an interesting (pretty much unexpected) error:

At type_indexededgelist.c:269 : invalid (odd) length of edges vector, Invalid edge vector

The problem is that it was a well-tested set of scripts (I am using the testthat package for a while) that was working perfectly before so I was a bit confused. The error message indicated that the issue was related to the igraph package. It took me a while but I found an interesting entry in the release notes of igraph v0.6:

Numbering from 1 in R

The biggest change in the R interface is that starting from this version vertices and edges are numbered from one. This change might be painful for many people, because it makes already existing code incompatible with igraph 0.6. To make the switch easier, there is now an igraph0 package on CRAN; igraph0 uses 0-based vertex and edge ids, and it can be used to run old code. Note, however, that igraph0 will not be developed in the future. Please use the igraph package for current and future work.

(Also note that in Python and C vertices and edges are still numbered from zero, as these languages traditionally use zero-based indexing.)


Cool :-) After my first frustation I can understand the reasons for such a change. Sometimes things like this are necessary in a project's life. It takes a while to adapt, but a few initial wrong decisions cannot be fixed easily. If they cause more trouble than how useful they are, time has come to eliminate them.


So the solution is to stick to the igraph0 package, or try to update the scripts to index from 1. Since my project is only required for my research I have chosen the second approach. For the time-critical tasks the answer would have been definitely the igraph0 package.

To leave a comment for the author, please follow the link and comment on his blog: 0xCAFEBABE.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.