tensorcircuit.templates.graphs¶

Some common graphs and lattices

tensorcircuit.templates.graphs.Even1D(n: int, s: int = 0) Any[source]¶
class tensorcircuit.templates.graphs.Grid2DCoord(n: int, m: int)[source]¶

Bases: object

Two-dimensional grid lattice

__init__(n: int, m: int)[source]¶
Parameters:
  • n (int) – number of rows

  • m (int) – number of cols

all_cols(pbc: bool = False) Sequence[Tuple[int, int]][source]¶

return all col edge with 1d index encoding

Parameters:

pbc (bool, optional) – whether to include pbc edges (periodic boundary condition), defaults to False

Returns:

list of col edge

Return type:

Sequence[Tuple[int, int]]

all_rows(pbc: bool = False) Sequence[Tuple[int, int]][source]¶

return all row edge with 1d index encoding

Parameters:

pbc (bool, optional) – whether to include pbc edges (periodic boundary condition), defaults to False

Returns:

list of row edge

Return type:

Sequence[Tuple[int, int]]

lattice_graph(pbc: bool = True) Any[source]¶

Get the 2D grid lattice in nx.Graph format

Parameters:

pbc (bool, optional) – whether to include pbc edges (periodic boundary condition), defaults to True

Returns:

_description_

Return type:

Graph

one2two(i: int) Tuple[int, int][source]¶
two2one(x: int, y: int) int[source]¶
tensorcircuit.templates.graphs.Line1D(n: int, node_weight: Sequence[float] | None = None, edge_weight: Sequence[float] | None = None, pbc: bool = True) Any[source]¶

1D chain with n sites

Parameters:
  • n (int) – [description]

  • pbc (bool, optional) – [description], defaults to True

Returns:

[description]

Return type:

Graph

tensorcircuit.templates.graphs.Odd1D(n: int, *, s: int = 1) Any¶