# Compute the Gibbs energy

I have a question about Gibbs distribution in Stochastic theory. In which, it defined a clique as a a subset $C$ in the whole image $\Omega$ if two different element of $C$ are neighbors. Figure 2 gives the $2^{nd}$ order of neighborhood and all the available cliques in this 8-element neighboring system.

For computational efficiency, the 2nd-order clique is used, which contains an 8-element neighborhood. According to the MRF-GRF equivalence described by Hammersley-Clifford theorem, the Gibbs potential value is defined as: $$V_c(x_i) = \begin{cases} \beta, & \text{if x_i=x_j, x_j is neighbor of x_i} \\ -\beta, & \text{if x_i \not=x_j } \end{cases}$$ where $\beta$ is positive.

$U(x)$ is an energy function of the form $$U(x)=\sum_{c \in C}V_c(x)$$ which is a sum of clique potentials $V_c(x)$ over all possible cliques $C$.My question is how to compute $U(x=1)$ and $U(x=2)$ at position D6, H3 and F9 based on above definition. Thank you for your help.

This is input

As my reference paper, the results are

$$D6: U(x=1)=0; U(x=2)=0$$ $$H3: U(x=1)=-8\beta; U(x=2)=8\beta$$ $$F9: U(x=1)=-8\beta; U(x=2)=8\beta$$