# quimb.tensor.geometry¶

Some functions for generating the edges of a lattice.

## Functions¶

 `sort_unique`(edges) Make sure there are no duplicate edges and that for each `check_2d`(coo, Lx, Ly, cyclic) Check `coo` in inbounds for a maybe cyclic 2D lattice. `edges_2d_square`(Lx, Ly[, cyclic, cells]) Return the graph edges of a finite 2D square lattice. The nodes `edges_2d_hexagonal`(Lx, Ly[, cyclic, cells]) Return the graph edges of a finite 2D hexagonal lattice. There are two `edges_2d_triangular`(Lx, Ly[, cyclic, cells]) Return the graph edges of a finite 2D triangular lattice. There is a `edges_2d_triangular_rectangular`(Lx, Ly[, cyclic, cells]) Return the graph edges of a finite 2D triangular lattice tiled in a `edges_2d_kagome`(Lx, Ly[, cyclic, cells]) Return the graph edges of a finite 2D kagome lattice. There are `check_3d`(coo, Lx, Ly, Lz, cyclic) Check `coo` in inbounds for a maybe cyclic 3D lattice. `edges_3d_cubic`(Lx, Ly, Lz[, cyclic, cells]) Return the graph edges of a finite 3D cubic lattice. The nodes `edges_3d_pyrochlore`(Lx, Ly, Lz[, cyclic, cells]) Return the graph edges of a finite 3D pyorchlore lattice. There are `edges_3d_diamond`(Lx, Ly, Lz[, cyclic, cells]) Return the graph edges of a finite 3D diamond lattice. There are `edges_3d_diamond_cubic`(Lx, Ly, Lz[, cyclic, cells]) Return the graph edges of a finite 3D diamond lattice tiled in a cubic `edges_tree_rand`(n[, max_degree, seed]) Return a random tree with `n` nodes. This a convenience function for

## Module Contents¶

quimb.tensor.geometry.sort_unique(edges)[source]

Make sure there are no duplicate edges and that for each `coo_a < coo_b`.

quimb.tensor.geometry.check_2d(coo, Lx, Ly, cyclic)[source]

Check `coo` in inbounds for a maybe cyclic 2D lattice.

quimb.tensor.geometry.edges_2d_square(Lx, Ly, cyclic=False, cells=None)[source]

Return the graph edges of a finite 2D square lattice. The nodes (sites) are labelled like `(i, j)`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly))`.

Returns:

edges

Return type:

list[((int, int), (int, int))]

quimb.tensor.geometry.edges_2d_hexagonal(Lx, Ly, cyclic=False, cells=None)[source]

Return the graph edges of a finite 2D hexagonal lattice. There are two sites per cell, and note the cells do not form a square tiling. The nodes (sites) are labelled like `(i, j, s)` for `s` in `'AB'`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly))`.

Returns:

edges

Return type:

list[((int, int, str), (int, int, str))]

quimb.tensor.geometry.edges_2d_triangular(Lx, Ly, cyclic=False, cells=None)[source]

Return the graph edges of a finite 2D triangular lattice. There is a single site per cell, and note the cells do not form a square tiling. The nodes (sites) are labelled like `(i, j)`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly))`.

Returns:

edges

Return type:

list[((int, int), (int, int))]

quimb.tensor.geometry.edges_2d_triangular_rectangular(Lx, Ly, cyclic=False, cells=None)[source]

Return the graph edges of a finite 2D triangular lattice tiled in a rectangular geometry. There are two sites per rectangular cell. The nodes (sites) are labelled like `(i, j, s)` for `s` in `'AB'`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly))`.

Returns:

edges

Return type:

list[((int, int, s), (int, int, s))]

quimb.tensor.geometry.edges_2d_kagome(Lx, Ly, cyclic=False, cells=None)[source]

Return the graph edges of a finite 2D kagome lattice. There are three sites per cell, and note the cells do not form a square tiling. The nodes (sites) are labelled like `(i, j, s)` for `s` in `'ABC'`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly))`.

Returns:

edges

Return type:

list[((int, int, str), (int, int, str))]

quimb.tensor.geometry.check_3d(coo, Lx, Ly, Lz, cyclic)[source]

Check `coo` in inbounds for a maybe cyclic 3D lattice.

quimb.tensor.geometry.edges_3d_cubic(Lx, Ly, Lz, cyclic=False, cells=None)[source]

Return the graph edges of a finite 3D cubic lattice. The nodes (sites) are labelled like `(i, j, k)`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• Lz (int) – The number of cells along the z-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly), range(Lz))`.

Returns:

edges

Return type:

list[((int, int, int), (int, int, int))]

quimb.tensor.geometry.edges_3d_pyrochlore(Lx, Ly, Lz, cyclic=False, cells=None)[source]

Return the graph edges of a finite 3D pyorchlore lattice. There are four sites per cell, and note the cells do not form a cubic tiling. The nodes (sites) are labelled like `(i, j, k, s)` for `s` in `'ABCD'`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• Lz (int) – The number of cells along the z-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly), range(Lz))`.

Returns:

edges

Return type:

list[((int, int, int, str), (int, int, int, str))]

quimb.tensor.geometry.edges_3d_diamond(Lx, Ly, Lz, cyclic=False, cells=None)[source]

Return the graph edges of a finite 3D diamond lattice. There are two sites per cell, and note the cells do not form a cubic tiling. The nodes (sites) are labelled like `(i, j, k, s)` for `s` in `'AB'`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• Lz (int) – The number of cells along the z-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly), range(Lz))`.

Returns:

edges

Return type:

list[((int, int, int, str), (int, int, int, str))]

quimb.tensor.geometry.edges_3d_diamond_cubic(Lx, Ly, Lz, cyclic=False, cells=None)[source]

Return the graph edges of a finite 3D diamond lattice tiled in a cubic geometry. There are eight sites per cubic cell. The nodes (sites) are labelled like `(i, j, k, s)` for `s` in `'ABCDEFGH'`.

Parameters:
• Lx (int) – The number of cells along the x-direction.

• Ly (int) – The number of cells along the y-direction.

• Lz (int) – The number of cells along the z-direction.

• cyclic (bool, optional) – Whether to use periodic boundary conditions.

• cells (list, optional) – A list of cells to use. If not given the cells used are `itertools.product(range(Lx), range(Ly), range(Lz))`.

Returns:

edges

Return type:

list[((int, int, int, str), (int, int, int, str))]

quimb.tensor.geometry.edges_tree_rand(n, max_degree=None, seed=None)[source]

Return a random tree with `n` nodes. This a convenience function for testing purposes and the trees generated are not guaranteed to be uniformly random (for that see `networkx.random_tree`).

Parameters:
• n (int) – The number of nodes.

• max_degree (int, optional) – The maximum degree of the nodes. For example `max_degree=3` means generate a binary tree.

• seed (int, optional) – The random seed.

Returns:

edges

Return type:

list[(int, int)]