@Test public void testMoralize1() { Graph<BayesVariable> graph = new BayesNetwork(); GraphNode x0 = addNode(graph); GraphNode x1 = addNode(graph); GraphNode x2 = addNode(graph); GraphNode x3 = addNode(graph); GraphNode x4 = addNode(graph); connectParentToChildren(x2, x1); connectParentToChildren(x3, x1); connectParentToChildren(x4, x1); JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph ); assertLinkedNode(jtBuilder, new int[]{1, 2, 3, 4}); assertLinkedNode(jtBuilder, new int[]{2, 1}); assertLinkedNode(jtBuilder, new int[]{3, 1}); assertLinkedNode(jtBuilder, new int[]{4, 1}); jtBuilder.moralize(); assertLinkedNode(jtBuilder, new int[]{1, 2, 3, 4}); assertLinkedNode(jtBuilder, new int[]{2, 1, 3, 4}); assertLinkedNode(jtBuilder, new int[]{3, 1, 2, 4}); assertLinkedNode(jtBuilder, new int[]{4, 1, 2, 3}); }
public void moralize() { for (GraphNode<BayesVariable> v : graph ) { for ( Edge e1 : v.getInEdges() ) { GraphNode pV1 = graph.getNode(e1.getOutGraphNode().getId()); moralize(v, pV1); } } }
JunctionTreeBuilder { public void moralize() { for (GraphNode<BayesVariable> v : graph ) { for ( Edge e1 : v.getInEdges() ) { GraphNode pV1 = graph.getNode(e1.getOutGraphNode().getId()); moralize(v, pV1); } } } }
JunctionTreeBuilder { public void moralize() { for (GraphNode<BayesVariable> v : graph ) { for ( Edge e1 : v.getInEdges() ) { GraphNode pV1 = graph.getNode(e1.getOutGraphNode().getId()); moralize(v, pV1); } } } JunctionTreeBuilder(Graph<BayesVariable> graph); }
JunctionTreeBuilder { public void moralize() { for (GraphNode<BayesVariable> v : graph ) { for ( Edge e1 : v.getInEdges() ) { GraphNode pV1 = graph.getNode(e1.getOutGraphNode().getId()); moralize(v, pV1); } } } 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 moralize() { for (GraphNode<BayesVariable> v : graph ) { for ( Edge e1 : v.getInEdges() ) { GraphNode pV1 = graph.getNode(e1.getOutGraphNode().getId()); moralize(v, pV1); } } } 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);  }