Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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

share|improve this question
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

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer

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
G<-read.graph("unipartite_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)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.