# Graph-cut and pairwise MRF

I try to use graph-cut method but I got some trouble with it. I want to segment an image into foreground and background. For each pixel $$x$$, I got the probability that it belongs to the background $$p(x|\phi_b)$$ and to the foreground $$p(x|\phi_f)$$ by kernel density estimation (KDE). Here is the log-posterior :

$$\log p(\mathcal{L}|x) = \left( \sum^N_{i=1} \sum^N_{j=1} \lambda(l_il_j + (1-l_i)(1-l_j)) \right) + \sum^N_{i=1} \log\left( \frac{p(x_i|\phi_f)}{p(x_i|\phi_b)} \right) l_i$$

where $$\mathcal{L} = [l_1...L_N]$$, $$N$$ is the number of pixel in the image.

If I understand, the first term is the pairwise cost, for smoothness and determine the weight on edges between a pixel and its neighbors. According to the equation, I put lambda as a weight on each edges.

The second term is the unary cost and determine the weight on edges between a pixel and the source and the sink. Here, the weight between a pixel and the source is the same that between the pixel and the sink ? Am I right ?

Thanks