pysal.lib.weights.
higher_order_sp
(w, k=2, shortest_path=True, diagonal=False)[源代码]¶稀疏W的邻接权重或顺序K的邻接权重。
参数: |
|
---|---|
返回: |
|
笔记
低阶连续性被移除。
实例
>>> from pysal.lib.weights import lat2W
>>> import pysal.lib
>>> w25 = lat2W(5,5)
>>> w25.n
25
>>> w25[0] == {1: 1.0, 5: 1.0}
True
>>> w25_2 = pysal.lib.weights.util.higher_order_sp(w25, 2)
>>> w25_2[0] == {10: 1.0, 2: 1.0, 6: 1.0}
True
>>> w25_2 = pysal.lib.weights.util.higher_order_sp(w25, 2, diagonal=True)
>>> w25_2[0] == {0: 1.0, 10: 1.0, 2: 1.0, 6: 1.0}
True
>>> w25_3 = pysal.lib.weights.util.higher_order_sp(w25, 3)
>>> w25_3[0] == {15: 1.0, 3: 1.0, 11: 1.0, 7: 1.0}
True
>>> w25_3 = pysal.lib.weights.util.higher_order_sp(w25, 3, shortest_path=False)
>>> w25_3[0] == {1: 1.0, 3: 1.0, 5: 1.0, 7: 1.0, 11: 1.0, 15: 1.0}
True