Solution (source code)

= Solution

For a finite graph $G=(V,E)$, the $q=2$ <random-cluster model> is
$$
\phi_{p,2}(\omega)=\frac1Z
p^{o(\omega)}(1-p)^{|E|-o(\omega)}2^{k(\omega)},
$$
where $o(\omega)$ is the number of open edges and $k(\omega)$ the number of open connected components. In the <Edwards-Sokal coupling>, first sample $\omega$, assign an independent uniform spin $\pm1$ to each open cluster, and give every vertex its cluster's spin. The resulting spin law is the <Ising model> with
$$
p=1-e^{-2\beta}.
$$
Conversely, from an Ising configuration, close every edge joining unequal spins and independently open each edge joining equal spins with probability $p$.