libpysal.weights.neighbor_equality

libpysal.weights.neighbor_equality(w1, w2)[source]

Test if the neighbor sets are equal between two weights objects

Parameters:
w1W

instance of spatial weights class W

w2W

instance of spatial weights class W

Returns:
bool

Notes

Only set membership is evaluated, no check of the weight values is carried out.

Examples

>>> from libpysal.weights.util import neighbor_equality
>>> from libpysal.weights import lat2W, W
>>> w1 = lat2W(3,3)
>>> w2 = lat2W(3,3)
>>> neighbor_equality(w1, w2)
True
>>> w3 = lat2W(5,5)
>>> neighbor_equality(w1, w3)
False
>>> n4 = w1.neighbors.copy()
>>> n4[0] = [1]
>>> n4[1] = [4, 2]
>>> w4 = W(n4)
>>> neighbor_equality(w1, w4)
False
>>> n5 = w1.neighbors.copy()
>>> n5[0]
[3, 1]
>>> n5[0] = [1, 3]
>>> w5 = W(n5)
>>> neighbor_equality(w1, w5)
True