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 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, 1, 2, 3, 4);
        assertLinkedNode(jtBuilder, 2, 1);
        assertLinkedNode(jtBuilder, 3, 1);
        assertLinkedNode(jtBuilder, 4, 1);

        jtBuilder.moralize();

        assertLinkedNode(jtBuilder, 1, 2, 3, 4);
        assertLinkedNode(jtBuilder, 2, 1, 3, 4);
        assertLinkedNode(jtBuilder, 3, 1, 2, 4);
        assertLinkedNode(jtBuilder, 4, 1, 2, 3);
    }