igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Modularity in weighted networks


From: Steward, Lucy
Subject: [igraph] Modularity in weighted networks
Date: Wed, 27 Nov 2013 15:49:55 +0000

Hello,

I am having an issue with calculating modularities of weighted networks.

I have a weighted matrix which I am trying to calculate both the optimal modularity and its associated group memberships, and also the modularity of a pre-determined split of the same network. To calculate the optimal, I have been using the edge.betweenness.community function as follows:

dat=read.csv(file.choose("complete_frequency_weighted.csv"),header=TRUE,row.names=1,check.names=FALSE) 
m=as.matrix(dat) 
complete.g=graph.adjacency(m,mode="undirected",weighted=T) 

optimal<-edge.betweenness.community(complete.g, E(complete.g)$weight)
optimal

Graph community structure calculated with the edge betweenness algorithm
Number of communities (best split): 5 
Modularity (best split): 0.422237 
Membership vector:
008p 009p 010p 010y 011y 012b 013p 014p 015p 016p 018p 020p 020y 024y 031y 032y 033p 034p 035p 035r 037w 
   1    2    2    1    3    3    2    2    2    1    3    3    2    2    4    4    5    5    1    3    3 
038p 038r 040r 043p 043w 044p 045p 046p 047p 048p 049p 049w 049y 050g 050y 051p 052w 054w 055b 056b 058y 
   1    2    2    1    1    1    2    1    1    3    3    4    5    5    5    2    3    3    3    3    1 
061y 062p 063p 064p 067p 067y 070y 082w 103w 
   1    1    1    4    2    5    3    5    4 

And to calculate the pre-determined split modularity, I have been using the simple modularity function:

spa.com<-read.csv("spatial_mem.csv",header=T,row.names=1)
spatial.complete<-unlist(spa.com)
names(spatial.complete)<-row.names(spa.com)
spatial<-modularity(complete.g, membership=spatial.complete, weights = E(complete.g)$weight)
spatial

[1] 0.7198975

As you can see, the modularity for the predetermined split of the network is considerably better than that of the optimal modularity. How can this be the case, when surely the first method should be able to detect this configuration and report if it is indeed more optimal? I have attached my data if it is helpful.

Many thanks 
Lucy 


Attachment: complete_frequency_weighted.csv
Description: complete_frequency_weighted.csv

Attachment: spatial_mem.csv
Description: spatial_mem.csv


Lucy Steward
PhD Researcher
Environment and Sustainability Institute
University of Exeter
Penryn Campus
Penryn
Cornwall
TR10 9EZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]