public JunctionTree build() {
        return build(true);
    }
@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();
        assertThat(root.getBitSet()).isEqualTo(clique1);
        assertThat(root.getChildren().size()).isEqualTo(1);

        // clique2
        JunctionTreeSeparator sep =  root.getChildren().get(0);
        assertThat(sep.getBitSet()).isEqualTo(clique1And2);
        JunctionTreeClique jtNode2 = sep.getChild();
        assertThat(sep.getParent().getBitSet()).isEqualTo(clique1);
        assertThat(jtNode2.getBitSet()).isEqualTo(clique2);
        assertThat(jtNode2.getChildren().size()).isEqualTo(2);

        // clique3
        sep =  jtNode2.getChildren().get(0);
        assertThat(sep.getBitSet()).isEqualTo(clique2And3);
        JunctionTreeClique jtNode3 =sep.getChild();
        assertThat(sep.getParent().getBitSet()).isEqualTo(clique2);
        assertThat(jtNode3.getBitSet()).isEqualTo(clique3);
        assertThat(jtNode3.getChildren().size()).isEqualTo(1);

        // clique4
        sep =  jtNode3.getChildren().get(0);
        assertThat(sep.getBitSet()).isEqualTo(clique3And4);
        JunctionTreeClique jtNode4 = sep.getChild();
        assertThat(sep.getParent().getBitSet()).isEqualTo(clique3);
        assertThat(jtNode4.getBitSet()).isEqualTo(clique4);
        assertThat(jtNode4.getChildren().size()).isEqualTo(0);

        // clique5
        sep =  jtNode2.getChildren().get(1);
        assertThat(sep.getBitSet()).isEqualTo(clique2And5);
        JunctionTreeClique jtNode5 = sep.getChild();
        assertThat(sep.getParent().getBitSet()).isEqualTo(clique2);
        assertThat(jtNode5.getBitSet()).isEqualTo(clique5);
        assertThat(jtNode5.getChildren().size()).isEqualTo(1);

        //clique 6
        sep =  jtNode5.getChildren().get(0);
        assertThat(sep.getBitSet()).isEqualTo(clique5And6);
        JunctionTreeClique jtNode6 = sep.getChild();
        assertThat(sep.getParent().getBitSet()).isEqualTo(clique5);
        assertThat(jtNode6.getBitSet()).isEqualTo(clique6);
        assertThat(jtNode6.getChildren().size()).isEqualTo(0);
    }