networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersYields
_greedy_modularity_communities_generator(G, weight=None, resolution=1)

This function performs Clauset-Newman-Moore greedy modularity maximization At each step of the process it yields the change in modularity that will occur in the next step followed by yielding the new community partition after that step.

Greedy modularity maximization begins with each node in its own community and repeatedly joins the pair of communities that lead to the largest modularity until one community contains all nodes (the partition has one set).

This function maximizes the generalized modularity, where :None:None:`resolution` is the resolution parameter, often expressed as $\gamma$. See ~networkx.algorithms.community.quality.modularity .

Parameters

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

The name of an edge attribute that holds the numerical value used as a weight. If None, then each edge has weight 1. The degree is the sum of the edge weights adjacent to the node.

resolution : float (default=1)

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

Yield community partitions of G and the modularity change at each step.

Yields

Alternating yield statements produce the following two objects:
communities: dict_values

A dict_values of frozensets of nodes, one for each community. This represents a partition of the nodes of the graph into communities. The first yield is the partition with each node in its own community.

dq: float

The change in modularity when merging the next two communities that leads to the largest modularity.

See Also

modularity

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/modularity_max.py#17
type: <class 'function'>
Commit: