@Test public void testFullExample1() { 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"); OpenBitSet clique2 = bitSet("00011100"); OpenBitSet clique3 = bitSet("01010100"); OpenBitSet clique4 = bitSet("11010000"); OpenBitSet clique5 = bitSet("00001110"); OpenBitSet clique6 = bitSet("00000111"); OpenBitSet clique1And2 = bitSet("00011000"); OpenBitSet clique2And3 = bitSet("00010100"); OpenBitSet clique2And5 = bitSet("00001100"); OpenBitSet clique3And4 = bitSet("01010000"); OpenBitSet clique5And6 = bitSet("00000110"); JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph ); JunctionTreeClique root = jtBuilder.build(false).getRoot(); assertEquals( clique1, root.getBitSet() ); assertEquals(1, root.getChildren().size()); 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()); 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()); 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()); 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()); 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()); }
public JunctionTree build() { return build(true); }
JunctionTreeBuilder { public JunctionTree build() { return build(true); } }
JunctionTreeBuilder { public JunctionTree build() { return build(true); } JunctionTreeBuilder(Graph<BayesVariable> graph); }
JunctionTreeBuilder { public JunctionTree build() { return build(true); } 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 JunctionTree build() { return build(true); } 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);  }