Jo_bast
Jo_bast

Reputation: 448

Error reading dataset in R

I have problem in reading a dataset

My code :

require(igraph)
g <- graph(c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4, 
               4, 5, 5, 3, 4, 6, 6, 7, 7, 8, 
               8, 6, 9, 10, 10, 11, 11, 9))

Error :

Error in graph(c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4, 4, 5, 5, 3, 4, 6, 6, 7,  : 
  At structure_generators.c:84 : Invalid (negative) vertex id, Invalid vertex id

Upvotes: 6

Views: 2436

Answers (1)

user1317221_G
user1317221_G

Reputation: 15441

The problem seems to be vertex of name 0

yourgraph <- c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4, 
               4, 5, 5, 3, 4, 6, 6, 7, 7, 8, 
               8, 6, 9, 10, 10, 11, 11, 9)

g <- graph(yourgraph + 1)

Upvotes: 9

Related Questions