pysal.lib.weights.netW(link_list, share='A', transform='r')[source]

Create a network-contiguity based weight object based on different nodal relationships encoded in a network.

link_list : list

of tuples where each tuple is of the form (o,d) where o is an origin id and d is a destination id

share : string

denoting how to define the nodal relationship used to determine neighboring edges; defualt is ‘A’ for any shared nodes between two network edges; options include:

‘A’: any shared nodes ‘O’: a shared origin node ‘D’: a shared destination node ‘OD’ a shared origin node or a shared destination node ‘C’: a shared node that is the destination of the first

edge and the origin of the second edge - i.e., a directed chain is formed moving from edge one to edge two.

transform : Transformation for standardization of final OD spatial weight; default

is ‘r’ for row standardized

W : nodal contiguity W object for networkd edges or flows

W Object representing the binary adjacency of the network edges given a definition of nodal relationshipysal.lib.weights.spintW.


>>> import pysal.lib
>>> links = [('a','b'), ('a','c'), ('a','d'), ('c','d'), ('c', 'b'), ('c','a')]
>>> O = pysal.lib.weights.spintW.netW(links, share='O')
>>> O.neighbors[('a', 'b')]
[('a', 'c'), ('a', 'd')]
>>> OD = pysal.lib.weights.spintW.netW(links, share='OD')
>>> OD.neighbors[('a', 'b')]
[('a', 'c'), ('a', 'd'), ('c', 'b')]
>>> any_common = pysal.lib.weights.spintW.netW(links, share='A')
>>> any_common.neighbors[('a', 'b')]
[('a', 'c'), ('a', 'd'), ('c', 'b'), ('c', 'a')]