libpysal.weights.w_local_cluster¶
- libpysal.weights.w_local_cluster(w)[source]¶
Local clustering coefficients for each unit as a node in a graph.
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\) [WS98].
Examples
>>> from libpysal.weights import lat2W, w_local_cluster >>> 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. ]])