11package com .thealgorithms .randomized ;
22
3- import org .junit .jupiter .api .Test ;
4-
5- import java .util .*;
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertTrue ;
65
7- import static org .junit .jupiter .api .Assertions .*;
6+ import java .util .Arrays ;
7+ import java .util .Collection ;
8+ import java .util .List ;
9+ import org .junit .jupiter .api .Test ;
810
911public class KargerMinCutTest {
1012
1113 @ Test
1214 public void testSimpleGraph () {
1315 // Graph: 0 -- 1
1416 Collection <Integer > nodes = Arrays .asList (0 , 1 );
15- List <int []> edges = List .of (new int []{0 , 1 });
17+ List <int []> edges = List .of (new int [] {0 , 1 });
1618
1719 KargerMinCut .KargerOutput result = KargerMinCut .findMinCut (nodes , edges );
1820
@@ -25,11 +27,7 @@ public void testSimpleGraph() {
2527 public void testTriangleGraph () {
2628 // Graph: 0 -- 1 -- 2 -- 0
2729 Collection <Integer > nodes = Arrays .asList (0 , 1 , 2 );
28- List <int []> edges = List .of (
29- new int []{0 , 1 },
30- new int []{1 , 2 },
31- new int []{2 , 0 }
32- );
30+ List <int []> edges = List .of (new int [] {0 , 1 }, new int [] {1 , 2 }, new int [] {2 , 0 });
3331
3432 KargerMinCut .KargerOutput result = KargerMinCut .findMinCut (nodes , edges );
3533
@@ -42,12 +40,7 @@ public void testSquareGraph() {
4240 // | |
4341 // 3 -- 2
4442 Collection <Integer > nodes = Arrays .asList (0 , 1 , 2 , 3 );
45- List <int []> edges = List .of (
46- new int []{0 , 1 },
47- new int []{1 , 2 },
48- new int []{2 , 3 },
49- new int []{3 , 0 }
50- );
43+ List <int []> edges = List .of (new int [] {0 , 1 }, new int [] {1 , 2 }, new int [] {2 , 3 }, new int [] {3 , 0 });
5144
5245 KargerMinCut .KargerOutput result = KargerMinCut .findMinCut (nodes , edges );
5346
@@ -58,10 +51,7 @@ public void testSquareGraph() {
5851 public void testDisconnectedGraph () {
5952 // Graph: 0 -- 1 2 -- 3
6053 Collection <Integer > nodes = Arrays .asList (0 , 1 , 2 , 3 );
61- List <int []> edges = List .of (
62- new int []{0 , 1 },
63- new int []{2 , 3 }
64- );
54+ List <int []> edges = List .of (new int [] {0 , 1 }, new int [] {2 , 3 });
6555
6656 KargerMinCut .KargerOutput result = KargerMinCut .findMinCut (nodes , edges );
6757
@@ -72,14 +62,7 @@ public void testDisconnectedGraph() {
7262 public void testCompleteGraph () {
7363 // Complete Graph: 0 -- 1 -- 2 -- 3 (all nodes connected to each other)
7464 Collection <Integer > nodes = Arrays .asList (0 , 1 , 2 , 3 );
75- List <int []> edges = List .of (
76- new int []{0 , 1 },
77- new int []{0 , 2 },
78- new int []{0 , 3 },
79- new int []{1 , 2 },
80- new int []{1 , 3 },
81- new int []{2 , 3 }
82- );
65+ List <int []> edges = List .of (new int [] {0 , 1 }, new int [] {0 , 2 }, new int [] {0 , 3 }, new int [] {1 , 2 }, new int [] {1 , 3 }, new int [] {2 , 3 });
8366
8467 KargerMinCut .KargerOutput result = KargerMinCut .findMinCut (nodes , edges );
8568
@@ -117,17 +100,9 @@ public void testComplexGraph() {
117100 // Nodes: 0, 1, 2, 3, 4, 5, 6, 7, 8
118101 // Edges: Fully connected graph with additional edges for complexity
119102 Collection <Integer > nodes = Arrays .asList (0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
120- List <int []> edges = List .of (
121- new int []{0 , 1 }, new int []{0 , 2 }, new int []{0 , 3 }, new int []{0 , 4 }, new int []{0 , 5 },
122- new int []{1 , 2 }, new int []{1 , 3 }, new int []{1 , 4 }, new int []{1 , 5 }, new int []{1 , 6 },
123- new int []{2 , 3 }, new int []{2 , 4 }, new int []{2 , 5 }, new int []{2 , 6 }, new int []{2 , 7 },
124- new int []{3 , 4 }, new int []{3 , 5 }, new int []{3 , 6 }, new int []{3 , 7 }, new int []{3 , 8 },
125- new int []{4 , 5 }, new int []{4 , 6 }, new int []{4 , 7 }, new int []{4 , 8 },
126- new int []{5 , 6 }, new int []{5 , 7 }, new int []{5 , 8 },
127- new int []{6 , 7 }, new int []{6 , 8 },
128- new int []{7 , 8 },
129- new int []{0 , 6 }, new int []{1 , 7 }, new int []{2 , 8 }
130- );
103+ List <int []> edges = List .of (new int [] {0 , 1 }, new int [] {0 , 2 }, new int [] {0 , 3 }, new int [] {0 , 4 }, new int [] {0 , 5 }, new int [] {1 , 2 }, new int [] {1 , 3 }, new int [] {1 , 4 }, new int [] {1 , 5 }, new int [] {1 , 6 }, new int [] {2 , 3 }, new int [] {2 , 4 }, new int [] {2 , 5 }, new int [] {2 , 6 },
104+ new int [] {2 , 7 }, new int [] {3 , 4 }, new int [] {3 , 5 }, new int [] {3 , 6 }, new int [] {3 , 7 }, new int [] {3 , 8 }, new int [] {4 , 5 }, new int [] {4 , 6 }, new int [] {4 , 7 }, new int [] {4 , 8 }, new int [] {5 , 6 }, new int [] {5 , 7 }, new int [] {5 , 8 }, new int [] {6 , 7 }, new int [] {6 , 8 }, new int [] {7 , 8 },
105+ new int [] {0 , 6 }, new int [] {1 , 7 }, new int [] {2 , 8 });
131106
132107 KargerMinCut .KargerOutput result = KargerMinCut .findMinCut (nodes , edges );
133108
0 commit comments