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_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
str
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.
- transform
Transformation
for
standardization
of
final
OD
spatial
weight;default
is ‘r’ for row standardized
- **kwargs
keyword
arguments
optional arguments for
pysal.weights.W
- link_list
- Returns:
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')]