Modularity Maximization
By: Luís Rita
Tags: Modularity, Greedy Algorithms, Community, Clustering, Maximization

Modularity Maximization

Greedy Algorithm

Current article is based on these 4 hypotheses to define a community

Based on the hypothesis a random network does not have community structure, the local modularity concept was formulated [1]. It compares the partition of a given network with the analogous degree-preserved randomization.

Considering a network with N nodes and L links, and a partition of it with nc communities, each with Nc nodes and Lc links:

Local modularity compares the number of links between the real network wiring of a subgraph Cc and the randomly rewired subgraph:

pij results from randomly rewiring the whole network, maintaining the expected degree of each node:

If Mc = 0, then the subgraph is randomly wired (thus, no community structure). If Mc < 0, Cc has fewer edges than expected and should not be considered a community.

Manipulating (2), a simplified formula is obtained:

Generalizing local modularity to the whole network, the best partition of the graph is identified. This way, the network’s modularity becomes the sum over all communities of (4):

Similarly, the higher the modularity, the higher the quality of the partition of the network. It can take positive, null or negative values. Whenever the whole network is defined as one community:

In the extreme case, each node is a single community, Lc = 0 and the modularity becomes negative. Consequently, none of the previous structures can be classified as a community.

Several algorithms use modularity to partition a network.

Greedy Algorithm

Greedy algorithm maximizes modularity at each step [2]:

1. At the beginning, each node belongs to a different community;

2. The pair of nodes/communities that, joined, increase modularity the most, become part of the same community. Modularity is calculated for the full network;

3. Step 2 is executed until one community remains;

4. Network partition with the higher modularity is chosen.

In terms of computational complexity, since modularity variation can be calculated in constant time, step 2 requires O(L) calculations. After merging communities, the adjacency matrix of the network is updated in a worst-case scenario of O(N). Each merging event is repeated N-1 times. Thus, the overall complexity is: O((L+N)N) or O(N^2), in a sparse graph.

Although modularity is computationally suited and an accurate way of community detection, two pitfalls should be highlighted: resolution limit and modularity maxima.

Resolution Limit

First, a way to calculate the network’s modularity variation when communities A and B are merged is introduced [2]:

This means two communities should be joined whenever:

Assuming there is one link between communities A and B:

In other words, when communities A and B are connected even only by one link, they will be merged if their size is lower than a threshold. Becoming impossible to detect communities below a certain size.

Assuming,

The resolution limit depends on the size of the network. One way to overcome this limitation is by subdividing larger communities into smaller ones and partition them.

Modularity Maxima

The fourth hypothesis presented at the beginning of the article, relies on the assumption that higher modularity implies a better partition of the network. Although, in some graphs, significantly different partitions may have similar modularity. This becomes a relevant issue when the number of nodes in the network increases. Becoming harder to separate the network’s best partition from the lower quality ones. In the case of the algorithms that optimize modularity, this is a central issue, once they iterate until its variation is lower than an input threshold.

Figure 1 Significantly different partitions of the same network can have similar modularity [2]

Upon analyzes of the network in Figure 1, the number of links inside each cluster is approximated to:

Considering kA = kB = kC and applying (7) to the previous network, modularity variation is calculated in terms of the number of nodes nc:

Merging two random clusters of the previous network in the same community will decrease modularity at most 2/nc^2. In the limit, this variation is undetectable:

Empirically, the best partition should be the one that groups each 5-node cluster in different communities. Although, modularity increases by 0.003 whenever two adjacent communities are merged. Moreover, if random 5-node clusters are assigned to a community, even if they are not directly connected, it results in a modularity variation close to 0 around the one detected for the optimal partition. This complies with the vision of the plateau in the modularity graph that may distort the choice of the best partition in Figure 1. This plateau explains why a large number of modularity maximization algorithms can quickly detect high modularity partitions — they are not unique.

Modularity optimization algorithms are part of a larger set of problems that are solved by optimizing a quality function.

References

[1] A.-L. Barabási, “Network Science Book,” [Online]. Available: http://networksciencebook.com. [Accessed 15 May 2019]

[2] M. E. J. Newman, “Fast algorithm for detecting community structure in networks,” Physical Review E, vol. 69, no. 6, 2004