networkx.algorithms.community.modularity_max.greedy_modularity_communities¶
-
greedy_modularity_communities
(G, weight=None)[source]¶ Find communities in graph using Clauset-Newman-Moore greedy modularity maximization. This method currently supports the Graph class and does not consider edge weights.
Greedy modularity maximization begins with each node in its own community and joins the pair of communities that most increases modularity until no such pair exists.
- Parameters
G (NetworkX graph)
- Returns
- Return type
Yields sets of nodes, one for each community.
Examples
>>> from networkx.algorithms.community import greedy_modularity_communities >>> G = nx.karate_club_graph() >>> c = list(greedy_modularity_communities(G)) >>> sorted(c[0]) [8, 14, 15, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
References
- 1
M. E. J Newman ‘Networks: An Introduction’, page 224 Oxford University Press 2011.
- 2
Clauset, A., Newman, M. E., & Moore, C. “Finding community structure in very large networks.” Physical Review E 70(6), 2004.