-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not independent edges in matching #104
Comments
Hi @gbtami thanks for raising this, it highlights a lack of documentation that would be useful for users interested in related graph theory problems outside of quantum error correction. In fact I've been meaning to add extra examples and documentation for this for a while (see issues #46 and #61) so I'll provide quite a long answer, which I'll modify and add into the documentation (without your specific example) soon if it is clear enough. I'll explain the problem pymatching solves in the language of graph theory instead of error correction and then explain how you can use pymatching to solve your minimum-weight perfect matching problem. Please let me know if anything you need is unclear. If you just want a fix to your problem you can copy the code at the bottom. Minimum-weight T-joinsPyMatching doesn't actually solve exactly the minimum-weight perfect matching (MWPM) problem, but instead a closely related problem known as the minimum-weight T-join problem (MWTJ) in graph theory (which we call the minimum-weight embedded matching problem in our paper). The MWTJ problem is defined as follows. Let So the following function finds a minimum-weight T-join using pymatching:
There are two small differences here to the normal MWTJ problem. Firstly, pymatching also allows boundary edges (or "half edges") to be added to the graph. In contrast to an edge Importantly, even if you set Reduction from min-weight T-joins to min-weight perfect matchingsIt turns out that if you have an efficient algorithm for the MWPM problem (i.e. the blossom algorithm) you can use it to find a MWTJ (first shown in this paper). Furthermore, if you have an efficient algorithm for the MWTJ problem (i.e. pymatching) then it can be used to find a MWPM (which is what you need). For this reduction we will assume that the matching graph contains only edges, and no boundary edges. If this is the case, then any perfect matching will contain exactly On the other hand, the MWTJ problem can have more than However, this approach adds a very large constant Note that pymatching is optimised to be fast when solving the MWTJ problem for the types of problems that arise in quantum error correction: these are usually sparse graphs where the set Code for solving a MWPM problem using pymatchingBelow is some code for solving your MWPM problem which gives the correct solution, consistent with NetworkX.
and running this provides the correct solution to your problem:
|
I'm sorry to not find the mentioned related issues myself, but the quantum error correction jargon usage made me careless :) |
Excellent! And nice to see a chess application of pymatching :) |
Unfortunately this paper is not available public to anyone. |
@gbtami What are you talking about? The sparse blossom paper is on the arXiv, free for anyone to read (including no signup step): https://arxiv.org/abs/2303.15933 . This is very standard in quantum computing. |
You are right. I'm totally blind. Sry :) |
First of all I have to say I know nothing about decoding quantum error correcting (QEC) codes. So maybe I completely misuse this lib.
I tried to compare how performant PyMatching decode_to_edges_array() is compared to networkx min_weight_matching() and find sometimes it creates invalid matching edge sets.
I expected max 5 edges without any common nodes.
What am I misunderstanding here?
The text was updated successfully, but these errors were encountered: