I saw this question on a forum: http://www.geeksforgeeks.org/archives/19042
Given an undirected graph and a number m, determine if the graph can be colored with at most m colors such that no two adjacent vertices of the graph are colored with same color.
I am wondering if you can just compare the number of vertices to that of m,
instead of trying to find a particular solution?
What am I missing?
There could be a coloring even if the number of vertices (
|V|) is bigger thenm.For example, in bipartite graph – there is coloring for any
m>=2, regardless of the number of vertices.In a clique however, the only feasible colorings require
m >= |V|So:
If
m > = |V|– there is a solution, however, ifm < |V|– we can derive nothing. There might be an answer anyway.Bonus: The graph coloring, for the general case is one of the classical NP-Complete problems – meaning – there is no known polynomial solution for it, and if one can be found – we can derive
P = NP