# triangular_lattice_graph#

triangular_lattice_graph(m, n, periodic=False, with_positions=True, create_using=None)[source]#

Returns the $$m$$ by $$n$$ triangular lattice graph.

The triangular lattice graph is a two-dimensional grid graph in which each square unit has a diagonal edge (each grid unit has a chord).

The returned graph has $$m$$ rows and $$n$$ columns of triangles. Rows and columns include both triangles pointing up and down. Rows form a strip of constant height. Columns form a series of diamond shapes, staggered with the columns on either side. Another way to state the size is that the nodes form a grid of m+1 rows and (n + 1) // 2 columns. The odd row nodes are shifted horizontally relative to the even rows.

Directed graph types have edges pointed up or right.

Positions of nodes are computed by default or with_positions is True. The position of each node (embedded in a euclidean plane) is stored in the graph using equilateral triangles with sidelength 1. The height between rows of nodes is thus $$\sqrt(3)/2$$. Nodes lie in the first quadrant with the node $$(0, 0)$$ at the origin.

Parameters
mint

The number of rows in the lattice.

nint

The number of columns in the lattice.

periodicbool (default: False)

If True, join the boundary vertices of the grid using periodic boundary conditions. The join between boundaries is the final row and column of triangles. This means there is one row and one column fewer nodes for the periodic lattice. Periodic lattices require m >= 3, n >= 5 and are allowed but misaligned if m or n are odd

with_positionsbool (default: True)

Store the coordinates of each node in the graph node attribute ‘pos’. The coordinates provide a lattice with equilateral triangles. Periodic positions shift the nodes vertically in a nonlinear way so the edges don’t overlap so much.

create_usingNetworkX graph constructor, optional (default=nx.Graph)

Graph type to create. If graph instance, then cleared before populated.

Returns
NetworkX graph

The m by n triangular lattice graph.