Minimum-Weight Perfect Matching Decoder
The original surface-code decoder, from Dennis, Kitaev, Landahl and Preskill (2002). Each data qubit is an edge of the matching graph and each stabilizer is a node. An error chain flips the stabilizers at its two ends, so the syndrome appears as a sparse set of defects sitting at the endpoints of invisible chains. The decoder's job is to guess a chain set with the same endpoints: it builds a weighted graph on the defects (weight = lattice distance), then finds the minimum-weight perfect matching, the pairing of least total length. Because a chain may also terminate on a boundary, every defect additionally gets the option of matching to the nearest boundary. Watch every distance, every candidate pairing and every correction path get drawn, step by step.