We now return to the calculation of the matching graph weights (Step 2 in alg:decoder).
The first step is to construct a decoding graph based on the RHG lattice.
For the sake of brevity, we will describe this construction for an RHG lattice with periodic boundary conditions (see [1]} for the case of lattices with boundaries).
We refer to the elements of the decoding graph as vertices and arcs, to avoid confusion with the nodes and edges of the RHG lattice.
The decoding graph has a vertex for each six-body \(X\)  stabilizer acting on the primal qubits of the RHG lattice. These stabilizers are formed from products of cluster state stabilizers surrounding a dual cell.
Vertices are connected by arcs if their corresponding stabilizers share a qubit.
As each qubit is in the support of two such stabilizers, the arcs of the decoding graph are in a one-to-one correspondence with the primal qubits of the RHG lattice, and hence with a subset of the modes of the cluster state.
We assign weights to the arcs of the decoding graph as follows.
Consider the mode \(q\)  corresponding to an arc in the decoding graph.
Let \(m\)  be the number of swapped-out modes neighboring \(q\)  and let \(z\)  be the outcome of the homodyne measurement of \(q\) . We assign to this mode a heuristic error probability as follows:
\(w(z, m, \tilde{\delta }) ={\left\lbrace \begin{array}{ll}2/5 & \mbox{if } m = 4, \\1/3 & \mbox{if } m = 3, \\1/4 & \mbox{if } m = 2, \\\frac{\sum _{n \in \mathbb {Z}} \exp [-(z-(2n+1)\sqrt{\pi })^2/\tilde{\delta }]}{\sum _{n \in \mathbb {Z}} \exp [-(z-n\sqrt{\pi })^2/\tilde{\delta }]} & \mbox{if } m \le 1.\end{array}\right.}\) 
