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
weights : bool, optional
|
---|---|
Returns: | out : float, 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)
{0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0, 4: 1.0}