轉自http://blog.csdn.net/pennyliang/article/details/6838956
Clustering coefficient的定義有兩種;全局的和局部的。
全局的算法基於triplet。triplet分為開放的triplet(open triplet)和封閉的triplet(closed triplet)兩種(A triplet is three nodes that are connected by either two (open triplet) or three (closed triplet) undirected ties)。
可以用下面結構定義一個triplet
struct triplet { int key; set<int> pair;};
例如下圖{1,(2,3)}構成的triplet是封閉的,{3,(4,5)}構成的triplet是開放的
全局的Clustering coefficient比較簡單,公式如下:Clustering coefficient(global) = number of closed triplet / number of triplet(closed+open)
以上圖為例:
closed triplet ={1,(2,3)},{2,(1,3)},{3,(1,2)}
all triplet = {1,(2,3)},{2,(1,3)},{3,(1,2)},{3,(2,4)},{3,(4,5)},{3,(1,5)},{3,(2,5)},{3,(1,4)}
number of closed triplet = 3
number of triplet = 8
number of triplet / number of triplet = 3/8
局部的Clustering coefficient的計算方法:局部計算是面向節點的,對於節點vi,找出其直接鄰居節點集合Ni,計算Ni構成的網絡中的邊數K,除以Ni集合可能的邊數|Ni|*(|Ni|-1)/2例如:1節點的鄰居節點(2,3),他們之間構成的邊有1條,可能構成的邊1條,因此1/1=12節點的鄰居節點(1,3),他們之間構成的邊有1條,可能構成的邊1條,因此1/1=13節點的鄰居節點(1,2,4,5),他們之間構成的邊有1條,可能構成的邊(4*3)/2條,因此1/6=1/6
4節點的鄰居節點(3),他們之間構成的邊有0條,可能構成的邊0條,因此0
5節點的鄰居節點(3),他們之間構成的邊有0條,可能構成的邊0條,因此0
則,5個節點平均local Clustering coefficient = (1+1+1/6)/5=13/30
參考
1)http://en.wikipedia.org/wiki/Clustering_coefficient
2)<<Complex Network>> 3.2 properties of real-world networks p25