@Test
public void testFullExample1() {

    // from "Bayesian Belief Network Propagation Engine In Java"
    // the result here is slightly different, due to ordering, but it's still correct.
    // http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.135.7921&rep=rep1&type=pdf
    Graph<BayesVariable> graph = new BayesNetwork();
    GraphNode xa = addNode(graph);
    GraphNode xb = addNode(graph);
    GraphNode xc = addNode(graph);
    GraphNode xd = addNode(graph);
    GraphNode xe = addNode(graph);
    GraphNode xf = addNode(graph);
    GraphNode xg = addNode(graph);
    GraphNode xh = addNode(graph);
    connectParentToChildren(xa, xb, xc);
    connectParentToChildren(xb, xd);
    connectParentToChildren(xc, xe, xg);
    connectParentToChildren(xd, xf);
    connectParentToChildren(xe, xf, xh);
    connectParentToChildren(xg, xh);
    OpenBitSet clique1 = bitSet("00111000"); // d, e, f
    OpenBitSet clique2 = bitSet("00011100"); // c, d, e
    OpenBitSet clique3 = bitSet("01010100"); // c, e, g
    OpenBitSet clique4 = bitSet("11010000"); // e, g, h
    OpenBitSet clique5 = bitSet("00001110"); // b, c, d
    OpenBitSet clique6 = bitSet("00000111"); // a, b, c
    OpenBitSet clique1And2 = bitSet("00011000"); // d, e
    OpenBitSet clique2And3 = bitSet("00010100"); // c, e
    OpenBitSet clique2And5 = bitSet("00001100"); // c, d
    OpenBitSet clique3And4 = bitSet("01010000"); // e, g
    OpenBitSet clique5And6 = bitSet("00000110"); // b, c
    // clique1
    JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph );
    JunctionTreeClique root = jtBuilder.build(false).getRoot();
    assertEquals( clique1, root.getBitSet() );
    assertEquals(1, root.getChildren().size());
    // clique2
    JunctionTreeSeparator sep =  root.getChildren().get(0);
    assertEquals( clique1And2, sep.getBitSet() );
    JunctionTreeClique jtNode2 = sep.getChild();
    assertEquals( clique1, sep.getParent().getBitSet() );
    assertEquals( clique2, jtNode2.getBitSet() );
    assertEquals(2, jtNode2.getChildren().size());
    // clique3
    sep =  jtNode2.getChildren().get(0);
    assertEquals( clique2And3, sep.getBitSet() );
    JunctionTreeClique jtNode3 =sep.getChild();
    assertEquals( clique2, sep.getParent().getBitSet() );
    assertEquals( clique3, jtNode3.getBitSet() );
    assertEquals( 1, jtNode3.getChildren().size());
    // clique4
    sep =  jtNode3.getChildren().get(0);
    assertEquals( clique3And4, sep.getBitSet() );
    JunctionTreeClique jtNode4 = sep.getChild();
    assertEquals( clique3, sep.getParent().getBitSet() );
    assertEquals( clique4, jtNode4.getBitSet() );
    assertEquals( 0, jtNode4.getChildren().size());
    // clique5
    sep =  jtNode2.getChildren().get(1);
    assertEquals( clique2And5, sep.getBitSet() );
    JunctionTreeClique jtNode5 = sep.getChild();
    assertEquals( clique2, sep.getParent().getBitSet() );
    assertEquals( clique5, jtNode5.getBitSet() );
    assertEquals( 1, jtNode5.getChildren().size());
    //clique 6
    sep =  jtNode5.getChildren().get(0);
    assertEquals( clique5And6, sep.getBitSet() );
    JunctionTreeClique jtNode6 = sep.getChild();
    assertEquals( clique5, sep.getParent().getBitSet() );
    assertEquals( clique6, jtNode6.getBitSet() );
    assertEquals( 0, jtNode6.getChildren().size());
}