为什么我从图中得到错误的邻居

问题描述

我试图从图中找到一个节点的共同邻居。但是,我收到了 the wrong neighbornode 8。从数据集中,我们可以说 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

图表:

enter image description here

你能告诉我为什么我找错了邻居吗?

可重现的数据:

structure(list(To = c(1L,1L,2L,3L,4L,5L,8L,8L),From = c(7L,7L,6L,6L)),class = "data.frame",row.names = c(NA,-11L))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)