读取R中的数据集时出错

时间:2013-12-22 14:12:51

标签: r igraph

我在阅读数据集时遇到问题

我的代码:

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 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

1 个答案:

答案 0 :(得分:7)

问题似乎是名称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)