I strongly suspect that the tutorial you are trying to follow was developed for igraph version 0.5.4 or earlier. At that time, vertices and edges in an igraph object were indexed from zero instead of one, and the tutorial seems to account for this, judging from the following comment in the tutorial:
# IMPORTANT NOTE: Unlike in most languages, R objects are numbered
# from 1 instead of 0, so if you want the first element in a
# vector, you would reference it by vector_name[1]. HOWEVER,
# igraph objects are numbered starting from 0. This can lead to
# lots of confusion, since it's not always obvious at first which
# objects are native to R and which belong to igraph.
Since igraph 0.6, this is not true anymore; vertices and edges in the R interface of igraph are indexed from 1 just like every other well-behaved R object. You have two options here (besides asking the authors of the tutorial to update it for igraph 0.6):
You can modify the commands in the tutorial to make sure that every vertex and edge index is 1-based; i.e., if they subtracted 1 from the indices somewhere for some reason, just omit the subtraction, and similarly, if they added 1 to the indices somewhere, omit the addition. This would also be a good way to check whether you really understand what you are doing :)
Use the
igraph0
package instead ofigraph
. Theigraph0
package is identical toigraph
but uses zero-based indexing to ensure that old igraph codes are still functional during the transition period. However, you should keep on usingigraph
for new analysis projects.