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
nodes : container of nodes, optional
weighted : bool, optional
|
---|---|
Returns : | out : float, dictionary or tuple of dictionaries
|
Notes
Self loops are ignored.
References
[R103] | Generalizations of the clustering coefficient to weighted complex networks by J. Saramäki, M. Kivelä, J.-P. Onnela, K. Kaski, and J. Kertész, Physical Review E, 75 027105 (2007). http://jponnela.com/web_documents/a9.pdf |
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}