<p>The short answer: for a nxn grid, the complexity is at least exponential n.</p>

<p>A junction tree is created from the induced graph of the MRF, which depends on the elimination order (which variables you eliminate first to calculate a marginal). The elimination cost is exponential in the size of the largest clique in the induced graph. See <a href="https://arxiv.org/pdf/1506.08544.pdf" rel="nofollow noreferrer">this</a> paper for details.</p>

<p>So even though we can use exact inference on the junction tree, the complexity would be exponential in size of the largest clique in the induced graph of the elimination order that was used.</p>

<p>The best possible elimination order will yield a largest clique size equal to the tree width, which is n for a nxn grid. But there are no efficient algorithms for finding it.</p>
why is the exact inference of the MRF in the grid graph impossible
<p>The question is as written in the title</p>

<p><a href="https://i.stack.imgur.com/o9MZd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o9MZd.png" alt="enter image description here"></a></p>

<p>There is a 3x3 grid graph at the above image. We can convert it into junction tree. Then it is possible to use message-passing(product-sum algorithm) for the inference(estimating likelihood/posterior etc). So I wonder why the exact inference in the grid graph is so hard?</p>

<p>Is it impossible to find such a junction tree when the grid goes larger?</p>