# Newman's modularity clustering for graphs

I am interested in running Newman's modularity clustering algorithm on a large graph. If you can point me to a library (or R package, etc) that implements it I would be most grateful.

best ~lara

-
 sorry for the graphical-techniques tag, but my brand new account doesn't let me tag with 'graph' and 'partitioning' as I intended to. – laramichaels Aug 19 '10 at 16:10 @csgillespie: thank you for retagging it :) – laramichaels Aug 19 '10 at 16:55

The igraph library implements some algorithms for community structure based on Newman's optimization of modularity. You can consult the reference manual for details and citations.

-

Use the igraph package for R: http://igraph.sourceforge.net/doc/R/fastgreedy.community.html this implements a fast algorithm for community finding using the newman-girvan modularity maximization method.

your code will look like this:

library(igraph)
# read graph from csv file
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)