I am reading up on vertex coloring algorithm. I see documents explaining how the problem can be solved using BFS (implying the problem can be solved in O(|V|+|E|). But I also see it mentioned that this is an NP-hard problem.
How do these two fit together? Could you please throw some light?
Here is the algorithm I came across, which looked like a general-case polynomial solution to me:
Have each color identified by a number. Start with a node and assign it the color with least number. Visit each of its neighbour using BFS. While visiting a node, check the color of each of its neighbours and assign the color with least number which is not assigned to any of its neighbours.
It is told that BFS approach works only for 2 colors. I am uable to see why the above technique wont work for more than 2 colors