average_clustering(G, trials=1000, seed=None)
The local clustering of each node in G
is the fraction of triangles that actually exist over all possible triangles in its neighborhood. The average clustering coefficient of a graph G
is the mean of local clusterings.
This function finds an approximate average clustering coefficient for G by repeating :None:None:`n`
times (defined in :None:None:`trials`
) the following experiment: choose a node at random, choose two of its neighbors at random, and check if they are connected. The approximate coefficient is the fraction of triangles found over the number of trials .
Number of trials to perform (default 1000).
Indicator of random number generation state. See Randomness<randomness>
.
Approximated average clustering coefficient.
Estimates the average clustering coefficient of G.
>>> from networkx.algorithms import approximationSee :
... G = nx.erdos_renyi_graph(10, 0.2, seed=10)
... approximation.average_clustering(G, trials=1000, seed=10) 0.214
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