time O(m^V)
space O(V)
0
1
2
3
Initialize graph with 4 nodes. Need to color using at most 3 colors.
Pseudocode
Pseudocode
1function graphColoring(graph, m, n):
2 color = array of 0s of size n
3 function solve(node):
4 if node == n: return true
5 for c from 1 to m:
6 if isSafe(node, color, c):
7 color[node] = c
8 if solve(node + 1): return true
9 color[node] = 0
10 return false
11 return solve(0)