【发布时间】:2018-08-06 04:44:22
【问题描述】:
我在 iGraph R 中使用degree 函数,结果如下
G<-read.graph("sample.graphml", format="graphml")
degree(G)
> degree(G)
[1] 2 18 6 15 64 64 11 36 53 63 54 54 47 72 86 46 55 17
[19] 9 14 13 6 14 17 14 8 16 8 20 13 14 17 13 17 13 2
这些值是为每个节点计算的度数,但它不显示相应的节点id。我查看了函数的描述,但仍然没有找到输出节点ID的参数。
dput(G)
structure(list(6, FALSE, c(1, 3, 5, 3, 4, 5, 5), c(0, 0, 1, 1,
2, 2, 4), c(0, 1, 3, 4, 2, 5, 6), c(0, 1, 3, 2, 4, 5, 6), c(0,
0, 1, 1, 3, 4, 7), c(0, 2, 4, 6, 6, 7, 7), list(c(1, 0, 1), structure(list(), .Names = character(0)),
structure(list(id = c("6", "4", "2", "5", "1", "3")), .Names = "id"),
list()), <environment>), class = "igraph")
> degree(G)
[1] 2 3 2 2 2 3
【问题讨论】:
-
“node id”是指“name”吗?因为否则,结果是有序的,即id为1的节点度数为2,id为2的节点度数为18,以此类推。
-
我正在尝试打印名称,因为只有这样,我才能看到哪个节点的度数最高