pysal.lib.weights.w_local_cluster

pysal.lib.weights.w_local_cluster(w)[source]

Local clustering coefficients for each unit as a node in a graph. [ws]

Parameters:
w : W

spatial weights object

Returns:
c : array

(w.n,1) local clustering coefficients

Notes

The local clustering coefficient \(c_i\) quantifies how close the neighbors of observation \(i\) are to being a clique:

\[c_i = | \{w_{j,k}\} |/ (k_i(k_i - 1)): j,k \in N_i\]

where \(N_i\) is the set of neighbors to \(i\), \(k_i = |N_i|\) and \(\{w_{j,k}\}\) is the set of non-zero elements of the weights between pairs in \(N_i\). [Watts1998]

Examples

>>> from pysal.lib.weights import lat2W
>>> w = lat2W(3,3, rook=False)
>>> w_local_cluster(w) 
array([[1.        ],
       [0.6       ],
       [1.        ],
       [0.6       ],
       [0.42857143],
       [0.6       ],
       [1.        ],
       [0.6       ],
       [1.        ]])

True