libpysal.weights.netW

libpysal.weights.netW(link_list, share='A', transform='r', **kwargs)[source]

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

Parameters
link_listlist

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

sharestr

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: O a shared origin node; D a shared destination node; OD; a shared origin 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.

transformTransformation for standardization of final OD spatial weight; default

is ‘r’ for row standardized

**kwargskeyword arguments

optional arguments for pysal.weights.W

Returns
Wnodal contiguity W object for networkd edges or flows

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

Examples

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