SlideShare a Scribd company logo
4
Most read
7
Most read
9
Most read
GRAPH COLORING USING
BACKTRACKING
BY:
P. Shashidhar
18E11A05B7
What is graph coloring?
• The 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
1. Arrange the vertices of graph in the same order.
2. Choose the first vertex and color it with the first color.
3. 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.
4. If all the adjacent vertices are colored with the color, assign the new
color to it.
5. Repeat the same process until all the vertices are colored.
6. If any complication occurs backtrack before step and repeat the
process.
Graph coloring using backtracking
Graph coloring using backtracking
Graph coloring using backtracking
Algorithm:
1.Create a recursive function that takes current index, number of
vertices and output color array.
2.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.
3.Assign a color to a vertex (1 to m).
4.For every assigned color recursively call the function with next index
and number of vertices
5.If any recursive function returns true break the loop and returns true.
GraphColor(int k){
for(int c=1;c<=m;c++);
if(isSafe(k,c)){
X[k]=c;
if((k+1)<n)
GraphColor(k+1);
else
print x[];return;
}
}
isSafe(int k,int c){
for(int i=0;i<n;i++){
if(G[k][i]=2 && c==x[i]){
return false;
}
}
return true;
}
Applications:
• Making schedule or Time table.
• Sudoku.
• Register allocation.
• Map coloring.
• Job allocation in CPU.
THANK YOU

More Related Content

PPT
Graph coloring problem
V.V.Vanniaperumal College for Women
 
PPT
Graph colouring
Priyank Jain
 
PPTX
Backtracking
subhradeep mitra
 
PPTX
Graph coloring
Rashika Ahuja
 
PPT
BackTracking Algorithm: Technique and Examples
Fahim Ferdous
 
PPTX
Graph coloring
Barani Tharan
 
PPTX
daa-unit-3-greedy method
hodcsencet
 
PPTX
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
Graph coloring problem
V.V.Vanniaperumal College for Women
 
Graph colouring
Priyank Jain
 
Backtracking
subhradeep mitra
 
Graph coloring
Rashika Ahuja
 
BackTracking Algorithm: Technique and Examples
Fahim Ferdous
 
Graph coloring
Barani Tharan
 
daa-unit-3-greedy method
hodcsencet
 
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 

What's hot (20)

PPTX
15 puzzle problem using branch and bound
Abhishek Singh
 
PPTX
Problem reduction AND OR GRAPH & AO* algorithm.ppt
arunsingh660
 
PPTX
Elements of dynamic programming
Tafhim Islam
 
PDF
I. AO* SEARCH ALGORITHM
vikas dhakane
 
PDF
Hill climbing algorithm in artificial intelligence
sandeep54552
 
PDF
Vc dimension in Machine Learning
VARUN KUMAR
 
PDF
A* Search Algorithm
vikas dhakane
 
PPT
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com
 
PPTX
Algorithm and pseudocode conventions
saranyatdr
 
PPTX
Naive bayes
Ashraf Uddin
 
PPTX
Hashing
Amar Jukuntla
 
PPTX
Breadth First Search & Depth First Search
Kevin Jadiya
 
PPTX
Chess board problem(divide and conquer)
RASHIARORA8
 
PDF
Production System in AI
Bharat Bhushan
 
PPT
backpropagation in neural networks
Akash Goel
 
PPTX
3 tier data warehouse
J M
 
PPTX
Strassen's matrix multiplication
Megha V
 
PPT
Minimum spanning tree
Hinal Lunagariya
 
PPTX
State space search
chauhankapil
 
15 puzzle problem using branch and bound
Abhishek Singh
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
arunsingh660
 
Elements of dynamic programming
Tafhim Islam
 
I. AO* SEARCH ALGORITHM
vikas dhakane
 
Hill climbing algorithm in artificial intelligence
sandeep54552
 
Vc dimension in Machine Learning
VARUN KUMAR
 
A* Search Algorithm
vikas dhakane
 
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com
 
Algorithm and pseudocode conventions
saranyatdr
 
Naive bayes
Ashraf Uddin
 
Hashing
Amar Jukuntla
 
Breadth First Search & Depth First Search
Kevin Jadiya
 
Chess board problem(divide and conquer)
RASHIARORA8
 
Production System in AI
Bharat Bhushan
 
backpropagation in neural networks
Akash Goel
 
3 tier data warehouse
J M
 
Strassen's matrix multiplication
Megha V
 
Minimum spanning tree
Hinal Lunagariya
 
State space search
chauhankapil
 
Ad

Similar to Graph coloring using backtracking (20)

PPTX
graph coloring back tracking and applications in realA time.pptx
jhansirani64003
 
PDF
Graph Coloring
Chetanmalviya8
 
PPT
Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Priyank Jain
 
PPTX
Graph Coloring Algorithm.pptx
ImaanIbrar
 
PPTX
Module 5 - GraphColoring hoeyo colr grafh.pptx
lomic31750
 
PPTX
Module 5 - GraphColo blhyhfhuufring.pptx
lomic31750
 
PPTX
Graph coloring problem(DAA).pptx
Home
 
PDF
An analysis between different algorithms for the graph vertex coloring problem
IJECEIAES
 
PPTX
Graphic colouring
varagilavanya
 
PPT
Exact coloring of real-life graphs is easy
Olivier Coudert
 
PPTX
daa seminar[1].pptx_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 
PPT
graph coloring.ppt
chetanvchaudhari
 
PPT
GRAPH COLORING AND ITS APPLICATIONS
Manojit Chakraborty
 
PPT
Graph coloring
Delowar Hossain
 
PPT
CS6702 Unit III coloring ppt
Abilaasha Ganesan
 
PPTX
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
varun arora
 
PDF
Algorithms for Graph Coloring Problem
Shengyi Wang
 
PPT
5.5 back track
Krish_ver2
 
PPTX
Graph coloring and_applications
mohammad alkhalil
 
graph coloring back tracking and applications in realA time.pptx
jhansirani64003
 
Graph Coloring
Chetanmalviya8
 
Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Priyank Jain
 
Graph Coloring Algorithm.pptx
ImaanIbrar
 
Module 5 - GraphColoring hoeyo colr grafh.pptx
lomic31750
 
Module 5 - GraphColo blhyhfhuufring.pptx
lomic31750
 
Graph coloring problem(DAA).pptx
Home
 
An analysis between different algorithms for the graph vertex coloring problem
IJECEIAES
 
Graphic colouring
varagilavanya
 
Exact coloring of real-life graphs is easy
Olivier Coudert
 
daa seminar[1].pptx_SQL _UNIT_DBMS_PRESENTSTATION
deeptanshudas100
 
graph coloring.ppt
chetanvchaudhari
 
GRAPH COLORING AND ITS APPLICATIONS
Manojit Chakraborty
 
Graph coloring
Delowar Hossain
 
CS6702 Unit III coloring ppt
Abilaasha Ganesan
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
varun arora
 
Algorithms for Graph Coloring Problem
Shengyi Wang
 
5.5 back track
Krish_ver2
 
Graph coloring and_applications
mohammad alkhalil
 
Ad

Recently uploaded (20)

PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PPTX
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
PPTX
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
PPTX
Ship’s Structural Components.pptx 7.7 Mb
abdalwhab7327
 
PDF
ETO & MEO Certificate of Competency Questions and Answers
Mahmoud Moghtaderi
 
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
PPTX
Chapter----five---Resource Recovery.pptx
078bce110prashant
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
Introduction to Data Science: data science process
ShivarkarSandip
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
Ship’s Structural Components.pptx 7.7 Mb
abdalwhab7327
 
ETO & MEO Certificate of Competency Questions and Answers
Mahmoud Moghtaderi
 
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Dr. Rahul Kumar
 
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
Chapter----five---Resource Recovery.pptx
078bce110prashant
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
Introduction to Data Science: data science process
ShivarkarSandip
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 

Graph coloring using backtracking

  • 2. What is graph coloring?
  • 3. • The 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.
  • 4. Method to Color a Graph 1. Arrange the vertices of graph in the same order. 2. Choose the first vertex and color it with the first color. 3. 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. 4. If all the adjacent vertices are colored with the color, assign the new color to it. 5. Repeat the same process until all the vertices are colored. 6. If any complication occurs backtrack before step and repeat the process.
  • 8. Algorithm: 1.Create a recursive function that takes current index, number of vertices and output color array. 2.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. 3.Assign a color to a vertex (1 to m). 4.For every assigned color recursively call the function with next index and number of vertices 5.If any recursive function returns true break the loop and returns true.
  • 9. GraphColor(int k){ for(int c=1;c<=m;c++); if(isSafe(k,c)){ X[k]=c; if((k+1)<n) GraphColor(k+1); else print x[];return; } } isSafe(int k,int c){ for(int i=0;i<n;i++){ if(G[k][i]=2 && c==x[i]){ return false; } } return true; }
  • 10. Applications: • Making schedule or Time table. • Sudoku. • Register allocation. • Map coloring. • Job allocation in CPU.