Communities#
Functions for computing and measuring community structure.
The functions in this class are not imported into the toplevel
networkx
namespace. You can access these functions by importing
the networkx.algorithms.community
module, then accessing the
functions as attributes of community
. For example:
>>> from networkx.algorithms import community
>>> G = nx.barbell_graph(5, 1)
>>> communities_generator = community.girvan_newman(G)
>>> top_level_communities = next(communities_generator)
>>> next_level_communities = next(communities_generator)
>>> sorted(map(sorted, next_level_communities))
[[0, 1, 2, 3, 4], [5], [6, 7, 8, 9, 10]]
Bipartitions#
Functions for computing the Kernighan–Lin bipartition algorithm.

Partition a graph into two blocks using the Kernighan–Lin algorithm. 
KClique#

Find kclique communities in graph using the percolation method. 
Modularitybased communities#
Functions for detecting communities based on modularity.

Find communities in G using greedy modularity maximization. 

Find communities in G using greedy modularity maximization. 
Tree partitioning#
Lukes Algorithm for exact optimal weighted tree partitioning.

Optimal partitioning of a weighted tree using the Lukes algorithm. 
Label propagation#
Label propagation community detection algorithms.

Returns communities in 
Generates community sets determined by label propagation 
Louvain Community Detection#
Function for detecting communities based on Louvain Community Detection Algorithm

Find the best partition of a graph using the Louvain Community Detection Algorithm. 

Yields partitions for each level of the Louvain Community Detection Algorithm 
Fluid Communities#
Asynchronous Fluid Communities algorithm for community detection.

Returns communities in 
Measuring partitions#
Functions for measuring the quality of a partition (into communities).

Returns the coverage of a partition. 

Returns the modularity of the given partition of the graph. 

Returns the coverage and performance of a partition of G. 

Returns the performance of a partition. 
Partitions via centrality measures#
Functions for computing communities based on centrality notions.

Finds communities in a graph using the Girvan–Newman method. 
Validating partitions#
Helper functions for communityfinding algorithms.

Returns True if 