Create a color array to store colors assigned to all veritces . Vertex number is used as index in this array . The value ' - 1' of colorArr [ i ] is used to indicate that no color is assigned to vertex ' i ' . The value 1 is used to indicate first color is assigned and value 0 indicates second color is assigned .
int colorArr [ V ] ; for ( int i = 0 ; i < V ; ++ i ) colorArr [ i ] = -1 ;