为什么聚类系数不同于我的程序和igraph R';谁的图书馆? 我只是在C++中编写一个程序,计算 dot>格式中的无向图的聚类系数[ cc>](局部和全局)。我的问题是,我的程序的结果与R(使用igraph库)的输出不匹配:

为什么聚类系数不同于我的程序和igraph R';谁的图书馆? 我只是在C++中编写一个程序,计算 dot>格式中的无向图的聚类系数[ cc>](局部和全局)。我的问题是,我的程序的结果与R(使用igraph库)的输出不匹配:,r,cluster-analysis,igraph,R,Cluster Analysis,Igraph,我的节目: The cluster coefficient of "0" is: 0.257 (88/342) The cluster coefficient of "1" is: 0.444 (40/90) The cluster coefficient of "10" is: 1.000 (2/2) The cluster coefficient of "2" is: 0.418 (46/110) The cluster coefficient of "11" is: 1.000 (2

我的节目:

The cluster coefficient of "0"  is: 0.257 (88/342)
The cluster coefficient of "1"  is: 0.444 (40/90)
The cluster coefficient of "10" is: 1.000 (2/2)
The cluster coefficient of "2"  is: 0.418 (46/110)
The cluster coefficient of "11" is: 1.000 (2/2)
The cluster coefficient of "12" is: 0.667 (8/12)
The cluster coefficient of "3"  is: 0.346 (54/156)
The cluster coefficient of "5"  is: 0.571 (24/42)
The cluster coefficient of "13" is: 1.000 (12/12)
The cluster coefficient of "4"  is: 0.607 (34/56)
The cluster coefficient of "7"  is: 0.679 (38/56)
The cluster coefficient of "14" is: 1.000 (6/6)
The cluster coefficient of "15" is: 0.833 (10/12)
The cluster coefficient of "16" is: 1.000 (6/6)
The cluster coefficient of "17" is: 0.733 (22/30)
The cluster coefficient of "9"  is: 0.833 (10/12)
The cluster coefficient of "18" is: 0.714 (30/42)
The cluster coefficient of "19" is: 1.000 (6/6)
The cluster coefficient of "6"  is: 1.000 (2/2)
The cluster coefficient of "8"  is: 0.733 (22/30)
其中,“”是图的节点,(n/m)分别是“其邻域内顶点之间的链接”(n)和“它们之间可能存在的链接数”(m)() 和R的输出:

0  0.2631579        x (+2 links)
1  0.4666667        x (+2 links)
2  0.4181818
3  0.3461538
4  0.6071429
5  0.6190476        x (+2 links)
6  1.0000000
7  0.6785714
8  0.6666667        x (-2 links)
9  0.8000000
10 1.0000000
11 1.0000000
12 0.6666667
13 1.0000000
14 1.0000000
15 0.8333333
16 1.0000000
17 0.7333333
18 0.7142857
19 1.0000000
其中每行中的第一个数字是节点,第二个是本地的CC,第三个是与我的输出不匹配时的注释(指定需要添加/删除以匹配R的输出的链接数(n))

我的第二个问题是来自R的全局CC与我的定义或维基百科的不匹配(除非我误解了公式)。该图的R输出为0.458891,我的输出为0.742


所以我手工做了:我计算了8的CC,并匹配了我程序的输出。所以我的问题是“igraph库是否可能有bug?”如果答案是“否”:“我缺少了什么?”

图形文件如下所示:

graph {
  1 -- 0;
  10 -- 0;
  10 -- 2;
  11 -- 0;
  11 -- 2;
  12 -- 0;
  12 -- 1;
  12 -- 3;
  12 -- 5;
  13 -- 0;
  13 -- 3;
  13 -- 4;
  13 -- 7;
  14 -- 0;
  14 -- 1;
  14 -- 4;
  15 -- 0;
  15 -- 2;
  15 -- 3;
  16 -- 0;
  16 -- 15;
  16 -- 3;
  17 -- 0;
  17 -- 1;
  17 -- 2;
  17 -- 5;
  17 -- 7;
  17 -- 9;
  18 -- 0;
  18 -- 1;
  18 -- 2;
  18 -- 3;
  18 -- 4;
  18 -- 7;
  19 -- 0;
  19 -- 18;
  19 -- 3;
  2 -- 0;
  2 -- 1;
  3 -- 0;
  3 -- 2;
  4 -- 0;
  4 -- 1;
  4 -- 3;
  5 -- 0;
  5 -- 2;
  5 -- 3;
  6 -- 0;
  6 -- 3;
  7 -- 0;
  7 -- 1;
  7 -- 2;
  7 -- 3;
  7 -- 4;
  8 -- 0;
  8 -- 1;
  8 -- 2;
  8 -- 3;
  8 -- 4;
  8 -- 5;
  9 -- 0;
  9 -- 1;
  9 -- 5;
}
例如,我使用R计算CC的方法是将图形加载(或生成一个新图形,因为它无法读取点文件)到变量“f”中,并对全局CC执行传递性(f),对局部执行传递性(f,“local”)


非常感谢您的阅读,并为我糟糕的英语感到抱歉。

这里是igraph的作者之一

我刚刚将您的图形加载到igraph(Python接口)中,其结果与您的结果匹配到最后一位。您使用的是哪个版本的igraph

至于“全局”聚类系数,请注意至少有两个相互冲突的定义:

  • 计算整个网络中的三角形数,并将其除以可能的三角形数。这是“真实”全局聚类系数,默认情况下igraph会计算该系数

  • 计算每个节点的局部聚类系数并取平均值。这是“平均局部”聚类系数,您正在计算它

  • 非常感谢你的回答(以及速度)。如果你得到同样的结果,可能我使用的是旧版本,所以我会尽快检查。对于全球CC,我误解了这两种类型,因此感谢您澄清:)