Finding perfect matchings

64 Views Asked by At

Given a connected graph $G$, do you have an idea how to calculate the amount of perfect matchings this graph has (given at least one exists)? I dont worry about the calculation being efficient in any way, which I also can not expect at all.

I guess an idea would be to brute-force find all individual perfect matchings, but how to get even one for a graph we have almost no information about? I am also wondering if there maybe is an approximation algorithm for this problem, but i could not find any.

2

There are 2 best solutions below

0
On BEST ANSWER

Finding perfect matchings is a special case of exact covering problem. In general, we have a set $V$ and a collection $S$ of subsets (in your case, edges) and need to find a subcollection $S'$, $S'\subseteq S$, (in your case, a perfect matching) such that every element of $V$ is in exactly one subset from $S'$. All solutions can be found with Knuth's Algorithm X. To solve exact covering, I usually use SAGE exact cover solver or the libexact library for C/C++ (libexact can also solve multiple covering).

0
On

If your graph is planar you can implement the FKT Algorithm which runs in polynomial time. Notice that Knuth's algorithm X is non deterministic and may take exponential time.