Repository: TheAlgorithms/Java
File: src/test/java/com/thealgorithms/datastructures/graphs/BoruvkaAlgorithmTest.java (Java)

Code before:
        edges.add(new BoruvkaAlgorithm.Edge(5, 7, 6));
        edges.add(new BoruvkaAlgorithm.Edge(6, 7, 9));
        edges.add(new BoruvkaAlgorithm.Edge(6, 8, 2));
        edges.add(new BoruvkaAlgorithm.Edge(7, 8, 11));

        Graph graph1 = new Graph(9, edges);
        /**
         * Adjacency matrix
         *    0   1   2   3   4   5   6   7   8
         * 0  0  10  12   0   0   0   0   0   0
         * 1 10   0   9   8   0   0   0   0   0
         * 2 12   9   0   0   3   1   0   0   0
         * 3  0   8   0   0   7   0   8   5   0
         * 4  0   0   3   7   0   3   0   0   0
         * 5  0   0   1   0   3   0   0   6   0
         * 6  0   0   0   8   0   0   0   9   2
         * 7  0   0   0   5   0   6   9   0  11
         * 8  0   0   0   0   0   0   2  11   0
         */

        List<BoruvkaAlgorithm.Edge> result1 = BoruvkaAlgorithm.boruvkaMST(graph1);
        // Expected result:
        // Edges: 8
        // Total weight: 43
        assertEquals(8, result1.size());
        assertEquals(43, result1.stream().mapToInt(edge -> edge.weight).sum());
    }

    @Test
    void testBoruvkaMSTV2E1() {
        List<BoruvkaAlgorithm.Edge> edges = new ArrayList<>();

        edges.add(new BoruvkaAlgorithm.Edge(0, 1, 10));

        Graph graph2 = new Graph(2, edges);

        /**
         * Adjacency matrix
         *    0  1
         * 0  0  10
         * 1  10  0
         */
        List<BoruvkaAlgorithm.Edge> result2 = BoruvkaAlgorithm.boruvkaMST(graph2);
        // Expected result:
        // Edges: 1
        // Total weight: 10
        assertEquals(1, result2.size());
        assertEquals(10, result2.stream().mapToInt(edge -> edge.weight).sum());
    }

    @Test

Review comment (suggestion):
```suggestion
        final var graph = new Graph(9, edges);
        /**
         * Adjacency matrix
         *    0   1   2   3   4   5   6   7   8
         * 0  0  10  12   0   0   0   0   0   0
         * 1 10   0   9   8   0   0   0   0   0
         * 2 12   9   0   0   3   1   0   0   0
         * 3  0   8   0   0   7   0   8   5   0
         * 4  0   0   3   7   0   3   0   0   0
         * 5  0   0   1   0   3   0   0   6   0
         * 6  0   0   0   8   0   0   0   9   2
         * 7  0   0   0   5   0   6   9   0  11
         * 8  0   0   0   0   0   0   2  11   0
         */

        final var result = BoruvkaAlgorithm.boruvkaMST(graph);
        assertEquals(8, result.size());
        assertEquals(43, result.stream().mapToInt(edge -> edge.weight).sum());
```

I think it does not make much sense to keep the `graph` and `result` _unique_ across all of the tests (please apply in other tests).
The comment, says exactly the same as the assertions. I would suggest to introduce `computeTotalWeight` method instead of having `result.stream().mapToInt(edge -> edge.weight).sum()`.

Code after:
        edges.add(new BoruvkaAlgorithm.Edge(5, 7, 6));
        edges.add(new BoruvkaAlgorithm.Edge(6, 7, 9));
        edges.add(new BoruvkaAlgorithm.Edge(6, 8, 2));
        edges.add(new BoruvkaAlgorithm.Edge(7, 8, 11));

        final var graph = new Graph(9, edges);
        /**
         * Adjacency matrix
         *    0   1   2   3   4   5   6   7   8
         * 0  0  10  12   0   0   0   0   0   0
         * 1 10   0   9   8   0   0   0   0   0
         * 2 12   9   0   0   3   1   0   0   0
         * 3  0   8   0   0   7   0   8   5   0
         * 4  0   0   3   7   0   3   0   0   0
         * 5  0   0   1   0   3   0   0   6   0
         * 6  0   0   0   8   0   0   0   9   2
         * 7  0   0   0   5   0   6   9   0  11
         * 8  0   0   0   0   0   0   2  11   0
         */
        final var result = BoruvkaAlgorithm.boruvkaMST(graph);
        assertEquals(8, result.size());
        assertEquals(43, computeTotalWeight(result));
    }

    @Test
    void testBoruvkaMSTV2E1() {
        List<BoruvkaAlgorithm.Edge> edges = new ArrayList<>();

        edges.add(new BoruvkaAlgorithm.Edge(0, 1, 10));

        final var graph = new Graph(2, edges);

        /**
         * Adjacency matrix
         *    0  1
         * 0  0  10
         * 1  10  0
         */
        final var result = BoruvkaAlgorithm.boruvkaMST(graph);
        assertEquals(1, result.size());
        assertEquals(10, computeTotalWeight(result));
    }

    @Test
    void testCompleteGraphK4() {
        List<BoruvkaAlgorithm.Edge> edges = new ArrayList<>();
        edges.add(new BoruvkaAlgorithm.Edge(0, 1, 7));
        edges.add(new BoruvkaAlgorithm.Edge(0, 2, 2));
        edges.add(new BoruvkaAlgorithm.Edge(0, 3, 5));
        edges.add(new BoruvkaAlgorithm.Edge(1, 2, 3));
        edges.add(new BoruvkaAlgorithm.Edge(1, 3, 4));