@Test
public void testIterativeEliminationUsingEdgeAndWeight() {
Graph<BayesVariable> graph = new BayesNetwork();
GraphNode x0 = addNode(graph);
GraphNode x1 = addNode(graph);
GraphNode x2 = addNode(graph);
GraphNode x3 = addNode(graph);
GraphNode x4 = addNode(graph);
GraphNode x5 = addNode(graph);
GraphNode x6 = addNode(graph);
// *
// / | \
// * | *
// | | |
// * | *
// \ /
// *
connectParentToChildren(x1, x2);
connectParentToChildren(x1, x3);
connectParentToChildren(x1, x6);
connectParentToChildren(x2, x4);
connectParentToChildren(x3, x5);
connectParentToChildren(x4, x6);
connectParentToChildren(x5, x6);
// need to ensure x5 followed by x4 are removed first
x1.setContent(new BayesVariable<String>("x1", x0.getId(), new String[]{"a", "b", "c", "d", "e", "f"}, new double[][]{{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}}));
x2.setContent(new BayesVariable<String>("x2", x0.getId(), new String[]{"a", "b"}, new double[][]{{0.1, 0.1}}));
x3.setContent(new BayesVariable<String>("x3", x0.getId(), new String[]{"a", "b"}, new double[][]{{0.1, 0.1}}));
x4.setContent(new BayesVariable<String>("x4", x0.getId(), new String[]{"a", "b"}, new double[][]{{0.1, 0.1}}));
x5.setContent(new BayesVariable<String>("x5", x0.getId(), new String[]{"a"}, new double[][]{{0.1 }}));
x6.setContent(new BayesVariable<String>("x6", x0.getId(), new String[]{"a", "b"}, new double[][]{{0.1, 0.1}}));
JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph );
//jtBuilder.moralize(); // don't moralize, as we want to force a simpler construction for vertex elimination order and updates