cosmiq.library.graphs#

cosmiq.library.graphs: graphs on atoms, and the lattices whose unit-disk graph the device’s interaction makes.

A pair of atoms is an edge when its interaction is strong, \(V = C_6/r^6 \ge 2.5\,\Omega\), and a non-edge when it is weak, \(V \le 0.5\,\Omega\), at the drive’s \(\Omega\). A register with a pair in between has no clean unit-disk graph, and is refused (LIB_MARGIN). There’s no embedder for arbitrary graphs: a graph is either a lattice family with a filling mask, or the unit-disk graph of given positions.

Graph

An undirected simple graph on vertices 0..n-1 (vertex i is atom i).

from_positions

The unit-disk graph of atoms at these (x, y) positions, µm: an edge where \(V \ge 2.5\,\Omega\).

kings

A rows x cols square grid whose graph joins each site to its eight neighbours (diagonals included), with the sites of filling occupied.

square

A rows x cols square grid whose graph joins nearest neighbours.

triangular

Rows of cols sites, odd rows shifted by half a spacing, whose graph joins each site to its six nearest neighbours.

EDGE

NON_EDGE

Classes

class cosmiq.library.graphs.Graph(n: int, edges: Iterable[tuple[int, int]] = ())

Bases: object

An undirected simple graph on vertices 0..n-1 (vertex i is atom i).

property n: int
property edges: tuple[tuple[int, int], ...]

Every edge once, as (i, j) with i < j, sorted.

property adjacency: NDArray[bool]

The [n, n] read-only adjacency matrix.

degrees() → NDArray[int64]

Each vertex’s number of neighbours.

neighbours(i: int) → tuple[int, ...]
independent(bits: object) → NDArray[bool]

Per shot: no two chosen vertices share an edge. bits as mis.postprocess takes.

maximal(bits: object) → NDArray[bool]

Per shot: independent, and no vertex can be added.

__len__() → int

Functions

cosmiq.library.graphs.from_positions(positions: Sequence[Sequence[float]] | NDArray[floating[Any]] | Tensor, *, device: str | DeviceSpec = 'cosmiq-ref-1', omega: float | None = None) → tuple[Register, Graph]#

The unit-disk graph of atoms at these (x, y) positions, µm: an edge where \(V \ge 2.5\,\Omega\). Positions are rounded onto the device’s grid first. A pair with \(0.5\,\Omega < V < 2.5\,\Omega\) is refused (LIB_MARGIN): its graph would depend on more than the blockade.

cosmiq.library.graphs.kings(rows: int, cols: int, *, spacing: float | None = None, filling: object = None, device: str | DeviceSpec = 'cosmiq-ref-1', omega: float | None = None) → tuple[Register, Graph]#

A rows x cols square grid whose graph joins each site to its eight neighbours (diagonals included), with the sites of filling occupied. See square.

cosmiq.library.graphs.square(rows: int, cols: int, *, spacing: float | None = None, filling: object = None, device: str | DeviceSpec = 'cosmiq-ref-1', omega: float | None = None) → tuple[Register, Graph]#

A rows x cols square grid whose graph joins nearest neighbours.

  • filling: a [rows, cols] bool mask of the occupied sites (all by default). Atom \(k\) is the \(k\)-th occupied site, row by row; the lattice is centred on the origin whatever the mask.

  • spacing: µm; by default the middle of the window where the margins hold, on twice the device’s position grid.

  • omega: the drive’s \(\Omega\) in rad/µs; by default the device’s largest \(\Omega\) on its grid.

Positions are rounded onto the device’s grid, and every pair is checked there: an edge needs \(V \ge 2.5\,\Omega\) and a non-edge \(V \le 0.5\,\Omega\) (LIB_MARGIN). The device’s own register rules are checked when a program is targeted.

cosmiq.library.graphs.triangular(rows: int, cols: int, *, spacing: float | None = None, filling: object = None, device: str | DeviceSpec = 'cosmiq-ref-1', omega: float | None = None) → tuple[Register, Graph]#

Rows of cols sites, odd rows shifted by half a spacing, whose graph joins each site to its six nearest neighbours. See square.

Values

cosmiq.library.graphs.EDGE = 2.5#
cosmiq.library.graphs.NON_EDGE = 0.5#