Social networks clump into friend groups. The internet organizes into topical communities. Protein interaction networks form functional modules. These clusters—groups of nodes more densely connected to each other than to the rest of the network—are called communities, and detecting them automatically is one of network science's most important and challenging problems. Community detection algorithms reveal the hidden organizational structure of complex systems from biology to sociology to technology.

What Makes a Community?

A community is a set of nodes with more internal connections than expected by chance. Quantifying this intuition leads to the modularity measure: Q = Σ [A_{ij} − k_i k_j / 2m] for node pairs i,j in the same community, where A is the adjacency matrix, k_i is the degree of node i, and m is the total number of edges. High modularity means the community structure is strong—nodes in communities are much more connected to each other than a random graph with the same degree sequence would predict. Maximizing Q is NP-hard, but good approximate algorithms exist.

Modularity: Q = (1/2m) Σ_{ij} [A_{ij} − k_i k_j / 2m] · δ(c_i, c_j)

The Louvain Method

The Louvain algorithm is the most widely used community detection method. It works in two phases. First, each node starts in its own community; nodes are greedily moved to neighboring communities if doing so increases modularity, repeating until no improvement is possible. Second, communities are collapsed into single nodes and the first phase repeats on this coarser network. Iterating until convergence yields a hierarchical community structure. Louvain runs in near-linear time on sparse graphs, scaling to networks with billions of nodes—essential for social network analysis at internet scale.

Spectral Methods

Spectral clustering uses eigenvalues and eigenvectors of the graph Laplacian matrix L = D − A, where D is the diagonal degree matrix. The eigenvectors corresponding to small eigenvalues encode community structure: nodes in the same community have similar eigenvector values, enabling k-means clustering in eigenvector space to recover communities. The Fiedler vector (second-smallest eigenvector) captures the primary division of a network into two parts—its sign determines which side of the cut each node falls on. Spectral methods have strong theoretical guarantees but are computationally expensive for very large networks.

Overlapping Communities

Real networks often have overlapping communities—a person belongs to family, work, and hobby groups simultaneously. Hard partitioning methods force each node into exactly one community. Soft methods like the Clique Percolation Method detect overlapping communities by finding cliques (complete subgraphs) that share k−1 nodes. Mixed-membership stochastic blockmodels use probabilistic frameworks where each node has fractional membership across communities. Detecting overlapping structure is more realistic but substantially harder, both algorithmically and in terms of validation.

Applications

Community detection has immediate practical applications. In biology, protein interaction networks partitioned into communities reveal functional modules—proteins that work together. In social networks, community detection enables targeted advertising, friend recommendations, and the study of information diffusion and polarization. In cybersecurity, unusual community structure may signal botnet activity. Financial networks are analyzed for community structure to understand systemic risk—communities of correlated assets can amplify shocks. In neuroscience, brain regions that activate together form functional communities whose structure correlates with cognitive tasks.

Conclusion

Community detection transforms the abstract concept of network clustering into computable algorithms capable of revealing the organizational logic of complex systems. From the Louvain method's practical scalability to spectral methods' theoretical elegance, a rich toolkit exists for different network types and scales. The core insight—that networks have natural clusters more connected internally than externally—applies across domains, making community detection one of network science's most broadly applicable tools.