How can I derive the joint distribution for this Markov network? I am reading Bayesian Reasoning And Machine Learning and I'm not sure how to do exercise 4.6 on p.80.
The undirected graph:

represents a Markov network with nodes $x1, x2, x3, x4, x5$, counting
clockwise around the pentagon with potentials $\phi(x_i,x_j)$. Show that the joint distribution can be written as $$p(x_1,x_2,x_3,x_4,x_5)=\frac{p(x_1,x_2,x_5)p(x_2,x_4,x_5)p(x_2,x_3,x_4)}{p(x_2,x_5)p(x_2,x_4)}$$
What I have tried so far:
We have that
\begin{align}
\frac{p(x_1,x_2,x_5)p(x_2,x_4,x_5)p(x_2,x_3,x_4)}{p(x_2,x_5)p(x_2,x_4)} &= \frac{p(x_1|x_2,x_5)p(x_2,x_5))p(x_5|x_2,x_4)p(x_2,x_4)p(x_2|x_3,x_4)p(x_3|x_4)p(x_4)}{p(x_2,x_5)p(x_2,x_4)} \\
&=p(x_1|x_2,x_5)p(x_5|x_4)p(x_2|x_4)p(x_3|x_4)p(x_4) \\
&=p(x_1|x_2,x_5)\phi(x_4,x_5)\phi(x_2,x_3)\phi(x_3,x_4)p(x_4)
\end{align}
I'm not sure how to factorize it any further. Could anyone please help?

The conditional independencies induced by this Markov network are
$$
x_1 \perp x_3,x_4 \mid x_2,x_5 \\
x_2 \perp x_4,x_5 \mid x_1,x_3 \\
x_3 \perp x_5,x_1 \mid x_2,x_4 \\
x_4 \perp x_1,x_2 \mid x_3,x_5 \\
x_5 \perp x_2,x_3 \mid x_1,x_4
$$
Using the chain rule, the joint distribution can be written as
$$
p(x_1,x_2,x_3,x_4,x_5) = p(x_1 \mid x_2,x_3,x_4,x_5) \cdot p(x_3 \mid x_2,x_4,x_5) \cdot p(x_2,x_4,x_5)
$$
Apply the conditional independencies derived above such that
$$
p(x_1 \mid x_2,x_3,x_4,x_5) = p(x_1 \mid x_2,x_5) \\
p(x_3 \mid x_2,x_4,x_5) = p(x_3 \mid x_2,x_4)
$$
So,
$$
p(x_1,x_2,x_3,x_4,x_5) = p(x_1 \mid x_2,x_5) \cdot p(x_3 \mid x_2,x_4) \cdot p(x_2,x_4,x_5)
$$
Using Bayes' rule,
\begin{align}
p(x_1,x_2,x_3,x_4,x_5) &= \frac{p(x_1,x_2,x_5)}{p(x_2,x_5)} \cdot \frac{p(x_3,x_2,x_4)}{p(x_2,x_4)} \cdot p(x_2,x_4,x_5) \\
&= \frac{p(x_1,x_2,x_5) \cdot p(x_3,x_2,x_4) \cdot p(x_2,x_4,x_5)}{p(x_2,x_5) \cdot p(x_2,x_4)}
\end{align}
which is the desired result.
