Modularity calculation for weighted graphs in igraph
I used the fastgreedy algorithm in igraph for my community detection in a weighted, undirected graph. Afterwards I wanted to have a look at the modularity and I got different values for different methods and I am wondering why. I included a short example, which demonstrates my problem: library(igraph) d<-matrix(c(1, 0.2, 0.3, 0.9, 0.9, 0.2, 1, 0.6, 0.4, 0.5, 0.3, 0.6, 1, 0.1, 0.8, 0.9, 0.4, 0.1, 1, 0.5, 0.9, 0.5, 0.8, 0.5, 1), byrow=T, nrow=5) g<-graph.adjacency(d, weighted=T, mode="lower",diag=FALSE, add.colnames=NA) fc<-fastgreedy.community(g) fc$modularity[3] #[1] -0.05011095 modularity(g