igraph 0.6 issues: Changed numbering of Vertices

[This article was first published on 0xCAFEBABE, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 their blog: 0xCAFEBABE.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)