In the module matching.py of PyMatching, it is possible to construct Matching objects to decode matching graphs using the minimum-weight perfect matching decoder. The decode() method returns the most probable correction and "The sum of the weights of the edges in the minimum-weight perfect matching".

Is it possible to get the matched nodes of the graph ?


1 Answer 1


Currently you are correct that PyMatching outputs the edges in the solution, but not the pairs of detection events. You can find a valid pairing of in Python by tracing the paths between detection events using the edges in the solution, but I agree it would be nicer if a fast method for this was already provided in the API. This is a nice feature I'd like to add at some point, and I've just opened an issue for it on GitHub: https://github.com/oscarhiggott/PyMatching/issues/34

  • 2
    $\begingroup$ Update: Version 2.0 of PyMatching does now include pymatching.Matching.decode_to_matched_dets_array and pymatching.Matching.decode_to_matched_dets_dict methods, which output pairs of matched detection events in the solution: github.com/oscarhiggott/PyMatching/releases/tag/v2.0.0 $\endgroup$ Commented Oct 26, 2022 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.