lar*_*els 13 statistics modularity r graph cluster-analysis
我有兴趣在大图上运行Newman的模块化聚类算法.如果你能指出我实现它的库(或R包等),我将非常感激.
最好〜拉拉
小智 8
使用R的igraph包:http: //igraph.sourceforge.net/doc/R/fastgreedy.community.html这实现了使用newman-girvan模块化最大化方法进行社区查找的快速算法.
你的代码将如下所示:
library(igraph)
# read graph from csv file
G<-read.graph("edgelist.txt", format="ncol")
fgreedy<-fastgreedy.community(G,merges=TRUE, modularity=TRUE)
memberships <-community.to.membership(G, fgreedy$merges, steps=which.max(fgreedy$modularity)-1)
print(paste('Number of detected communities=',length(memberships$csize)))
# Community sizes:
print(memberships$csize)
# modularity:
max(fgreedy$modularity)
Run Code Online (Sandbox Code Playgroud)