igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] adding vertices and edges to an empty graph from R


From: Rajarshi Guha
Subject: [igraph] adding vertices and edges to an empty graph from R
Date: Thu, 11 Dec 2008 17:34:07 -0500

Hi, I'm using igraph from R and am a little confused on how I can manually generate graphs by adding nodes and edges.

I have the following code:

g <- graph.empty(0, directed=FALSE)

ea <- 1:10
eb <- 11:20

g <- add.vertices(g, 10)
g <- add.vertices(g, 10)
g <- add.vertices(g, 1)

g <- add.edges(g, as.numeric(t(cbind(ea, 21))))

So, I expect that I should add the edges

1 21
2 21
3 21
...
10 21

Instead I get the error:

Error in add.edges(g, as.numeric(t(cbind(ea, 21)))) :
  At type_indexededgelist.c:244 : cannot add edges, Invalid vertex id

More generally, is there a way to refer to nodes by some label? In the above case how would I determine the 'vertex id' - wouldn't they just be the values 1, 2, 3, ... 21?

Any pointers would be appreciated


-------------------------------------------------------------------
Rajarshi Guha  <address@hidden>
GPG Fingerprint: D070 5427 CC5B 7938 929C  DD13 66A1 922C 51E7 9E84
-------------------------------------------------------------------
A meeting is an event at which the minutes are
kept and the hours are lost.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]