Solution (source code)

= Solution

Let $o(\omega)$ be the number of open <edges>, $k(\omega)$ the number of connected components in the open subgraph, counting isolated vertices, and $m=|E|$. Summing the joint weight over <spins> requires a constant <spin> on every open component. There are exactly $q^{k(\omega)}$ choices. Thus the <edge> marginal is
$$
\boxed{\phi_{p,q}(\omega)=\frac1{Z_{\rm RC}}p^{o(\omega)}(1-p)^{m-o(\omega)}q^{k(\omega)}}.
$$
This is the <random-cluster measure>, and the joint normalizing constant is $Z_{\rm RC}$.

Summing instead over <edge> configurations factors independently over <edges>. For a fixed <spin> configuration the resulting weight is
$$
\prod_{\{x,y\}\in E}\left[(1-p)+p\mathbf1_{\sigma_x=\sigma_y}\right]
=e^{-\beta m}\exp\left(\beta\sum_{\{x,y\}\in E}\mathbf1_{\sigma_x=\sigma_y}\right),
$$
since $1-p=e^{-\beta}$. The factor $e^{-\beta m}$ is independent of the <spins>. Hence the <spin> marginal is exactly the ferromagnetic <Potts measure> in the convention
$$
\boxed{\pi_{\beta,q}(\sigma)=\frac1{Z_{\rm P}}\exp\left(\beta\sum_{\{x,y\}\in E}\mathbf1_{\sigma_x=\sigma_y}\right),\qquad p=1-e^{-\beta}}.
$$
Its <partition function> satisfies $Z_{\rm RC}=e^{-\beta m}Z_{\rm P}$.

Conditionally on $\sigma$, <edge> states are independent: an <edge> with different endpoint <spins> is closed with <probability> one, while one with equal endpoint <spins> is open with <probability> $p$. Conditionally on $\omega$, color its $k(\omega)$ open components independently and uniformly from $\{1,\ldots,q\}$. Equivalently, every compatible <spin> configuration has <conditional probability> $q^{-k(\omega)}$, and all incompatible configurations have <probability> zero. These are the two conditional laws of the <Edwards-Sokal coupling>.

If $x,y$ belong to the same open component, their colors agree surely; otherwise the two independent component colors agree with <probability> $1/q$. Therefore
$$
\pi_{\beta,q}(\sigma_x=\sigma_y)
=\phi_{p,q}(x\leftrightarrow y)+\frac1q\left(1-\phi_{p,q}(x\leftrightarrow y)\right).
$$
Rearranging proves the <spin-connectivity identity for the Potts model>:
$$
\boxed{\left(1-\frac1q\right)\phi_{p,q}(x\leftrightarrow y)
=\pi_{\beta,q}(\sigma_x=\sigma_y)-\frac1q}.
$$

<Phase transitions> refer to infinite-volume limits, not a single finite graph. The identity shows that connectivity is exactly the excess <spin> agreement above its independent-color baseline. More directly, use a wired <random-cluster boundary condition> and fix the corresponding boundary <spin> to color $1$. Its component has color $1$, while every finite component has a uniform color. In the compatible infinite-volume <coupling>,
$$
\pi^1_{\beta,q}(\sigma_0=1)
=\frac1q+\left(1-\frac1q\right)\phi^{\rm w}_{p,q}(0\leftrightarrow\infty).
$$
Consequently normalized <spontaneous magnetization> is
$$
\boxed{M(\beta)=\frac{q\pi^1_{\beta,q}(\sigma_0=1)-1}{q-1}
=\theta^{\rm w}(p,q)}.
$$
The onset of a wired infinite cluster and the onset of <spontaneous magnetization> in the <Potts model> are the same transition under $p=1-e^{-\beta}$, giving $\beta_c(q)=-\log(1-p_c(q))$. This also transfers any jump or continuity of that order parameter between the two descriptions; it makes no assumption about behavior exactly at the critical point.