3
3
import static org .junit .jupiter .api .Assertions .assertFalse ;
4
4
import static org .junit .jupiter .api .Assertions .assertTrue ;
5
5
6
- import org .junit .jupiter .api .Test ;
7
6
import java .util .ArrayList ;
7
+ import org .junit .jupiter .api .Test ;
8
8
9
9
public class BipartiteGraphDFSTest {
10
10
@@ -26,23 +26,23 @@ private ArrayList<ArrayList<Integer>> createAdjacencyList(int numVertices, int[]
26
26
@ Test
27
27
public void testBipartiteGraphEvenCycle () {
28
28
int numVertices = 4 ;
29
- int [][] edges = { {0 , 1 }, {1 , 2 }, {2 , 3 }, {3 , 0 } }; // Even cycle
29
+ int [][] edges = {{0 , 1 }, {1 , 2 }, {2 , 3 }, {3 , 0 }}; // Even cycle
30
30
ArrayList <ArrayList <Integer >> adj = createAdjacencyList (numVertices , edges );
31
31
assertTrue (BipartiteGraphDFS .isBipartite (numVertices , adj ), "Graph should be bipartite (even cycle)" );
32
32
}
33
33
34
34
@ Test
35
35
public void testBipartiteGraphOddCycle () {
36
36
int numVertices = 5 ;
37
- int [][] edges = { {0 , 1 }, {1 , 2 }, {2 , 0 }, {1 , 3 }, {3 , 4 } }; // Odd cycle
37
+ int [][] edges = {{0 , 1 }, {1 , 2 }, {2 , 0 }, {1 , 3 }, {3 , 4 }}; // Odd cycle
38
38
ArrayList <ArrayList <Integer >> adj = createAdjacencyList (numVertices , edges );
39
39
assertFalse (BipartiteGraphDFS .isBipartite (numVertices , adj ), "Graph should not be bipartite (odd cycle)" );
40
40
}
41
41
42
42
@ Test
43
43
public void testBipartiteGraphDisconnected () {
44
44
int numVertices = 6 ;
45
- int [][] edges = { {0 , 1 }, {2 , 3 }, {4 , 5 } }; // Disconnected bipartite graphs
45
+ int [][] edges = {{0 , 1 }, {2 , 3 }, {4 , 5 }}; // Disconnected bipartite graphs
46
46
ArrayList <ArrayList <Integer >> adj = createAdjacencyList (numVertices , edges );
47
47
assertTrue (BipartiteGraphDFS .isBipartite (numVertices , adj ), "Graph should be bipartite (disconnected)" );
48
48
}
@@ -58,15 +58,15 @@ public void testBipartiteGraphSingleVertex() {
58
58
@ Test
59
59
public void testBipartiteGraphCompleteBipartite () {
60
60
int numVertices = 4 ;
61
- int [][] edges = { {0 , 2 }, {0 , 3 }, {1 , 2 }, {1 , 3 } }; // K2,2 (Complete bipartite graph)
61
+ int [][] edges = {{0 , 2 }, {0 , 3 }, {1 , 2 }, {1 , 3 }}; // K2,2 (Complete bipartite graph)
62
62
ArrayList <ArrayList <Integer >> adj = createAdjacencyList (numVertices , edges );
63
63
assertTrue (BipartiteGraphDFS .isBipartite (numVertices , adj ), "Graph should be bipartite (complete bipartite)" );
64
64
}
65
65
66
66
@ Test
67
67
public void testBipartiteGraphNonBipartite () {
68
68
int numVertices = 3 ;
69
- int [][] edges = { {0 , 1 }, {1 , 2 }, {2 , 0 } }; // Triangle (odd cycle)
69
+ int [][] edges = {{0 , 1 }, {1 , 2 }, {2 , 0 }}; // Triangle (odd cycle)
70
70
ArrayList <ArrayList <Integer >> adj = createAdjacencyList (numVertices , edges );
71
71
assertFalse (BipartiteGraphDFS .isBipartite (numVertices , adj ), "Graph should not be bipartite (triangle)" );
72
72
}
0 commit comments