TOPICS
Search

Community Detection


Community detection is the problem of finding a set partition or an overlapping collection of vertex subsets in a graph so that vertices grouped together share a specified pattern of connectivity. In the most common assortative interpretation, a graph community has comparatively many internal graph edges and comparatively few graph edges joining it to other communities. Other definitions group vertices by structural roles or by latent classes in a stochastic block model, so there is no single definition of a graph community that is appropriate in every setting (Fortunato 2010).

A common approach chooses a set partition that maximizes graph modularity. Modularity compares the observed number of graph edges within each proposed community with the number expected from a null model that preserves the vertex degrees. Modularity is therefore both a measure of community structure and an objective function for community detection, although other definitions and objectives are also used.

The Louvain algorithm is a heuristic for increasing graph modularity by alternating local moves of vertices between communities with aggregation, in which each graph community is replaced by a single graph vertex (Blondel et al. 2008). It can produce communities whose induced subgraphs are disconnected. The Leiden algorithm introduces a refinement phase before aggregation. For the usual graph modularity objective on an undirected graph, it guarantees that each returned graph community induces a connected graph, but does not guarantee a set partition with maximum graph modularity (Traag et al. 2019).

Unlike a classical graph partitioning problem with prescribed part sizes or a fixed cut objective, community detection often includes choosing the number and sizes of the parts. Approaches include cluster analysis based on graph-derived similarities, spectral graph partitioning, and estimation of hidden block labels in a stochastic block model. When a random model supplies true hidden labels, detection commonly asks only for an estimated partition correlated with those labels, while finding every label correctly is a stronger requirement.

For a hypergraph, a hyperedge may meet several communities in different numbers of vertices. Community detection must then determine which hyperedge sizes and splitting patterns to favor, producing trade-offs that do not occur for ordinary pairwise graph edges (Li et al. 2026).

The Wolfram Language function FindGraphCommunities[g] finds communities in a graph, and CommunityGraphPlot[g] visualizes its community structure.


See also

Bethe Hessian, Cluster Analysis, Graph Community, Graph Modularity, Hypergraph Stochastic Block Model, Set Partition, Spectral Graph Partitioning, Stochastic Block Model

Explore with Wolfram|Alpha

References

Blondel, V. D.; Guillaume, J.-L.; Lambiotte, R.; and Lefebvre, E. "Fast Unfolding of Communities in Large Networks." J. Stat. Mech. 2008, P10008, 2008. https://doi.org/10.1088/1742-5468/2008/10/P10008.Fortunato, S. "Community Detection in Graphs." Phys. Rep. 486, 75-174, 2010. https://doi.org/10.1016/j.physrep.2009.11.002.Li, J.; Schaub, M. T.; and Peel, L. "Higher-Order Trade-Offs in Hypergraph Community Detection." Sci. Adv. 12, eaef2184, 2026. https://doi.org/10.1126/sciadv.aef2184.Porter, M. A.; Onnela, J.-P.; and Mucha, P. J. "Communities in Networks." Notices Amer. Math. Soc. 56, 1082-1097, 2009.Traag, V. A.; Waltman, L.; and van Eck, N. J. "From Louvain to Leiden: Guaranteeing Well-Connected Communities." Sci. Rep. 9, 5233, 2019. https://doi.org/10.1038/s41598-019-41695-z.

Cite this as:

Weisstein, Eric W. "Community Detection." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/CommunityDetection.html

Subject classifications