我在一个大型网络中检测到了社区,在igraph中得到了一个低模块性。我怀疑结果。所以我再试一次,在igraph中,模块性要高得多。我不知道原因。在下面,我将编写一个示例网络和我使用的代码。
图:(ncol格式)图是无向的。第三栏是重量。)
1 2 123
1 3 32
2 3 523
3 6 3
6 5 11
6 8 234
5 8 324
3 9 234
9 11 32
9 12 5534
9 13 32
11 12 322
11 13 3
12 13 32R码:
library(igraph)
g=read.graph('graph.ncol',format='ncol',directed=F)
c=multilevel.community(g)
modularity(c)
[1] 0.2845496Python代码:
import igraph
g=igraph.Graph.Read_Ncol('graph.ncol',directed=False)
c=g.community_multilevel()
c.modularity
0.4974489795918367在我最初的网络中,使用R和Python的社区数量有很大不同。这不仅是一种多层次的方法。我也尝试过快速贪婪的方法。使用R和Python的结果也不同。
发布于 2014-10-27 13:04:48
在计算社区结构和模块化时,R接口自动使用来自weight属性的权重,而Python接口不使用。例如,在Python中:
>>> g=load("test.ncol", directed=False)
>>> g.multilevel_community().q
0.4974489795918367
>>> g.multilevel_community(weights=g.es["weight"]).q
0.2845496103894415https://stackoverflow.com/questions/26585739
复制相似问题