Aba*_*ano 2 r cluster-analysis igraph
我只是用C++编写程序,以点格式计算无向图的聚类系数[ CC ](局部和全局).我的问题是我的程序的结果与R的输出(与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/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)
Run Code Online (Sandbox Code Playgroud)
其中""是图的节点,(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
Run Code Online (Sandbox Code Playgroud)
每行中的第一个数字是节点,第二个是本地CC,第三个是我的注释,当它与我的输出不匹配时(指定链接数量(n)我需要添加/删除以匹配R的输出).
我遇到的第二个问题是来自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;
}
Run Code Online (Sandbox Code Playgroud)
我用R计算CC的方法是将图形(或生成一个新图形,因为它不能读取点文件)加载到var"f"中,例如,执行全局CC和传递性的传递性(f)( f,"本地")为本地人.
非常感谢阅读,并抱歉我的英语不好.
igraph的作者之一.
我刚刚将您的图形加载到igraph(Python界面)中,其结果与您的最后一位数相匹配.您使用的是哪个版本的igraph?
至于"全局"聚类系数,请注意至少有两个相互矛盾的定义:
计算整个网络中的三角形数量,并将其除以可能的三角形数量.这是"真实的"全局聚类系数,igraph默认计算.
计算每个节点的局部聚类系数并取平均值.这是"平均局部"聚类系数,您正在计算它.
| 归档时间: |
|
| 查看次数: |
3080 次 |
| 最近记录: |