neuralqx.graph.grid_2d module

class Grid2D(m, n, periodic=False, *, plot=False, non_planar=False, random_embedding=False, random_embedding_mean=0.0, random_embedding_std=5.0, random_embedding_seed=123)

Bases: Graph

Two-dimensional rectangular grid graph \(P_m \,\square\, P_n\), optionally periodic.

For periodic=False, the graph is the Cartesian product of two path graphs, giving the usual \(m\times n\) rectangular lattice. For periodic=True, periodic boundary conditions are applied in both directions, yielding a torus graph \(C_m \,\square\, C_n\).

When non-periodic:

\[|V| = mn,\qquad |E| = m(n-1) + (m-1)n.\]

When periodic:

\[|V| = mn,\qquad |E| = 2mn.\]

The NetworkX generator uses 2D lattice coordinates internally; these are relabelled to consecutive integers before constructing Graph. If non_planar=True, vertices are relabelled to 3-tuples and may be given a random spatial embedding.

Parameters:
  • m (int) – Number of rows.

  • n (int) – Number of columns.

  • periodic (bool) – If True, impose periodic boundary conditions in both directions.

  • plot (bool) – If True, produce a visualisation via the base graph machinery.

  • non_planar (bool) – If True, relabel vertices to 3-tuples to trigger the non-planar pipeline.

  • random_embedding (bool) – If True, assign a random 3D embedding to vertices (non-planar only).

  • random_embedding_mean (float) – Mean of the Gaussian used for the random embedding.

  • random_embedding_std (float) – Standard deviation of the Gaussian used for the random embedding.

  • random_embedding_seed (int) – Seed controlling the random embedding.

property m
property n
property periodic