MAP Inference for factor graph

@ppletscher, @iglesias, @vigsterkr: this is the framework of MAP inference, tree max product will come in next PR, which runs good. 

@iglesias, I hope the clone error fixed now.