Monday, 17 March 2014

Graph Coloring

Graph coloring is part of graph theory ,which has great practical importance. The default graph coloring, vertex coloring means coloring of vertices of a graph in such a way that , no adjacent vertices share same colour.
  The problem of coloring of a graph has several application such as scheduling, register application in compilers, frequency assignment in mobile radios , etc.
How graph coloring is possible.

  1. Let G=(V,E) be the graph to be colored , where V and E are vertices set and edges set respectively 
  2. Compute the  degree of each vertices in 
  3. Make a list uncolored which holds V in descending order of their degrees
  4. Initialize currentColor to zero
  5. WHILE length of uncolored greater than zero
  6. Initialize first to the first element of uncolored
  7. Remove first from uncolored
  8. Initialize color(first) to currentColor
  9. Initialize coloredWithCurrent to {first}
  10. FOR each vertex v in uncolored
  11. IF adjacent list of v and coloredWithCurrent(currentColor) has no common elements
  12. Set color(v) to currentColor
  13. Add v to coloredWithCurrent(currentColor)
  14. Remove v from uncolored
  15. ENDIF
  16. ENDFOR
  17. Increment currentColor
  18. ENDWHILE 
   The idea of vertex coloring above take the vertex V and also, it's decreasingly arranged based on the number of adjacent  vertices for each vertex v in V.For this we need a adjacency list of the graph .The main idea of the graph coloring by above algorithm is that, it assigns current colour for vertices if the adjacency list of that vertex does not contain elements in the list of vertices which are already assigned the current color. If it contains, a new colour is assigned for the current vertex.
       I have implemented a web application based on above theory , in that we can create  vertices and edges after that just click the button "color it". Click here  to see my graph coloring application deployed on heroku. I used HTML 5JavaScript  and python-django for developing this. The source code link  . 

No comments:

Post a Comment