Calculating the Modularity of Partitioning a Network
From CLAIRlib
Modularity is a benefit measure used to quantify the quality of partitioning a network into communities. Good divisions, which have high values of modularity, are those in which there are dense internal connections between the nodes within community but only sparse connections between different communities.
In this tutorial you'll use the modularity.pl utility to calculate the modularity value for the division of the Karate Club into communities as described in the Finding Communities in Networks tutorial. In that tutorial, we got the optimal node labeling written to the Karate.bestComm file.
To use the modularity.pl utility, you'll need to have the Karate Club network in edgelist format. To convert the network from GML format to edgelist format, run
convert_network.pl --input karate.gml --input-format gml --output karate.el --output-format edgelist
Now, to calculate the modularity of the division of the Karate Club network into communities as specified in Karate.bestComm, run
modularity.pl --graph karate.el --partitions Karate.bestComm
The result will be something like,
0.370726495726496

