finds communities in the graph g.
FindGraphCommunities[{vw,…}]
uses rules vw to specify the graph g.
FindGraphCommunities
finds communities in the graph g.
FindGraphCommunities[{vw,…}]
uses rules vw to specify the graph g.
Details and Options
- FindGraphCommunities finds communities with many edges joining vertices of the same community and comparatively few edges joining vertices of different communities.
- FindGraphCommunities returns a list of communities {c1,c2,…}, where each community ci is a list of vertices.
- The communities are ordered by their length, with the largest community first.
- FindGraphCommunities supports a Method option that specifies the detailed method to use.
- Possible settings for the Method option include:
-
"Modularity" modularity-based clustering "Centrality" centrality-based clustering "CliquePercolation" clique percolation-based clustering "Hierarchical" hierarchical-based clustering "Spectral" spectral-based clustering - FindGraphCommunities works with undirected graphs, directed graphs, weighted graphs, multigraphs, and mixed graphs.
Examples
open all close allBasic Examples (2)
g = Graph[{12, 23, 13, 34, 45, 76, 86, 57, 78}]FindGraphCommunities[g]HighlightGraph[g, Map[Subgraph[g, #]&, %]]RandomGraph[WattsStrogatzGraphDistribution[30, 0.3, 3]]CommunityGraphPlot[%, FindGraphCommunities[%]]Scope (7)
FindGraphCommunities works with undirected graphs:
FindGraphCommunities[[image]]FindGraphCommunities[[image]]FindGraphCommunities[[image]]FindGraphCommunities[[image]]FindGraphCommunities[[image]]Use rules to specify the graph:
FindGraphCommunities[{1 -> 2, 1 -> 3, 2 -> 4, 3 -> 4, 3 -> 5, 4 -> 6, 5 -> 6, 5 -> 7, 6 -> 8, 7 -> 8}]FindGraphCommunities works with large graphs:
g = RandomGraph[WattsStrogatzGraphDistribution[10 ^ 4, 0.25, 5]];Timing[Length[FindGraphCommunities[g]]]Options (6)
Method (6)
By default, FindGraphCommunities uses modularity maximization methods:
FindGraphCommunities[[image]]This can also be obtained with Method->"Modularity":
FindGraphCommunities[[image], Method -> "Modularity"]Use Method->"Hierarchical" for hierarchical clustering based on vertex similarity:
FindGraphCommunities[[image], Method -> "Hierarchical"]Use Method->"Spectral" for spectral partitioning:
FindGraphCommunities[[image], Method -> "Spectral"]Use Method->"Centrality" for partitioning based on edge centrality:
FindGraphCommunities[[image], Method -> "Centrality"]Use Method->"CliquePercolation" for k-clique percolation:
FindGraphCommunities[[image], Method -> "CliquePercolation"]Use Method->"VertexMoving" to improve the result obtained by default:
g = GridGraph[{3, 7}]N[GraphAssortativity[g, FindGraphCommunities[g]]]N[GraphAssortativity[g, FindGraphCommunities[g, Method -> "VertexMoving"]]]Applications (2)
Find communities in a friendship network between members of a karate club:
g = ExampleData[{"NetworkGraph", "ZacharyKarateClub"}];FindGraphCommunities[g, Method -> "Hierarchical"]Predict the split of the network in case of an internal conflict:
HighlightGraph[g, Subgraph[g, #]& /@ %, GraphHighlightStyle -> "DehighlightHide"]A weighted network of wins in the National Hockey League during regular season 2010–2011. Group teams by conferences:
g = ExampleData[{"NetworkGraph", "NationalHockeyLeague"}];conferences = FindGraphCommunities[g]Partition teams in six divisions:
divisions = FindGraphPartition[g, 6]Properties & Relations (5)
Communities are ordered by their length, with the largest community first:
g = RandomGraph[SpatialGraphDistribution[100, 0.15]];Length /@ FindGraphCommunities[g]By default, FindGraphCommunities gives communities with high modularity:
g = ExampleData[{"NetworkGraph", "ZacharyKarateClub"}];FindGraphCommunities[g]Use GraphAssortativity to compute the modularity:
N[GraphAssortativity[g, %, "Normalized" -> False]]Use FindGraphPartition to find partitions of vertices into k parts of approximately equal size:
g = RandomGraph[WattsStrogatzGraphDistribution[20, 0.1, 3]];FindGraphPartition[g, 3]The size of communities in the Watts–Strogatz model:
𝒟[p_] := GraphPropertyDistribution[Length[FindGraphCommunities[g]], gWattsStrogatzGraphDistribution[1000, p]]ListPlot[Table[{p, RandomVariate[𝒟[p]]}, {p, 0, 1, 0.01}]]𝒟[r_] := GraphPropertyDistribution[Length[FindGraphCommunities[g]], gSpatialGraphDistribution[100, r]]ListPlot[Table[{r, RandomVariate[𝒟[r]]}, {r, 0, 0.25, 0.001}]]CommunityGraphPlot finds and visualizes communities:
g = RandomGraph[WattsStrogatzGraphDistribution[30, 0.3, 3]];CommunityGraphPlot[g]CommunityGraphPlot[g, FindGraphCommunities[g, Method -> "Spectral"]]Related Guides
Text
Wolfram Research (2012), FindGraphCommunities, Wolfram Language function, https://reference.wolfram.com/language/ref/FindGraphCommunities.html (updated 2015).
CMS
Wolfram Language. 2012. "FindGraphCommunities." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/FindGraphCommunities.html.
APA
Wolfram Language. (2012). FindGraphCommunities. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindGraphCommunities.html
BibTeX
@misc{reference.wolfram_2026_findgraphcommunities, author="Wolfram Research", title="{FindGraphCommunities}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/FindGraphCommunities.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_findgraphcommunities, organization={Wolfram Research}, title={FindGraphCommunities}, year={2015}, url={https://reference.wolfram.com/language/ref/FindGraphCommunities.html}, note=[Accessed: 12-June-2026]}