【问题标题】:How to find overlapping community structures using R? [closed]如何使用 R 找到重叠的社区结构? [关闭]
【发布时间】:2013-01-29 17:25:09
【问题描述】:

我有两个问题:

1- 我想知道是否可以使用 igraph 在 R 中发现重叠的社区结构?

2- 我发现 LinkComm 包可以做类似的事情(找到重叠的社区结构)但它不能接受 igraph 网络,是否可以将 LinkComm 函数应用于 igraph 图?

提前致谢,

【问题讨论】:

  • 你是什么意思,但它不能接受 igraph 网络?您有 igraph 并且想在其上应用 LinkComm 功能吗?从您的问题中不清楚您有什么输入?你想得到什么?你试过什么?
  • yest Agstudy,没错。它不能接受 igraph 图。
  • 对吗?什么?我问你一些问题来澄清你的第一个问题......显然你不明白我的意思。这个问题需要澄清一下,这就是为什么您在 4 小时后没有答案。
  • 哥们,你说得对,“我有一个 igraph,我想在上面应用 LinkComm 功能”。
  • 我还没有投票!至少对我来说,即使您的问题也不清楚。尝试生成您拥有的代码以及您想要应用 LinkComm 的哪个功能。我真的很想帮助你“伙计”。也就是说,我认为您可以将 igraph 边缘保存为 data.frame,使用此 data.frame 创建 lincomm 对象......但是没有代码,这一切都只是猜测......

标签: r networkx igraph


【解决方案1】:

这是使用 linkcomm 包和 igraph 对象的一个​​(相当肮脏的)技巧。困难在于linkcomm 使用igraph0 包,它直接使用igraph 对象的字段,这建议。他们的方法适用于igraph0 包,但不适用于igraph 包,因为igraph 为igraph 定义了[[ 索引运算符。

无论如何,下面的内容只是覆盖了linkcomm 包中的一个函数。它适用于包版本 1.0-6 (2011-05-27),并且几乎肯定不会适用于任何其他版本。正确的解决方法是更新其作者的linkcomm 包。

library(linkcomm)

# This will result a long warning about masked objects, because igraph 
# defines almost all names igraph0 defines, and linkcomm loads igraph0.
# But we are fine if we load igraph after linkcomm, because by default
# the igraph functions will be used
library(igraph)

# Modify the function from the linkcomm package, we create a new 
# function called 'lc'
lc <- as.list(getLinkCommunities)
lc[[11]][[10]][[3]] <- call("get.edgelist", quote(x), names=FALSE)
lc <- as.function(lc)

# Get some test data
karate <- nexus.get("karate")

# Use the newly defined 'lc' function on the test data
karcomm <- lc(get.data.frame(karate), check.duplicates=FALSE)

【讨论】:

  • 感谢 Gabor,请在您的 igraph 包中包含这个重叠社区 :),顺便说一句,现在出现了一些新的快速 K-Clique 算法,值得将它们包含在您很棒的 igraph 包中。
  • 您可以在这里提出功能请求:bugs.launchpad.net/igraph
  • 您能否解释一下运行linkcomm 演示时community membership 的情节是什么意思?
  • @GaborCsardi 运行您的代码时,我收到此错误&gt; lc[[11]][[10]][[3]] &lt;- call("get.edgelist", quote(x), names=FALSE) Error in *tmp*[[10]] : subscript out of bounds
  • @MonaJalal: linkcomm 已更新,因此您不再需要此解决方法。只需在图表上调用getLinkCommunities
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-04
  • 2010-09-13
  • 1970-01-01
  • 2016-04-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多