Discussion:
[igraph] add.edges error message
Alisa Coffin
2008-02-23 19:23:11 UTC
Permalink
Hello,

I am brand new to using igraph, and relatively new to R, so please bear with
me if my question is a simple one. I am building a graph using the example
given in the "Real world examples" of the igraph introductory material. I
have been successful so far in creating the graph, adding vertices, and
creating a matrix of edges. However, when it comes to adding the edges to
g2005 <- add.edges(g2005, t(edges2005))
Error in add.edges(g2005, t(edges2005)) :
At type_indexededgelist.c:240 : cannot add edges, Invalid vertex id

I'm not sure what this means. I have tried looking at the vertex list and
the edge list and can't seem to find a problem with either. Any ideas? Any
workarounds?

Thank you very much!
Alisa
--
Alisa Coffin, PhD. Candidate
Department of Geography
University of Florida
Gainesville, FL 32611
Gabor Csardi
2008-02-23 19:37:11 UTC
Permalink
Alisa, without looking at your data, i can only guess that
this is the infamous "0-based ids" trick. igraph vertices are
numbered from zero. If indeed this is the problem, then you can solve
it by subtracting one from the edges:

g2005 <- add.edges(g2005, t(edges2005)-1)

Btw. the error message means that in your edge matrix the ids are
not between 0 and number_of_vertices-1.

Gabor
Post by Alisa Coffin
Hello,
I am brand new to using igraph, and relatively new to R, so please bear with me
if my question is a simple one. I am building a graph using the example given
in the "Real world examples" of the igraph introductory material. I have been
successful so far in creating the graph, adding vertices, and creating a matrix
of edges. However, when it comes to adding the edges to the graph, I get an
g2005 <- add.edges(g2005, t(edges2005))
At type_indexededgelist.c:240 : cannot add edges, Invalid vertex id
I'm not sure what this means. I have tried looking at the vertex list and the
edge list and can't seem to find a problem with either. Any ideas? Any
workarounds?
Thank you very much!
Alisa
--
Alisa Coffin, PhD. Candidate
Department of Geography
University of Florida
Gainesville, FL 32611
_______________________________________________
igraph-help mailing list
http://lists.nongnu.org/mailman/listinfo/igraph-help
--
Csardi Gabor <***@rmki.kfki.hu> UNIL DGM
Alisa Coffin
2008-02-24 19:52:07 UTC
Permalink
Thank you for your help Gabor. This was, if fact the problem, but it stemmed
from an earlier issue of extracting the information from a GIS network
dataset. I used the OID instead of the EID, which I should have used. Then
subtracting one made it work out.

Alisa.
Post by Gabor Csardi
Alisa, without looking at your data, i can only guess that
this is the infamous "0-based ids" trick. igraph vertices are
numbered from zero. If indeed this is the problem, then you can solve
g2005 <- add.edges(g2005, t(edges2005)-1)
Btw. the error message means that in your edge matrix the ids are
not between 0 and number_of_vertices-1.
Gabor
Post by Alisa Coffin
Hello,
I am brand new to using igraph, and relatively new to R, so please bear
with me
Post by Alisa Coffin
if my question is a simple one. I am building a graph using the example
given
Post by Alisa Coffin
in the "Real world examples" of the igraph introductory material. I have
been
Post by Alisa Coffin
successful so far in creating the graph, adding vertices, and creating a
matrix
Post by Alisa Coffin
of edges. However, when it comes to adding the edges to the graph, I get
an
Post by Alisa Coffin
g2005 <- add.edges(g2005, t(edges2005))
At type_indexededgelist.c:240 : cannot add edges, Invalid vertex id
I'm not sure what this means. I have tried looking at the vertex list
and the
Post by Alisa Coffin
edge list and can't seem to find a problem with either. Any ideas? Any
workarounds?
Thank you very much!
Alisa
--
Alisa Coffin, PhD. Candidate
Department of Geography
University of Florida
Gainesville, FL 32611
_______________________________________________
igraph-help mailing list
http://lists.nongnu.org/mailman/listinfo/igraph-help
--
_______________________________________________
igraph-help mailing list
http://lists.nongnu.org/mailman/listinfo/igraph-help
--
Alisa Coffin, PhD. Candidate
Department of Geography
University of Florida
Gainesville, FL 32611
Continue reading on narkive:
Loading...