【问题标题】:Detecting community with python and networkx使用 python 和 networkx 检测社区
【发布时间】:2015-05-16 08:43:12
【问题描述】:

我正在研究网络中的检测社区。​​p>

我正在使用networkx和Python,我需要实现这个算法:http://arxiv.org/pdf/0803.0476.pdf

这就是我尝试解决的方法: 首先,我制作列表列表,其中包含与图中节点一样多的列表(社区),以便我可以按索引找到社区。然后对于每个节点,我找到它们的邻居并计算模块化增益,如下所示:

q1 = (sum_in+ki_in)/float(2*m) - pow(sum_tot+ki,2)/float(pow(2*m,2))
q2 = sum_in/float(2*m) - pow(sum_tot, 2)/float(pow(2*m,2)) -pow(ki,2)/float(pow(2*m,2))
q =  q1 - q2

在哪里

for x in temp: # list of neighbors of node i
    sum_in += G.degree(x, weight='weight')
    sum_tot += G.in_degree(x, weight='weight')
    ki_in += weights[i, x]
    ki = G.in_degree(i, weight='weight')

然后我找到最大 q 并将节点 I 移动到新社区。 但这不起作用,似乎我在公式中犯了错误,因为大量节点算法找不到社区。​​p>

有谁知道如何解决这个问题?

【问题讨论】:

    标签: python networkx modularity


    【解决方案1】:

    无权访问您提供的链接。 (本来是想发表评论的,但现在无法添加评论)

    【讨论】:

    • 嗯,有一篇文章叫做:大型网络中社区的快速展开
    【解决方案2】:

    你不需要解决这个问题,该算法已经在 python 中的community 包中实现。您可以在the source code 中查看他们是如何做到的。

    如果你必须自己实现一个任务,尽量避免发生堆栈溢出的坏习惯,你自己去学习更多;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-12
      • 1970-01-01
      • 1970-01-01
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多