public void createClique(int v, boolean[][] clonedAdjMatrix, Set<Integer> verticesToUpdate, boolean[] adjList) {
        for ( int i = 0; i < adjList.length; i++ ) {
            if ( !adjList[i] ) {
                // not connected to this vertex
                continue;
            }
            getRelatedVerticesToUpdate(v, clonedAdjMatrix, verticesToUpdate, i);

            boolean needsConnection = false;
            for ( int j = i+1; j < adjList.length; j++ ) {
                // i + 1, so it doesn't check if a node is connected with itself
                if ( !adjList[j] || clonedAdjMatrix[i][j] ) {
                    // edge already exists
                    continue;
                }

                connect(adjacencyMatrix, i, j);
                connect(clonedAdjMatrix, i, j );
                getRelatedVerticesToUpdate(v, clonedAdjMatrix, verticesToUpdate, j);

                needsConnection = true;
            }

            if ( needsConnection ) {
                verticesToUpdate.add( i );
            }
        }
    }
@Test
    public void testCreateClique() {
        Graph<BayesVariable> graph = new BayesNetwork();

        GraphNode dX0 = addNode(graph);
        GraphNode dX1 = addNode(graph);
        GraphNode dX2 = addNode(graph);
        GraphNode dX3 = addNode(graph);
        GraphNode dX4 = addNode(graph);
        GraphNode dX5 = addNode(graph);

        connectParentToChildren(dX1, dX2, dX3, dX4);

        JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph );
        // do not moralize, as we want to test just the clique creation through elimination of the provided vertices

        Set<Integer> vertices = new HashSet<Integer>();
        boolean[] adjList = new boolean[] { false, false, true, true, true, false };

        boolean[][] clonedAdjMatrix = JunctionTreeBuilder.cloneAdjacencyMarix(jtBuilder.getAdjacencyMatrix());
        jtBuilder.createClique(dX1.getId(), clonedAdjMatrix, vertices, adjList );

        assertThat(vertices.size()).isEqualTo(3);
        assertThat(vertices.containsAll(Arrays.asList(2, 3, 4))).isTrue();

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