networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
average_clustering(G, nodes=None, weight=None, count_zeros=True)

The clustering coefficient for the graph is the average,

$$C = \frac{1}{n}\sum_{v \in G} c_v,$$

where $n$ is the number of nodes in G.

Notes

This is a space saving routine; it might be faster to use the clustering function to get a list and then take the average.

Self loops are ignored.

Parameters

G : graph
nodes : container of nodes, optional (default=all nodes in G)

Compute average clustering for nodes in this container.

weight : string or None, optional (default=None)

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

count_zeros : bool

If False include only the nodes with nonzero clustering in the average.

Returns

avg : float

Average clustering

Compute the average clustering coefficient for the graph G.

Examples

>>> G = nx.complete_graph(5)
... print(nx.average_clustering(G)) 1.0
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.cluster.average_clustering

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