landlab.graph.matrix package#

Subpackages#

Submodules#

landlab.graph.matrix.at_node module#

Get links and their directions at each node.

Parameters:

nodes_at_link (ndarray of int, shape (n_links, 2)) – Node identifier for each link tail and head.

Returns:

Tuple of link identifiers for each node, link directions for each node and offsets into these arrays for each node.

Return type:

tuple of ndarray of int

Examples

::

0 – 1 | | 2 – 3 - 4

>>> import numpy as np
>>> nodes_at_link = np.array([[2, 3], [3, 4], [2, 0], [3, 1], [4, 1], [0, 1]])
>>> (links_at_node, link_dirs_at_node, offset_to_node) = get_links(nodes_at_link)
>>> links_at_node
array([2, 5, 3, 4, 5, 0, 2, 0, 1, 3, 1, 4])
>>> link_dirs_at_node
array([ 1, -1,  1,  1,  1, -1, -1,  1, -1, -1,  1, -1], dtype=int8)
>>> offset_to_node
array([ 0,  2,  5,  7, 10, 12])

landlab.graph.matrix.at_patch module#

Construct as links_at_patch array for a graph.

Parameters:
  • patches (tuple of ndarray of int) – Links that define patches as (links, offset_to_patch).

  • sort (bool, optional) – Sort the links.

  • nodes_at_link (ndarray of int, shape (n_links, 2)) – Nodes at link tail and head.

  • xy_of_node (ndarray of float, shape (n_nodes, 2)) – Coordinates of nodes.

Examples

Module contents#