Suppose I have a graph $G$ with $M(G)$ the (unknown) set of perfect matchings of $G$. Suppose this set is non-empty, then how difficult is it to sample uniformly at random from $M(G)$? What if I am okay with a distribution that is close to uniform, but not quite uniform, then is there an efficient algorithm?
2 Answers
There is a classical paper of Jerrum and Sinclair (1989) on sampling perfect matchings from dense graphs. Another classical paper of Jerrum, Sinclair and Vigoda (2004; pdf) discusses sampling perfect matchings from bipartite graphs.
Both these papers uses rapidly mixing Markov chains, and so the samples are only almost uniform. I imagine that uniform sampling is difficult.
- 4,872
- 2
- 28
- 57
- 280,205
- 27
- 317
- 514
If you assume that your graph is planar, then there is a polynomial time procedure for this sampling problem.
First, the problem of counting the number of perfect matchings is in P for planar graphs. ( https://en.wikipedia.org/wiki/FKT_algorithm ) ( A good exposition of this fact can be found in the first chapter of Jerrum's book on Counting, Sampling and Integrating.)
Next, for each edge $e$ of $G$, count the number of perfect matchings of $G \setminus e$. This can be turned into the probability that a uniform perfect matching contains $e$ - just divide by the number of perfect matchings in $G$. Sample an edge according to this probability, and continue inductively.
(This is taking advantage of the fact that matchings are a "self-reducible" structure, so counting problems and uniform sampling problems are essentially the same. You can see JVV "Random Generation of Combinatorial Structures from a Uniform Distribution" for more on this point of view.)
A simple proof that this gives the correct distribution:
Let $c(H)$ denote the number of ordered perfect matchings in a graph $H$, as ordered sequences. (Which is $n!$ times the number of unordered perfect matchings, $n = H/2$.)
Let $e_1, \ldots, e_n$ the sequence of edges chosen in this procedure. Since each step was independent of the former, the probability of choosing this sequence of edges is:
$\frac{ c(G \setminus e_1)}{c(G)} \frac{ c(G \setminus \{e_1, e_2\} )}{c(G \setminus e_1)} \ldots \frac{ c(G \setminus \{e_1, \ldots, e_{n-1} \}) }{c(G \setminus \{ e_1, \ldots, e_{n-2} \} )}$.
Note that $c(G \setminus \{e_1, \ldots, e_{n-1} \}) = 1$, since $G \setminus \{e_1, \ldots, e_{n-1} \}$ is just the edge $e_n$. So this product telescopes and leaves $1 / c(G)$.
- 384
- 1
- 12