beats junction tree AND LBP for n=1000, tree
added Mooij code