【发布时间】:2021-03-20 19:18:10
【问题描述】:
我试图从图中找到一个节点的公共邻居。但是,对于node 8,我得到了the wrong neighbor。从数据集中,我们可以说node 8 的共同邻居是node 5 and 6,但我得到的是node 4 and 5!
代码:
graph <- graph_from_data_frame(df_graph, directed = FALSE)
plot(graph, vertex.label = V(graph)$name)
neighbors(graph, 8, mode="all")
输出:
+ 3/8 vertices, named, from a32ba25:
[1] 4 5 8
图表:
你能告诉我为什么我找错了邻居吗?
可重现的数据:
structure(list(To = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 4L, 5L, 8L,
8L), From = c(7L, 3L, 4L, 7L, 4L, 5L, 4L, 6L, 6L, 5L, 6L)), class = "data.frame", row.names = c(NA,
-11L))
【问题讨论】:
标签: r graph igraph neighbours