JunctionTreeBuilder { public static void updateCliques(List<OpenBitSet> cliques, OpenBitSet newClique) { boolean superSetFound = false; for ( OpenBitSet existingCluster : cliques ) { if ( OpenBitSet.andNotCount(newClique, existingCluster) == 0) { superSetFound = true; break; } } if ( !superSetFound ) { cliques.add(newClique); } } JunctionTreeBuilder(Graph<BayesVariable> graph); Graph<BayesVariable> getGraph(); JunctionTree build(); JunctionTree build(boolean init); JunctionTree build(Resource resource, String namespace, String name); JunctionTree build(Resource resource, String namespace, String name, boolean init); void moralize(); void moralize(GraphNode<BayesVariable> v, GraphNode v1); static void connect(boolean[][] adjMatrix, int v1, int v2); static void disconnect(boolean[][] adjMatrix, int v1, int v2); List<OpenBitSet> triangulate(); void eliminateVertex(PriorityQueue<EliminationCandidate> p, Map<Integer, EliminationCandidate> elmVertMap, boolean[][] clonedAdjMatrix, boolean[] adjList, Set<Integer> verticesToUpdate, EliminationCandidate v); void createClique(int v, boolean[][] clonedAdjMatrix, Set<Integer> verticesToUpdate, boolean[] adjList); static void updateCliques(List<OpenBitSet> cliques, OpenBitSet newClique); boolean[][] getAdjacencyMatrix(); static boolean[][] cloneAdjacencyMarix(boolean[][] src); JunctionTree junctionTree(List<OpenBitSet> cliques, boolean init); JunctionTree junctionTree(Resource resource, String namespace, String name, List<OpenBitSet> cliques, boolean init); void mergeGraphs(SeparatorSet[][][] graphs, SeparatorSet separatorSet); int createJunctionTreeGraph(SeparatorSet[][] sepGraph, JunctionTreeClique parent, JunctionTreeClique[] jtNodes, JunctionTreeSeparator[] jtSeps, int i); void mapNodeToCliqueFamily(OpenBitSet[] varNodeToCliques, JunctionTreeClique[] jtNodes); void mapVarNodeToCliques(OpenBitSet[] nodeToCliques, int id, OpenBitSet clique); static List<Integer> getAdjacentVertices(boolean[][] adjacencyMatrix, int i);  }
@Test public void testCliqueSuperSet() { Graph<BayesVariable> graph = new BayesNetwork(); JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph ); List<OpenBitSet> cliques = new ArrayList<OpenBitSet>(); OpenBitSet OpenBitSet1 = bitSet("00011110"); jtBuilder.updateCliques(cliques, OpenBitSet1); assertEquals( 1, cliques.size() ); OpenBitSet OpenBitSet2 = bitSet("00000110"); jtBuilder.updateCliques(cliques, OpenBitSet2); assertEquals( 1, cliques.size() ); assertEquals( OpenBitSet1, cliques.get(0) ); OpenBitSet OpenBitSet3 = bitSet("01000110"); jtBuilder.updateCliques(cliques, OpenBitSet3); assertEquals( 2, cliques.size() ); assertEquals( OpenBitSet1, cliques.get(0) ); assertEquals( OpenBitSet3, cliques.get(1) ); }