# Drawing a bayesian network and then converting to a factor graph to implement max-product algorithm

I'm trying to understand the fully worked example 5.2 in "Bayesian Reasoning and Machine Learning" by David Barber. Frustratingly the explanations around the example are all about potentials and factor graphs but the example itself is probability based. To make sure I've understood the theory I'm therefore trying to convert the problem to a factor graph representation. I have two problems at the moment:

1) Converting the probability p(a,b,c)=p(a|b)p(b|c)p(c) into the corresponding bayesian graph.
2) Converting the bayesian graph to a factor graph with potential nodes in the correct place.

For 1 I believe the following is correct but not sure:

For 2 I think the following is correct:

I'm not sure on the latter though if the 'c' variable node should have another single function node on it U3(c). If it shouldn't under what circumstances can that occur.

Thanks

1. The directed graph you drew is in fact consistent with the factorization $$p(a,b,c)=p(a|b)p(b|c)p(c)$$. The only requirement is that the variables on the right-hand side of the conditional probabilities ($$b$$ and $$c$$) appear as parents of the variables on the left-hand side ($$a$$ and $$b$$, respectively).
2. Your factor graph is also correct. It would have been acceptable to include a separate potential whose scope is just $$c$$, but this is not necessary. In your case, this is already covered by the factor product $$U_2(b,c) = p(b|c)p(c)$$.