【问题标题】:Graph Giant Connected Component图巨连通分量
【发布时间】:2016-11-20 15:43:15
【问题描述】:

我有一个格式为

的矩阵
a b 8.0
a d 0.1
......

第 1 列是节点 A,第 2 列是节点 B,第 3 列是相关系数 我必须制作一个找到阈值的程序,因此连接的网络有一个巨大的连接组件,由总网络节点的 50-60% 组成。 我写了一个程序,它使用二进制搜索来搜索阈值,例如

if Giant Connected Component > 60% new threshold=oldthreshold + oldthreshold/2
if Giant Connected Component < 50% new threshold=oldthreshold - oldthreshold/2

问题是算法也在搜索阈值 > 1 和/或

【问题讨论】:

  • 您可以在表格中找到最小值和最大值,并将其用作二分搜索的起始范围。
  • 阈值必须为 1>rc>0
  • 啊,我明白了。您的问题是您没有正确实现二进制搜索。稍后我会更详细地回答。

标签: python networking graph connected-components


【解决方案1】:

你描述的算法不是二分查找。

要正确实现二分搜索,请跟踪两个值,min_thresholdmax_threshold。最初将这些设置为最小和最大可能的阈值。然后在每一步:

threshold = (min_threshold + max_threshold)/2
if GCC(threshold) > 60%:  # threshold is too low, update minimum
    min_threshold = threshold
else if GCC(threshold) < 50%:  # threshold is too high, update maximum
    max_threshold = threshold

【讨论】:

  • thnx 我现在就试试,几个小时后写下它的工作原理。它是一个 45Gb .dat 文件
  • if GCC(threshold) &gt; 60%: 不是有效的 python 代码顺便说一句。
  • @Jean-FrançoisFabre 是的,这是类似于 OP 在他的问题中使用的伪代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多