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

This implementation is O(n^4), much slower than alternatives, but it is provided as an easy-to-understand reference implementation.

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.

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
resolution : float (default=1)

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

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.

Returns

list

A list of sets of nodes, one for each community. Sorted by length with largest communities first.

Find communities in G using greedy modularity maximization.

See Also

greedy_modularity_communities
modularity

Examples

>>> from networkx.algorithms.community import \
naive_greedy_modularity_communities
... G = nx.karate_club_graph()
... c = naive_greedy_modularity_communities(G)
... sorted(c[0]) [8, 14, 15, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
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#376
type: <class 'function'>
Commit: