presentation of Graph coloring Technique using backtracking
Size: 1.02 MB
Language: en
Added: May 22, 2021
Slides: 11 pages
Slide Content
GRAPH COLORING USING BACKTRACKING BY: P. Shashidhar 18E11A05B7
What is graph coloring?
T he objective is to minimize the number of colors while coloring a graph. The smallest number of colors required to color a graph G is called its chromatic number of that graph. Graph coloring problem is a NP Complete problem . No efficient algorithm is available to implement graph coloring mainly we use Greedy and Backtracking algorithm.
Method to Color a Graph Arrange the vertices of graph in the same order. Choose the first vertex and color it with the first color. Then choose next vertex and color it with the lowest numbered color that has not been colored on any vertices which is adjacent to it. If all the adjacent vertices are colored with the color, assign the new color to it. Repeat the same process until all the vertices are colored. If any complication occurs backtrack before step and repeat the process.
Algorithm: Create a recursive function that takes current index, number of vertices and output color array. If the current index is equal to number of vertices. Check if the output color configuration is safe, i.e check if the adjacent vertices do not have same color. If the conditions are met, print the configuration and break. Assign a color to a vertex (1 to m). For every assigned color recursively call the function with next index and number of vertices If any recursive function returns true break the loop and returns true.