flamingpy.codes.RHG_graph

flamingpy.codes.RHG_graph(dims: Union[int, Tuple[int, int, int], List, numpy.ndarray], boundaries='primal', polarity=None)[source]

Return an EGraph of a dims-dimensional RHG lattice.

Generate a Raussendorf-Harrington-Goyal (RHG) lattice, which can be viewed as the measurement-based version or foliation of the surface code, with specified dimensions and boundary types.

Parameters
  • dims (int or Sequence[int]) – the dimensions of the lattice. If int, generates a cube corresponding to a code of distance dims. If a sequence (dx, dy, dz), assumes distances dx, dy, dz in x, y, z directions, respectively. For axes with open boundaries, the corresponding distance should be greater than 1.

  • boundaries (str or list-type, optional) –

    the boundary types in x, y, z. We use the identification primal = smooth and dual = rough, to align with surface code terminology. Available choices in the order x, y, z are:

    ’open_primal’: [primal, dual, primal] ‘open_dual’: [primal, dual, dual] ‘primal’: [primal, primal, primal] ‘dual’: [dual, dual, dual] ‘periodic’: [periodic, periodic, periodic] ‘periodic_primal’: [periodic, periodic, primal] ‘periodic_dual’: [periodic, periodic, dual] ‘{b}’: b, b, b, [‘{b1}’, ‘{b2}’, ‘{b3}’]: b1, b2, b3,

    where each b above can be ‘primal’, ‘dual’, or ‘periodic’. By default, ‘primal’ is used (i.e. [‘primal’, ‘primal’, ‘primal’]).

  • polarity (func) –

    a function that specifies edge weights. It must be of the following form:

    polarity(edge) = weight.

    If not supplied, assumes all edges have weight 1.

Returns

the RHG lattice.

Return type

EGraph

Contents

Home

Background

Using FlamingPy

Development

Getting Help

Python API