public void moralize() {
        for (GraphNode<BayesVariable> v : graph ) {
            for ( Edge e1 : v.getInEdges() ) {
                GraphNode pV1 = graph.getNode(e1.getOutGraphNode().getId());
                moralize(v, pV1);
            }
        }
    }
@Test
    public void testMoralize2() {
        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);
        GraphNode x5 = addNode(graph);
        GraphNode x6 = addNode(graph);

        connectParentToChildren(x1, x2, x3);
        connectParentToChildren(x2, x4);
        connectParentToChildren(x4, x5);
        connectParentToChildren(x3, x5);
        connectParentToChildren(x6, x5);

        JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph );
        jtBuilder.moralize();

        assertLinkedNode(jtBuilder, x1.getId(), 2, 3);

        assertLinkedNode(jtBuilder, x2.getId(), 1, 4);

        assertLinkedNode(jtBuilder, x3.getId(), 1, 4, 5, 6);

        assertLinkedNode(jtBuilder, x4.getId(), 2, 3, 5, 6);

        assertLinkedNode(jtBuilder, x5.getId(), 3, 4, 6);

        assertLinkedNode(jtBuilder, x6.getId(), 3, 4, 5);

    }