The max-product form of belief propagation replaces summation by maximization. On a tree, storing maximizing states while passing messages and then backtracking gives an exact maximum a posteriori estimate.
Writing , the edge term rewards neighboring computers having the same infection state, as in a ferromagnetic Ising model, while expresses a mild prior preference for the rarer uninfected state. Thus the prior encodes local transmission over the network without assuming independent infections.
The observation likelihood is
Consequently the posterior distribution is
This remains a binary pairwise Markov random field on a tree. To find its maximum a posteriori estimate, run max-product belief propagation: send a two-entry message in each direction along every edge, then backtrack from the maximizing root state. Each message examines four state pairs, and the maximum degree is bounded, so the total cost is
Let and regard as the latent variable. At iteration , the E-step forms
The M-step updates
This is the expectation-maximization algorithm for the posterior objective: including in the complete-data log density makes the maximizer a maximum a posteriori estimate rather than a maximum-likelihood estimate.