max product inference for factor graph model

@ppletscher, @iglesias, @vigsterkr: this PR implements the max product inference for tree graph.