# landlab.graph.object package#

## landlab.graph.object.at_node module#

Set up data structures for node-to-link connectivity.

Parameters:
• graph (Graph) – A Graph.

• nodes_at_link (ndarray of int) – Nodes at either end of a link (tail node, then head node).

• number_of_nodes (int, optional) – The total number of nodes. If not given, use the largest node in nodes_at_link.

Returns:

Return type:

tuple of ndarray

Parameters:

• link_dirs_at_node (ndarray of int, shape (n_nodes, max_links_per_node)) – Direction of links entering or leaving each node.

Returns:

The sorted arrays. If inplace is True, these are the input arrays.

Return type:

Examples

```>>> import numpy as np
```
```(1) - 1 -> (3)
|          ^
2          3
V          |
(0) - 0 -> (2)
```
```>>> links_at_node = [[2, 0], [1, 2], [3, 0], [3, 1]]
>>> link_dirs_at_node = [[1, -1], [-1, -1], [-1, 1], [1, 1]]
>>> angle_of_link = np.array([0., 0., -90., 90.]) * np.pi / 180.
```
```>>> out = sort_links_at_node_by_angle(links_at_node, link_dirs_at_node,
```

The first item of the returned tuple is links at each node sorted counterclockwise by angle.

```>>> out
array([[0, 2], [2, 1], [3, 0],  [1, 3]])
```

The second item is the direction of the link (entering or leaving).

```>>> out
array([[-1,  1], [-1, -1], [-1,  1], [ 1,  1]], dtype=int8)
```

Because the input arrays are lists, not numpy arrays, the sort is not in-place.

```>>> out is not links_at_node
True
```
```>>> links_at_node = np.asarray([[2, 0], [1, 2], [3, 0], [3, 1]], dtype=int)
>>> link_dirs_at_node = np.asarray([[1, -1], [-1, -1], [-1, 1], [1, 1]], dtype=np.int8)
>>> angle_of_link = np.array([0., 0., -90., 90.]) * np.pi / 180.
```
```>>> _ = sort_links_at_node_by_angle(links_at_node, link_dirs_at_node,
array([[0, 2], [2, 1], [3, 0],  [1, 3]])
array([[-1,  1], [-1, -1], [-1,  1], [ 1,  1]], dtype=int8)
```

## landlab.graph.object.at_patch module#

get_nodes_at_patch(graph)[source]#

Set up data structure that describes node-patch connectivity.

Parameters: