Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

GRAPH COLORING PROBLEM WITH STATE SPACE

S
The graph coloring TREE
Solve
Graph graph coloring
coloring problem
is the problem of with
assigning Solve graph can
This problem coloring problem
be solved using with state space tree.
backtracking
problem is the colors to the ver-
state space tree. algorithms. The formal idea is to list down all the vertices
problem of tices of a graph in such a way that neighbor
Backtracking: and colors in two lists. Assign color 1 to vertex 1. If
partitioning the vertices are as-is a general algorithm for
Backtracking vertex 2 is not adjacent to vertex 1 then assign the same
signed with
finding different
all the colors.
solutions The problem
to some
vertices of a graph color, otherwise assign color 2. The process is repeated
of coloring a graph
computational problems, notably constraint
into the smallest until all vertices are colored. The algorithm backtracks
with the minimum
satisfaction possible
problems, number of
that incrementally
possible set of colors is a fundamental whenever color i is not possible to assign to any vertex k
builds possible candidates to the solutions
independent sets. NP-Hard problem with a as
number of it and it selects the next color i + 1 and the test is repeated.
and abandons a candidate soon as
Since it is a well- applicationsthat
determines of interest
the candidate cannot This graph can be colored with 3 colors
known NP-Hard such as timetabling,
possibly be completed code optimization
to finally become and
a
problem, it is of great seating
valid plans It is an algorithmic-
solution.
Example
interest of the technique for solving problems recursively
Given vertices (1,2,3,4)
computer science by trying to build a solution incrementally,
finding results over one piece at a time, removing those Each colours must not adjacent to each other.
exact algorithms that solutions that fail to satisfy the constraints
solve it. The main of the problem at any point of time Here we are using red,green and blue colours in
algorithms of this Follow the given steps to solve the problem: such a way that the colour must not adjacent to
kind, though, are Create a function that takes the graph, current each other.
scattered through the index, number of vertices, and output color
literature. array.
If the current index is equal to the number of
ABSTRACT
vertices. Print the color configuration in the from below state space tree, the possible
output array.
Assign a color to a vertex (1 to m). rputes are
For every assigned color, check if the
configuration is safe, recursively call the
function with the next index and number of
vertices
If any function returns true break the loop and
return true
If no function returns true then return false
INTRODUCTION:

Problem Statement:
Roll No.: TYCOC203

You might also like