我想计算图的平均聚类系数(来自igraph
包)。但是,我不确定应该遵循哪种方法。
library(igraph)
graph <- erdos.renyi.game(10000, 10000, type = "gnm")
# Global clustering coefficient
transitivity(graph)
# Average clustering coefficient
transitivity(graph, type = "average")
# The same as above
mean(transitivity(graph, type = "local"), na.rm = TRUE)
如果您能提供一些指导,我将不胜感激。
最佳答案
使用transitivity(graph)
计算全局聚类系数(transitivity):
This is simply the ratio of the triangles and the connected triples in the graph. For directed graph the direction of the edges is ignored.
同时,transitivity(graph, type = "average")
是 transitivity(graph, type = "local")
的平均值,首先计算局部聚类系数并然后对它们进行平均:
The local transitivity of an undirected graph, this is calculated for each vertex given in the vids argument. The local transitivity of a vertex is the ratio of the triangles connected to the vertex and the triples centered on the vertex. For directed graph the direction of the edges is ignored.
参见,例如,?传递性
和Clustering coefficient .
因此,首先这两种措施都是有效的,选择应该取决于您的目的。它们之间的区别非常明显(请参阅维基百科页面):
It is worth noting that this metric places more weight on the low degree nodes, while the transitivity ratio places more weight on the high degree nodes. In fact, a weighted average where each local clustering score is weighted by k_i(k_i-1) is identical to the global clustering coefficient
其中 k_i 是顶点 i 邻居的数量。因此,也许同时使用它们也是相当公平的。
关于r - 网络的平均聚类系数(igraph),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48853610/