Skip to content

Commit 823eab1

Browse files
committed
Change int to bool, rename function and tests
1 parent 29de3d5 commit 823eab1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/com/thealgorithms/backtracking/MColoring.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ private MColoring() {
3333
* @param nodes List of nodes representing the graph.
3434
* @param n The total number of nodes in the graph.
3535
* @param m The maximum number of allowed colors.
36-
* @return 1 if the graph can be colored using M colors, otherwise 0.
36+
* @return true if the graph can be colored using M colors, false otherwise.
3737
*/
38-
static int possiblePaint(ArrayList<Node> nodes, int n, int m) {
38+
static boolean isColoringPossible(ArrayList<Node> nodes, int n, int m) {
3939

4040
// Visited array keeps track of whether each node has been processed.
4141
ArrayList<Integer> visited = new ArrayList<Integer>();

src/test/java/com/thealgorithms/backtracking/MColoringTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void testGraphColoring1() {
1616
int[][] graph = {{0, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 1}, {1, 0, 1, 0}};
1717
int m = 3; // Number of colors
1818

19-
assertEquals(1, MColoring.possiblePaint(createGraph(graph), n, m));
19+
assertEquals(true, MColoring.isColoringPossible(createGraph(graph), n, m));
2020
}
2121

2222
@Test
@@ -25,7 +25,7 @@ void testGraphColoring2() {
2525
int[][] graph = {{0, 1, 1, 1, 0}, {1, 0, 0, 1, 0}, {1, 0, 0, 1, 1}, {1, 1, 1, 0, 1}, {0, 0, 1, 1, 0}};
2626
int m = 2; // Number of colors
2727

28-
assertEquals(0, MColoring.possiblePaint(createGraph(graph), n, m));
28+
assertEquals(false, MColoring.isColoringPossible(createGraph(graph), n, m));
2929
}
3030

3131
@Test
@@ -34,7 +34,7 @@ void testGraphColoring3() {
3434
int[][] graph = {{0, 1, 1}, {1, 0, 1}, {1, 1, 0}};
3535
int m = 2; // Number of colors
3636

37-
assertEquals(0, MColoring.possiblePaint(createGraph(graph), n, m));
37+
assertEquals(false, MColoring.isColoringPossible(createGraph(graph), n, m));
3838
}
3939

4040
private ArrayList<Node> createGraph(int[][] graph) {

0 commit comments

Comments
 (0)