triangular_lattice_graph(m, n, periodic=False, with_positions=True, create_using=None)
The :None:None:`triangular lattice graph`
is a two-dimensional :None:None:`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 :None:None:`m+1`
rows and :None:None:`(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 :None:None:`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.
<Unimplemented 'target' '.. _triangular lattice graph: http://mathworld.wolfram.com/TriangularGrid.html'>
<Unimplemented 'target' '.. _grid graph: http://www-cs-students.stanford.edu/~amitp/game-programming/grids/'>
<Unimplemented 'target' '.. _Triangular Tiling: https://en.wikipedia.org/wiki/Triangular_tiling'>
The number of rows in the lattice.
The number of columns in the lattice.
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 :None:None:`m >= 3`
, :None:None:`n >= 5`
and are allowed but misaligned if m
or n
are odd
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.
Graph type to create. If graph instance, then cleared before populated.
The m by n triangular lattice graph.
Returns the $m$ by $n$ triangular lattice graph.
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them