Compute the clustering coefficient for nodes.
For each node find the fraction of possible triangles that exist,
where is the number of triangles through node .
Parameters: | G : graph
nbunch : container of nodes, optional
with_labels: bool, optional :
weights : bool, optional
|
---|---|
Returns: | out : float, list, dictionary or tuple of dictionaries
|
Notes
The weights are the fraction of connected triples in the graph which include the keyed node. Ths is useful for computing transitivity.
Self loops are ignored.
Examples
>>> G=nx.complete_graph(5)
>>> print nx.clustering(G,0)
1.0
>>> print nx.clustering(G,with_labels=True)
{0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0, 4: 1.0}