@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); assertEquals( bitSet("011"), nodeToCliques[0] ); assertEquals( bitSet("100"), nodeToCliques[1] ); assertEquals( bitSet("001"), nodeToCliques[2] ); assertEquals( bitSet("100"), nodeToCliques[3] ); assertEquals( bitSet("111"), nodeToCliques[4] ); assertEquals( bitSet("100"), nodeToCliques[5] ); assertEquals( bitSet("001"), nodeToCliques[6] ); assertEquals( bitSet("110"), nodeToCliques[7] ); }
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); } }
JunctionTreeBuilder { 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); } } }
JunctionTreeBuilder { 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); } } JunctionTreeBuilder(Graph<BayesVariable> graph); }
JunctionTreeBuilder { 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); } } 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); }
JunctionTreeBuilder { 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); } } 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);  }