landlab.graph.hex package#

landlab.graph.hex.dual_hex module#

class DualHexGraph(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Bases: `DualGraph`, `TriGraph`

Graph of a structured grid of triangles.

Examples

```>>> import numpy as np
>>> from landlab.graph import DualHexGraph
```
```>>> graph = DualHexGraph((3, 2), node_layout="hex")
>>> graph.number_of_nodes
7
>>> graph.number_of_corners
6
```
```>>> np.round(graph.y_of_node * 2.0 / np.sqrt(3))
array([ 0.,  0.,  1.,  1.,  1.,  2.,  2.])
>>> graph.x_of_node
array([ 0.5,  1.5,  0. ,  1. ,  2. ,  0.5,  1.5])
```

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

__init__(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

property adjacent_corners_at_corner#

Get adjacent corners.

See also

`adjacent_nodes_at_node`

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

`angle_of_link`

property area_of_cell#

Get the area of each cell.

See also

`area_of_patch`

property cells_at_corner#

Get the cells that touch each corner.

See also

`patches_at_node`

property cells_at_face#

Get the cells on either side of each face.

See also

`patches_at_link`

property corner_at_face_head#

Get corners at face head.

See also

`node_at_link_head`

property corner_at_face_tail#

Get corners at face tail.

See also

`node_at_link_tail`

property corner_layout#
property corner_x#
property corner_y#
property corners#

Get identifier for each corner.

See also

`nodes`

property corners_at_bottom_edge#

Get corners along the bottom edge.

See also

`nodes_at_bottom_edge`

property corners_at_cell#

Get the corners that define a cell.

See also

`nodes_at_patch`

property corners_at_face#

Get corners at either end of faces.

See also

`nodes_at_link`

property corners_at_left_edge#

Get corners along the left edge.

See also

`nodes_at_left_edge`

property corners_at_right_edge#

Get corners along the right edge.

See also

`nodes_at_right_edge`

property corners_at_top_edge#

Get corners along the top edge.

See also

`nodes_at_top_edge`

property face_dirs_at_corner#

Return face directions into each corner.

See also

`link_dirs_at_node`

property faces_at_cell#

Get the faces that define a cell.

See also

`links_at_patch`

property faces_at_corner#

Get faces touching a corner.

See also

`links_at_node`

property length_of_face#
property midpoint_of_face#

Get the middle of faces.

See also

`midpoint_of_link`

property number_of_cells#

Get the number of cells.

See also

`number_of_patches`

property number_of_corners#

Get total number of corners.

See also

`number_of_nodes`

property number_of_faces#

Get corners at face head.

See also

`number_of_links`

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

`orientation_of_link`

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

`parallel_links_at_link`

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

`unit_vector_at_node`

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

`unit_vector_at_link`

property x_of_corner#

Get x-coordinate of corner.

See also

`x_of_node`

property xy_of_cell#

Get the centroid of each cell.

See also

`xy_of_patch`

property xy_of_corner#

Get x and y-coordinates of corner.

See also

`xy_of_node`

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

`y_of_node`

landlab.graph.hex.hex module#

Examples

```    * - *
/ \ / \
* - * - *
/ \ / \ / \
* - * - * - *
\ / \ / \ /
* - * - *
\ / \ /
* - *
```
```>>> from landlab.graph import TriGraph
>>> graph = TriGraph((5, 2), node_layout="hex", sort=True)
>>> graph.number_of_nodes
14
>>> graph.x_of_node
array([ 1. ,  2. ,
0.5,  1.5,  2.5,
0. ,  1. ,  2. ,  3. ,
0.5,  1.5, 2.5,
1. ,  2. ])
>>> graph.number_of_links
29
>>> graph.number_of_patches
16
```
```* - * - * - *
\ / \ / \ / \
* - * - * - *
/ \ / \ / \ /
* - * - * - *
```
```>>> from landlab.graph import TriGraph
>>> graph = TriGraph((3, 4), orientation="horizontal", node_layout="rect", sort=True)
>>> graph.number_of_nodes
12
>>> graph.x_of_node.reshape((3, 4))
array([[ 0. ,  1. ,  2. ,  3. ],
[ 0.5,  1.5,  2.5,  3.5],
[ 0. ,  1. ,  2. ,  3. ]])
>>> graph.number_of_links
23
>>> graph.number_of_patches
12
```
class HexGraphExtras[source]#

Bases: `object`

property nodes_at_bottom_edge#

Get nodes along the bottom edge.

Examples

```>>> import numpy as np
>>> from landlab.graph import TriGraph
>>> graph = TriGraph((3, 4), node_layout="rect")
>>> graph.nodes_at_bottom_edge
array([0, 1, 2, 3])
```
property nodes_at_left_edge#

Get nodes along the left edge.

Examples

```>>> import numpy as np
>>> from landlab.graph import TriGraph
>>> graph = TriGraph((3, 4), node_layout="rect")
>>> graph.nodes_at_left_edge
array([0, 4, 8])
```
property nodes_at_right_edge#

Get nodes along the right edge.

Examples

```>>> import numpy as np
>>> from landlab.graph import TriGraph
>>> graph = TriGraph((3, 4), node_layout="rect")
>>> graph.nodes_at_right_edge
array([ 3,  7, 11])
```
property nodes_at_top_edge#

Get nodes along the top edge.

Examples

```>>> import numpy as np
>>> from landlab.graph import TriGraph
>>> graph = TriGraph((3, 4), node_layout="rect")
>>> graph.nodes_at_top_edge
array([ 8,  9, 10, 11])
```

Return array of link orientation codes (one value per link).

Orientation codes are defined by `LinkOrientation`; 1 = E, 2 = ENE, 4 = NNE, 8 = N, 16 = NNW, 32 = ESE (using powers of 2 allows for future applications that might want additive combinations).

Examples

```>>> from landlab import HexModelGrid
>>> import numpy as np
>>> grid = HexModelGrid((3, 2))
>>> grid.orientation_of_link
array([ 1, 16,  4, 16,  4,  1,  1,  4, 16,  4, 16,  1], dtype=uint8)
>>> grid = HexModelGrid((2, 3), orientation="vertical")
>>> grid.orientation_of_link
array([32,  2,  8,  2, 32,  8,  8, 32,  2,  8,  2, 32], dtype=uint8)
```

Return similarly oriented links connected to each link.

Return IDs of links of the same orientation that are connected to each given link’s tail or head node.

The data structure is a numpy array of shape `(n_links, 2)` containing the IDs of the “tail-wise” (connected to tail node) and “head-wise” (connected to head node) links, or -1 if the link is inactive (e.g., on the perimeter) or it has no attached parallel neighbor in the given direction.

For instance, consider a 3x3 hex, in which link IDs are as shown:

```    o---17--o---18--o
/ .     / .     / .
11 12   13  14  15  16
/     . /     . /     .
o---8---o---9---o---10--o
.     / .     / .     /
2   3   4   5   6   7
. /     . /     . /
o---0---o---1---o
```

Here’s a mapping of the tail-wise and head-wise links, where there are valid parallel links:

```    o-------o-------o
/ .     / .     / .
/   .   /   .   /   .
/     4 3     6 5     .
o-----9-o-8--10-o-9-----o
.    13 12   15 14    /
.   /   .   /   .   /
. /     . /     . /
o-------o-------o
```

The corresponding data structure would be mostly filled with -1, but for the 11 active links, it would look like:

```3: [[-1, 13],
4:  [-1, 12],
5:  [-1, 15],
6:  [-1, 14],
8:  [-1,  9],
9:  [ 8, 10],
10: [ 9, -1],
12: [ 4, -1],
13: [ 3, -1],
14: [ 6, -1],
15: [ 5, -1]]
```

Examples

```>>> from landlab import HexModelGrid
>>> grid = HexModelGrid((3, 3))
>>> pll = grid.parallel_links_at_link
>>> pll[3:16]
array([[-1, 13],
[-1, 12],
[-1, 15],
[-1, 14],
[-1, -1],
[-1,  9],
[ 8, 10],
[ 9, -1],
[-1, -1],
[ 4, -1],
[ 3, -1],
[ 6, -1],
[ 5, -1]])
```
class HorizontalHexTriGraph[source]#

Bases: `object`

static corner_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import HorizontalHexTriGraph
>>> HorizontalHexTriGraph.corner_nodes((3, 2))
(4, 6, 5, 2, 0, 1)
>>> HorizontalHexTriGraph.corner_nodes((7, 1))
(9, 15, 15, 6, 0, 0)
>>> HorizontalHexTriGraph.corner_nodes((6, 1))
(9, 14, 13, 6, 0, 0)
>>> HorizontalHexTriGraph.corner_nodes((4, 2))
(8, 11, 9, 5, 0, 1)
```
static nodes_at_edge(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import HorizontalHexTriGraph
>>> HorizontalHexTriGraph.nodes_at_edge((5, 3))
(array([11, 15]), array([18, 17]), array([16, 12]), array([7, 3]),
array([0, 1]), array([2, 6]))
>>> HorizontalHexTriGraph.nodes_at_edge((4, 3))
(array([11]), array([15, 14, 13]), array([12]), array([7, 3]), array([0, 1]),
array([2, 6]))
```
static number_of_nodes(shape)[source]#
static number_of_perimeter_nodes(shape)[source]#
static perimeter_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import HorizontalHexTriGraph
>>> HorizontalHexTriGraph.perimeter_nodes((3, 2))
array([4, 6, 5, 2, 0, 1])
>>> HorizontalHexTriGraph.perimeter_nodes((1, 3))
array([2, 1, 0])
```
static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#
class HorizontalHexTriGraphCython[source]#

Bases: `object`

static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#
class HorizontalRectTriGraph[source]#

Bases: `object`

static corner_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import HorizontalRectTriGraph
>>> HorizontalRectTriGraph.corner_nodes((3, 4))
(11, 8, 0, 3)
>>> HorizontalRectTriGraph.corner_nodes((3, 2))
(5, 4, 0, 1)
>>> HorizontalRectTriGraph.corner_nodes((7, 1))
(6, 6, 0, 0)
>>> HorizontalRectTriGraph.corner_nodes((1, 3))
(2, 0, 0, 2)
```
static nodes_at_edge(shape)[source]#
static number_of_nodes(shape)[source]#
static number_of_perimeter_nodes(shape)[source]#
static perimeter_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import HorizontalRectTriGraph
>>> HorizontalRectTriGraph.perimeter_nodes((3, 2))
array([1, 3, 5, 4, 2, 0])
```
static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#
class HorizontalRectTriGraphCython[source]#

Bases: `object`

static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#
class TriGraph(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Graph of a structured grid of triangles.

Examples

```>>> import numpy as np
>>> from landlab.graph import TriGraph
```
```>>> graph = TriGraph((3, 2))
>>> graph.number_of_nodes == 6
True
>>> np.round(graph.y_of_node * 2.0 / np.sqrt(3))
array([ 0.,  0.,  1.,  1.,  2.,  2.])
>>> graph.x_of_node
array([ 0. ,  1. ,  0.5,  1.5,  0. ,  1. ])
```

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

__init__(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

property node_layout#
property orientation#
property perimeter_nodes#

Get nodes on the convex hull of a Graph.

Examples

```>>> import numpy as np
>>> from landlab.graph import Graph
>>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1]
>>> graph = Graph((node_y, node_x))
>>> np.sort(graph.perimeter_nodes)
array([0, 2, 3, 5])
```
property shape#
property spacing#
class VerticalHexTriGraph[source]#

Bases: `object`

static corner_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import VerticalHexTriGraph
>>> VerticalHexTriGraph.corner_nodes((2, 5))
(10, 13, 8, 3, 0, 5)
>>> VerticalHexTriGraph.corner_nodes((2, 3))
(5, 6, 4, 1, 0, 2)
>>> VerticalHexTriGraph.corner_nodes((2, 4))
(10, 11, 7, 3, 0, 2)
>>> VerticalHexTriGraph.corner_nodes((2, 2))
(4, 4, 3, 1, 0, 0)
>>> VerticalHexTriGraph.corner_nodes((3, 1))
(2, 2, 2, 0, 0, 0)
>>> VerticalHexTriGraph.corner_nodes((1, 3))
(2, 3, 1, 1, 0, 2)
```
static nodes_at_edge(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import VerticalHexTriGraph
>>> VerticalHexTriGraph.nodes_at_edge((3, 7))
(array([ 9, 16]), array([23, 26, 28]), array([29, 27, 24]), array([20, 13]),
array([6, 3, 1]), array([0, 2, 5]))
>>> VerticalHexTriGraph.nodes_at_edge((2, 3))
(array([2]), array([5]), array([6]), array([4]), array([1]), array([0]))
>>> VerticalHexTriGraph.nodes_at_edge((2, 4))
(array([2, 6]), array([10]), array([11, 9]), array([7]), array([3, 1]), array([0]))
```
static number_of_nodes(shape)[source]#
static number_of_perimeter_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import VerticalHexTriGraph
>>> VerticalHexTriGraph.number_of_perimeter_nodes((2, 3))
6
>>> VerticalHexTriGraph.number_of_perimeter_nodes((2, 2))
5
```
static perimeter_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import VerticalHexTriGraph
>>> VerticalHexTriGraph.perimeter_nodes((3, 7))
array([ 9, 16, 23, 26, 28, 29, 27, 24, 20, 13,  6,  3,  1,  0,  2,  5])
>>> VerticalHexTriGraph.perimeter_nodes((2, 3))
array([2, 5, 6, 4, 1, 0])
>>> VerticalHexTriGraph.perimeter_nodes((2, 4))
array([ 2, 6, 10, 11, 9, 7, 3, 1, 0])
>>> VerticalHexTriGraph.perimeter_nodes((2, 2))
array([0, 2, 4, 3, 1])
>>> VerticalHexTriGraph.perimeter_nodes((3, 1))
array([0, 1, 2])
```
static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#
class VerticalHexTriGraphCython[source]#

Bases: `object`

static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#
class VerticalRectTriGraph[source]#

Bases: `object`

static corner_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import VerticalRectTriGraph
>>> VerticalRectTriGraph.corner_nodes((4, 3))
(10, 9, 0, 1)
>>> VerticalRectTriGraph.corner_nodes((4, 4))
(15, 12, 0, 3)
>>> VerticalRectTriGraph.corner_nodes((3, 2))
(5, 4, 0, 1)
>>> VerticalRectTriGraph.corner_nodes((7, 1))
(6, 6, 0, 0)
>>> VerticalRectTriGraph.corner_nodes((1, 3))
(1, 0, 0, 1)
>>> VerticalRectTriGraph.corner_nodes((2, 3))
(4, 3, 0, 1)
```
static nodes_at_edge(shape)[source]#
static number_of_nodes(shape)[source]#
static number_of_perimeter_nodes(shape)[source]#
static perimeter_nodes(shape)[source]#

Examples

```>>> from landlab.graph.hex.hex import VerticalRectTriGraph
>>> VerticalRectTriGraph.perimeter_nodes((3, 2))
array([1, 3, 5, 4, 2, 0])
>>> VerticalRectTriGraph.perimeter_nodes((2, 3))
array([1, 4, 5, 3, 0, 2])
>>> VerticalRectTriGraph.perimeter_nodes((2, 4))
array([3, 7, 5, 6, 4, 0, 2, 1])
```
static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#
class VerticalRectTriGraphCython[source]#

Bases: `object`

static xy_of_node(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0))[source]#

Module contents#

class DualHexGraph(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Bases: `DualGraph`, `TriGraph`

Graph of a structured grid of triangles.

Examples

```>>> import numpy as np
>>> from landlab.graph import DualHexGraph
```
```>>> graph = DualHexGraph((3, 2), node_layout="hex")
>>> graph.number_of_nodes
7
>>> graph.number_of_corners
6
```
```>>> np.round(graph.y_of_node * 2.0 / np.sqrt(3))
array([ 0.,  0.,  1.,  1.,  1.,  2.,  2.])
>>> graph.x_of_node
array([ 0.5,  1.5,  0. ,  1. ,  2. ,  0.5,  1.5])
```

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

__init__(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

property adjacent_corners_at_corner#

Get adjacent corners.

See also

`adjacent_nodes_at_node`

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

`angle_of_link`

property area_of_cell#

Get the area of each cell.

See also

`area_of_patch`

property cells_at_corner#

Get the cells that touch each corner.

See also

`patches_at_node`

property cells_at_face#

Get the cells on either side of each face.

See also

`patches_at_link`

property corner_at_face_head#

Get corners at face head.

See also

`node_at_link_head`

property corner_at_face_tail#

Get corners at face tail.

See also

`node_at_link_tail`

property corner_layout#
property corner_x#
property corner_y#
property corners#

Get identifier for each corner.

See also

`nodes`

property corners_at_bottom_edge#

Get corners along the bottom edge.

See also

`nodes_at_bottom_edge`

property corners_at_cell#

Get the corners that define a cell.

See also

`nodes_at_patch`

property corners_at_face#

Get corners at either end of faces.

See also

`nodes_at_link`

property corners_at_left_edge#

Get corners along the left edge.

See also

`nodes_at_left_edge`

property corners_at_right_edge#

Get corners along the right edge.

See also

`nodes_at_right_edge`

property corners_at_top_edge#

Get corners along the top edge.

See also

`nodes_at_top_edge`

property face_dirs_at_corner#

Return face directions into each corner.

See also

`link_dirs_at_node`

property faces_at_cell#

Get the faces that define a cell.

See also

`links_at_patch`

property faces_at_corner#

Get faces touching a corner.

See also

`links_at_node`

property length_of_face#
property midpoint_of_face#

Get the middle of faces.

See also

`midpoint_of_link`

property number_of_cells#

Get the number of cells.

See also

`number_of_patches`

property number_of_corners#

Get total number of corners.

See also

`number_of_nodes`

property number_of_faces#

Get corners at face head.

See also

`number_of_links`

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

`orientation_of_link`

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

`parallel_links_at_link`

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

`unit_vector_at_node`

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

`unit_vector_at_link`

property x_of_corner#

Get x-coordinate of corner.

See also

`x_of_node`

property xy_of_cell#

Get the centroid of each cell.

See also

`xy_of_patch`

property xy_of_corner#

Get x and y-coordinates of corner.

See also

`xy_of_node`

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

`y_of_node`

class TriGraph(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Graph of a structured grid of triangles.

Examples

```>>> import numpy as np
>>> from landlab.graph import TriGraph
```
```>>> graph = TriGraph((3, 2))
>>> graph.number_of_nodes == 6
True
>>> np.round(graph.y_of_node * 2.0 / np.sqrt(3))
array([ 0.,  0.,  1.,  1.,  2.,  2.])
>>> graph.x_of_node
array([ 0. ,  1. ,  0.5,  1.5,  0. ,  1. ])
```

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

__init__(shape, spacing=1.0, xy_of_lower_left=(0.0, 0.0), orientation='horizontal', node_layout='rect', sort=False)[source]#

Create a structured grid of triangles.

Parameters:
• shape (tuple of int) – Number of rows and columns of the hex grid. The first value is the number of nodes in the first column and the second the number of nodes in the first column.

• spacing (float, optional) – Length of links.

• xy_of_lower_left (tuple of float, optional) – Coordinates of lower-left corner of the grid.

• orientation ({'horizontal', 'vertical'}) – Specify if triangles should be laid out in rows or columns.

• node_layout ({'rect', 'hex'}) – Specify the overall layout of the nodes. Use rect for the layout to approximate a rectangle and hex for a hexagon.

property node_layout#
property orientation#
property perimeter_nodes#

Get nodes on the convex hull of a Graph.

Examples

```>>> import numpy as np
>>> from landlab.graph import Graph
>>> node_x, node_y = [0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1]
>>> graph = Graph((node_y, node_x))
>>> np.sort(graph.perimeter_nodes)
array([0, 2, 3, 5])
```
property shape#
property spacing#