public void mapVarNodeToCliques(OpenBitSet[] nodeToCliques, int id, OpenBitSet clique) {
        for ( int i = clique.nextSetBit(0); i >= 0; i = clique.nextSetBit( i + 1 ) ) {
             OpenBitSet cliques = nodeToCliques[i];
            if ( cliques == null ) {
                cliques = new OpenBitSet();
                nodeToCliques[i] = cliques;
            }
            cliques.set(id);
        }
    }
@Test
    public void testMapNodeToCliques() {
        Graph<BayesVariable> graph = new BayesNetwork();
        JunctionTreeBuilder tbuilder = new JunctionTreeBuilder(graph);

        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);
        GraphNode x7 = addNode(graph);

        OpenBitSet clique0 = bitSet("01010101");
        OpenBitSet clique1 = bitSet("10010001");
        OpenBitSet clique2 = bitSet("10111010");

        OpenBitSet[] nodeToCliques = new OpenBitSet[8];
        tbuilder.mapVarNodeToCliques(nodeToCliques, 0, clique0);
        tbuilder.mapVarNodeToCliques(nodeToCliques, 1, clique1);
        tbuilder.mapVarNodeToCliques(nodeToCliques, 2, clique2);

        assertThat(nodeToCliques[0]).isEqualTo(bitSet("011"));
        assertThat(nodeToCliques[1]).isEqualTo(bitSet("100"));
        assertThat(nodeToCliques[2]).isEqualTo(bitSet("001"));
        assertThat(nodeToCliques[3]).isEqualTo(bitSet("100"));
        assertThat(nodeToCliques[4]).isEqualTo(bitSet("111"));
        assertThat(nodeToCliques[5]).isEqualTo(bitSet("100"));
        assertThat(nodeToCliques[6]).isEqualTo(bitSet("001"));
        assertThat(nodeToCliques[7]).isEqualTo(bitSet("110"));
    }