(boolean[][] graph, int m,
int i, int[] color)
| 37 | one solutions, this function prints one |
| 38 | of the feasible solutions.*/ |
| 39 | static boolean graphColoring(boolean[][] graph, int m, |
| 40 | int i, int[] color) |
| 41 | { |
| 42 | // if current index reached end |
| 43 | if (i == V) { |
| 44 | |
| 45 | // if coloring is safe |
| 46 | if (isSafe(graph, color)) { |
| 47 | |
| 48 | // Print the solution |
| 49 | printSolution(color); |
| 50 | return true; |
| 51 | } |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | // Assign each color from 1 to m |
| 56 | for (int j = 1; j <= m; j++) { |
| 57 | color[i] = j; |
| 58 | |
| 59 | // Recur of the rest vertices |
| 60 | if (graphColoring(graph, m, i + 1, color)) |
| 61 | return true; |
| 62 | color[i] = 0; |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | // Driver code |
| 68 | public static void main(String[] args) |
no test coverage detected