我在这个视频中看到,使用以下算法计算星图中心节点的聚类系数是 theta(n^2),对于 clique,它是 theta(n^3)。那是对的吗?
def clustering_coefficient(G,v):
neighbors = G[v].keys()
if len(neighbors) == 1: return 0.0
links = 0.0
for w in neighbors:
for u in neighbors:
if u in G[w]: links += 0.5
return 2.0*links/(len(neighbors)*(len(neighbors)-1))