Modularity is a measure of the structure of networks or graphs which measures the strength of division of a network into modules (also called groups, clusters or communities). Networks with high modularity have dense connections between the nodes within modules but sparse connections between nodes in different modules. Modularity is often used in optimization methods for detecting community structure in networks. Biological networks, including animal brains, exhibit a high degree of modularity. However, modularity maximization is not statistically consistent, and finds communities in its own null model, i.e. fully random graphs, and therefore it cannot be used to find statistically significant community structures in empirical networks. Furthermore, it has been shown that modularity suffers a resolution limit and, therefore, it is unable to detect small communities.
Many scientifically important problems can be represented and empirically studied using networks. For example, biological and social patterns, the World Wide Web, metabolic networks, food webs, neural networks and pathological networks are real world problems that can be mathematically represented and topologically studied to reveal some unexpected structural features.[1] Most of these networks possess a certain community structure that has substantial importance in building an understanding regarding the dynamics of the network. For instance, a closely connected social community will imply a faster rate of transmission of information or rumor among them than a loosely connected community. Thus, if a network is represented by a number of individual nodes connected by links which signify a certain degree of interaction between the nodes, communities are defined as groups of densely interconnected nodes that are only sparsely connected with the rest of the network. Hence, it may be imperative to identify the communities in networks since the communities may have quite different properties such as node degree, clustering coefficient, betweenness, centrality,[2] etc., from that of the average network. Modularity is one such measure, which when maximized, leads to the appearance of communities in a given network.
Modularity is the fraction of the edges that fall within the given groups minus the expected fraction if edges were distributed at random. The value of the modularity for unweighted and undirected graphs lies in the range
[-1/2,1]
There are different methods for calculating modularity.[1] In the most common version of the concept, the randomization of the edges is done so as to preserve the degree of each vertex. Consider a graph with
n
m
s
v
sv=1
v
sv=-1
A
A{vw
v
w
Avw=1
Avw=Awv
Modularity
Q
The expected number of edges shall be computed using the concept of a configuration model.[4] The configuration model is a randomized realization of a particular network. Given a network with
n
v
kv
Now consider two nodes
v
w
kv
kw
Let us consider each of the
kv
v
(v,w) | |
I | |
i |
i=1,\ldots,kv
(v,w) | |
I | |
i |
=1
i
kw
w
(v,w) | |
I | |
i |
=0
i
v
2m-1
m
kw
w
(v,w) | |
p(I | |
i |
=1)=
(v,w) | |
E[I | |
i |
]=
kw | |
2m-1 |
Jvw
v
w
Jvw=
kv | |
\sum | |
i=1 |
(v,w) | |
I | |
i |
E[Jvw]=
kv | |
E\left[\sum | |
i=1 |
(v,w) | |
I | |
i |
\right]=
kv | |
\sum | |
i=1 |
(v,w) | |
E[I | |
i |
]=
kv | |
\sum | |
i=1 |
kw | |
2m-1 |
=
kvkw | |
2m-1 |
m
1
kvkw | |
2m |
Jvw
1
v
w
kvkw | |
2m |
Hence, the difference between the actual number of edges between node
v
w
Avw-
kvkw | |
2m |
Summing over all node pairs gives the equation for modularity,
Q
It is important to note that holds good for partitioning into two communities only. Hierarchical partitioning (i.e. partitioning into two communities, then the two sub-communities further partitioned into two smaller sub communities only to maximize Q) is a possible approach to identify multiple communities in a network. Additionally, (3) can be generalized for partitioning a network into c communities.[6]
where eij is the fraction of edges with one end vertices in community i and the other in community j:
eij=\sumvw
Avw | |
2m |
1 | |
v\inci |
1 | |
w\incj |
a | ||||
|
=\sumjeij
We consider an undirected network with 10 nodes and 12 edges and the following adjacency matrix.
Node ID | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | |
2 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
3 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
4 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | |
5 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | |
6 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | |
7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | |
8 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |
9 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | |
10 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
The communities in the graph are represented by the red, green and blue node clusters in Fig 1. The optimal community partitions are depicted in Fig 2.
An alternative formulation of the modularity, useful particularly in spectral optimization algorithms, is as follows. Define
Svr
1
v
r
0
\delta(cv,cw)=\sumrSvrSwr
and hence
Q=
1 | |
2m |
\sumvw\sumr\left[Avw-
kvkw | |
2m |
\right]SvrSwr=
1 | |
2m |
Tr(STBS),
where
S
Sv
B
Bvw=Avw-
kvkw | |
2m |
.
All rows and columns of the modularity matrix sum to zero, which means that the modularity of an undivided network is also always
0
For networks divided into just two communities, one can alternatively define
sv=\pm1
v
Q={1\over4m}\sumvwBvwsvsw={1\over4m}sTBs,
where
s
sv
This function has the same form as the Hamiltonian of an Ising spin glass, a connection that has been exploited to create simple computer algorithms, for instance using simulated annealing, to maximize the modularity. The general form of the modularity for arbitrary numbers of communities is equivalent to a Potts spin glass and similar algorithms can be developed for this case also.[7]
Although the method of modularity maximization is motivated by computing a deviation from a null model, this deviation is not computed in a statistically consistent manner.[8] Because of this, the method notoriously finds high-scoring communities in its own null model(the configuration model), which by definition cannot be statistically significant. Because of this, the method cannot be used to reliably obtain statistically significant community structure in empirical networks.
Modularity compares the number of edges inside a cluster with the expected number of edges thatone would find in the cluster if the network were a random network with the same number of nodes and whereeach node keeps its degree, but edges are otherwise randomly attached. This random null model implicitly assumes that each node can get attached to any other node of the network. This assumption is however unreasonable if the network is very large, as the horizon of a node includes a small part of the network, ignoring most of it.Moreover, this implies that the expected number of edges between two groups of nodes decreases if the size of the network increases. So, if a network is large enough, the expected number of edges between two groups of nodes in modularity's null model may be smaller than one. If this happens, a single edge between the two clusters would be interpreted by modularity as a sign of a strong correlation between the two clusters, and optimizing modularity would lead to the merging of the two clusters, independently of the clusters' features. So, even weakly interconnected complete graphs, which have the highest possible density of internal edges, and represent the best identifiable communities, would be merged by modularity optimization if the network were sufficiently large.[9] For this reason, optimizing modularity in large networks would fail to resolve small communities, even when they are well defined. This biasis inevitable for methods like modularity optimization, which rely on a global null model.[10]
There are two main approaches which try to solve the resolution limit within the modularity context: the addition of a resistance r to every node, in the form of a self-loop, which increases (r>0) or decreases (r<0) the aversion of nodes to form communities;[11] or the addition of a parameter γ>0 in front of the null-case term in the definition of modularity, which controls the relative importance between internal links of the communities and the null model. Optimizing modularity for values of these parameters in their respective appropriate ranges, it is possible to recover the whole mesoscale of the network, from the macroscale in which all nodes belong to the same community, to the microscale in which every node forms its own community, hence the name multiresolution methods. However, it has been shown that these methods have limitations when communities are very heterogeneous in size.[12]
There are a couple of software tools available that are able to compute clusterings in graphs with good modularity.
Original implementation of the multi-level Louvain method.
The Leiden algorithm which additionally avoids unconnected communities.
The Vienna Graph Clustering (VieClus) algorithm, a parallel memetic algorithm.