【问题标题】:Community detection in extracted ego network using igraph使用 igraph 在提取的自我网络中进行社区检测
【发布时间】:2023-04-05 16:46:01
【问题描述】:

我使用安装在 R 软件中的 igraph 库,我想从网络“悲惨世界”中提取一个自我网络。

这是我的代码:

library("igraph")
lesmis<-read.graph("lesmis.gml", format="gml")
gavroche <- graph.neighborhood(lesmis, order = 2, nodes = which(V(lesmis)$label == "Gavroche"))
wc<-infomap.community(gavroche)
plot(wc, gavroche)

我得到这个错误:

infomap.community(gavroche) 中的错误:不是图形对象

这里是 gml 文件的链接: http://www-personal.umich.edu/~mejn/netdata/lesmis.zip

【问题讨论】:

  • graph.neighborhood 总是返回一个图表列表,因此您需要提取第一个(也是唯一一个)元素。
  • 谢谢,事实上,我想将 Gavroche 的以自我为中心的网络提取为图形,并将检测到的社区显示在输出图形中。

标签: r igraph


【解决方案1】:

我刚刚在寻找其他主题时遇到了这个问题。 我发现graph.neighborhood 创建的对象不是图形本身,而是一个列表,它又包含您期望的图形。然后你可以替换:

wc <- infomap.community(gavroche[[1]])
plot(wc, gavroche[[1]])

而且它必须有效。

【讨论】:

    猜你喜欢
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 1970-01-01
    • 2014-06-12
    • 1970-01-01
    • 2014-10-04
    相关资源
    最近更新 更多