Compute the squares clustering coefficient for nodes.
For each node return the fraction of possible squares that exist at the node [R186]
![C_4(v) = \frac{ \sum_{u=1}^{k_v}
\sum_{w=u+1}^{k_v} q_v(u,w) }{ \sum_{u=1}^{k_v}
\sum_{w=u+1}^{k_v} [a_v(u,w) + q_v(u,w)]},](../../_images/math/348128ff19e9b120c128e89bebf3362b182639b3.png)
where
are the number of common neighbors of
and
other than
(ie squares), and
,
where
if
and
are connected and 0 otherwise.
| Parameters : | G : graph nodes : container of nodes, optional (default=all nodes in G)
|
|---|---|
| Returns : | c4 : dictionary
|
Notes
While
(triangle clustering) gives the probability that
two neighbors of node v are connected with each other,
is
the probability that two neighbors of node v share a common
neighbor different from v. This algorithm can be applied to both
bipartite and unipartite networks.
References
| [R186] | (1, 2) Pedro G. Lind, Marta C. González, and Hans J. Herrmann. 2005 Cycles and clustering in bipartite networks. Physical Review E (72) 056127. |
Examples
>>> G=nx.complete_graph(5)
>>> print(nx.square_clustering(G,0))
1.0
>>> print(nx.square_clustering(G))
{0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0, 4: 1.0}