networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersYields
louvain_partitions(G, weight='weight', resolution=1, threshold=1e-07, seed=None)

Louvain Community Detection Algorithm is a simple method to extract the community structure of a network. This is a heuristic method based on modularity optimization.

The partitions at each level (step of the algorithm) form a dendogram of communities. A dendrogram is a diagram representing a tree and each level represents a partition of the G graph. The top level contains the smallest communities and as you traverse to the bottom of the tree the communities get bigger and the overal modularity increases making the partition better.

Each level is generated by executing the two phases of the Louvain Community Detection Algorithm.

Parameters

G : NetworkX graph
weight : string or None, optional (default="weight")

The name of an edge attribute that holds the numerical value used as a weight. If None then each edge has weight 1.

resolution : float, optional (default=1)

If resolution is less than 1, the algorithm favors larger communities. Greater than 1 favors smaller communities

threshold : float, optional (default=0.0000001)

Modularity gain threshold for each level. If the gain of modularity between 2 levels of the algorithm is less than the given threshold then the algorithm stops and returns the resulting communities.

seed : integer, random_state, or None (default)

Indicator of random number generation state. See Randomness<randomness> .

Yields partitions for each level of the Louvain Community Detection Algorithm

Yields

list

A list of sets (partition of G). Each set represents one community and contains all the nodes that constitute it.

See Also

louvain_communities

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/community/louvain.py#115
type: <class 'function'>
Commit: