SlideShare une entreprise Scribd logo
1  sur  10
M-COLORING PROBLEM ON A GRAPH
Mrs.G.Chandraprabha., M.Sc.,M.Phil.,
Assistant Professor,
Department of Information Technology,
V.V.V.anniaperumal College for Women,
Virudhunagar.
OBJECTIVES
M-COLORING GRAPH:
Given an undirected graph and a number m, determine if the
graph can be colored with at most m colors such that no two adjacent
vertices of the graph are colored with the same color.
Starting from vertex 0, we will try to assign colors one by one
to different nodes. But before assigning, we have to check whether the
color is safe or not. A color is not safe whether adjacent vertices are
containing the same color.
Note: Here coloring of a graph means the assignment of
colors to all vertices
Following is an example of a graph that can be colored
with 3 different colors:
PROBLEM:-
PROBLEM: Determine all ways in which the vertices in all
undirected graph can be colored, using only m colors, so that adjacent
vertices are not the same color.
Input: The adjacency matrix of a graph
G(V, E) and an integer m, which indicates the maximum number of colors
that can be used.
Let the maximum color m = 3.
OUTPUT: This algorithm will return which node will
be assigned with which color. If the solution is not possible,
it will return false.
For this input the assigned colors are:
Node 0 -> color 1
Node 1 -> color 2
Node 2 -> color 3
Node 3 -> color 2
EXAMPLE:-
INPUT: graph = {0, 1, 1, 1},
{1, 0, 1, 0},
{1, 1, 0, 1},
{1, 0, 1, 0}
OUTPUT: Solution Exists: Following are the assigned
colors: 1 2 3 2
EXPLANATION: By coloring the vertices with
following colors, adjacent vertices does not have same
colors.
INPUT: graph = {1, 1, 1, 1},
{1, 1, 1, 1},
{1, 1, 1, 1},
{1, 1, 1, 1}
OUTPUT:
Solution does not exist
EXPLANATION:
No solution exits .
NAIVE APPROACH: To solve the problem follow the below idea:
Generate all possible configurations of colors. Since each node can be
colored using any of the m available colors, the total number of color
configurations possible is mV. After generating a configuration of color, check
if the adjacent vertices have the same color or not. If the conditions are met,
print the combination and break the loop.
Follow the given steps to solve the problem:
 Create a recursive function that takes the 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).
every assigned color recursively call the
function with next index and number of
verticersive function returns true break the loop
and returns true.
ALGORITHMS:-
Void m_coloring(index i)
{
int color;
if(promising(i))
if(i==n)
cout<<vcolor[1] through vcolor[n];
else
for (color=1; color<=m; color++){
vcolor[i+1] = color;
m_coloring(i+1);
bool promising (index i)
{
index I;
boot switch;
switch= True;
j=1;
while (j< I && switch)
if (W[i] [j] && vcolor [i] = = vcolor[j])
switch =false;
j++;
}
return switch;
}
THANK YOU

Contenu connexe

Similaire à M-coloring.pptx

Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell AlgorithmGraph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell AlgorithmPriyank Jain
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxB.T.L.I.T
 
Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Adwait Hegde
 
Distributed coloring with O(sqrt. log n) bits
Distributed coloring with O(sqrt. log n) bitsDistributed coloring with O(sqrt. log n) bits
Distributed coloring with O(sqrt. log n) bitsSubhajit Sahu
 
SATISFIABILITY METHODS FOR COLOURING GRAPHS
SATISFIABILITY METHODS FOR COLOURING GRAPHSSATISFIABILITY METHODS FOR COLOURING GRAPHS
SATISFIABILITY METHODS FOR COLOURING GRAPHScscpconf
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxRajitha Reddy Alugati
 
C++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxC++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxBrianGHiNewmanv
 

Similaire à M-coloring.pptx (15)

Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Graph colouring
Graph colouringGraph colouring
Graph colouring
 
Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell AlgorithmGraph Coloring : Greedy Algorithm & Welsh Powell Algorithm
Graph Coloring : Greedy Algorithm & Welsh Powell Algorithm
 
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
Graph coloring Algorithm
Graph coloring AlgorithmGraph coloring Algorithm
Graph coloring Algorithm
 
Graph Coloring
Graph ColoringGraph Coloring
Graph Coloring
 
Graphic colouring
Graphic colouringGraphic colouring
Graphic colouring
 
Sol36
Sol36Sol36
Sol36
 
Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)Chromatic Number of a Graph (Graph Colouring)
Chromatic Number of a Graph (Graph Colouring)
 
Distributed coloring with O(sqrt. log n) bits
Distributed coloring with O(sqrt. log n) bitsDistributed coloring with O(sqrt. log n) bits
Distributed coloring with O(sqrt. log n) bits
 
Graph coloring
Graph coloringGraph coloring
Graph coloring
 
SATISFIABILITY METHODS FOR COLOURING GRAPHS
SATISFIABILITY METHODS FOR COLOURING GRAPHSSATISFIABILITY METHODS FOR COLOURING GRAPHS
SATISFIABILITY METHODS FOR COLOURING GRAPHS
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
 
C++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docxC++ Programming! Make sure to divide the program into 3 files the head.docx
C++ Programming! Make sure to divide the program into 3 files the head.docx
 

Plus de V.V.Vanniaperumal College for Women

Plus de V.V.Vanniaperumal College for Women (20)

Control Memory.pptx
Control Memory.pptxControl Memory.pptx
Control Memory.pptx
 
ADDRESSING MODES.pptx
ADDRESSING MODES.pptxADDRESSING MODES.pptx
ADDRESSING MODES.pptx
 
Data_Transfer&Manupulation Instructions.pptx
Data_Transfer&Manupulation Instructions.pptxData_Transfer&Manupulation Instructions.pptx
Data_Transfer&Manupulation Instructions.pptx
 
Timing & Control.pptx
Timing & Control.pptxTiming & Control.pptx
Timing & Control.pptx
 
Human Rights - 1.pptx
Human Rights - 1.pptxHuman Rights - 1.pptx
Human Rights - 1.pptx
 
Registers.pptx
Registers.pptxRegisters.pptx
Registers.pptx
 
Instruction Codes.pptx
Instruction Codes.pptxInstruction Codes.pptx
Instruction Codes.pptx
 
Features of Java.pptx
Features of Java.pptxFeatures of Java.pptx
Features of Java.pptx
 
JVM.pptx
JVM.pptxJVM.pptx
JVM.pptx
 
Constructors in JAva.pptx
Constructors in JAva.pptxConstructors in JAva.pptx
Constructors in JAva.pptx
 
IS-Crypttools.pptx
IS-Crypttools.pptxIS-Crypttools.pptx
IS-Crypttools.pptx
 
IS-Delibrate software attacks.pptx
IS-Delibrate software attacks.pptxIS-Delibrate software attacks.pptx
IS-Delibrate software attacks.pptx
 
IS-Nature of forces.ppt
IS-Nature of forces.pptIS-Nature of forces.ppt
IS-Nature of forces.ppt
 
IS-cryptograpy algorithms.pptx
IS-cryptograpy algorithms.pptxIS-cryptograpy algorithms.pptx
IS-cryptograpy algorithms.pptx
 
IS-Types of IDPSs.pptx
IS-Types of IDPSs.pptxIS-Types of IDPSs.pptx
IS-Types of IDPSs.pptx
 
IS-honeypot.pptx
IS-honeypot.pptxIS-honeypot.pptx
IS-honeypot.pptx
 
Sum of subset problem.pptx
Sum of subset problem.pptxSum of subset problem.pptx
Sum of subset problem.pptx
 
storm.ppt
storm.pptstorm.ppt
storm.ppt
 
storm for RTA.pptx
storm for RTA.pptxstorm for RTA.pptx
storm for RTA.pptx
 
Yarn.ppt
Yarn.pptYarn.ppt
Yarn.ppt
 

Dernier

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 

Dernier (20)

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 

M-coloring.pptx

  • 1. M-COLORING PROBLEM ON A GRAPH Mrs.G.Chandraprabha., M.Sc.,M.Phil., Assistant Professor, Department of Information Technology, V.V.V.anniaperumal College for Women, Virudhunagar.
  • 2. OBJECTIVES M-COLORING GRAPH: Given an undirected graph and a number m, determine if the graph can be colored with at most m colors such that no two adjacent vertices of the graph are colored with the same color. Starting from vertex 0, we will try to assign colors one by one to different nodes. But before assigning, we have to check whether the color is safe or not. A color is not safe whether adjacent vertices are containing the same color. Note: Here coloring of a graph means the assignment of colors to all vertices Following is an example of a graph that can be colored with 3 different colors:
  • 3.
  • 4. PROBLEM:- PROBLEM: Determine all ways in which the vertices in all undirected graph can be colored, using only m colors, so that adjacent vertices are not the same color. Input: The adjacency matrix of a graph G(V, E) and an integer m, which indicates the maximum number of colors that can be used.
  • 5. Let the maximum color m = 3. OUTPUT: This algorithm will return which node will be assigned with which color. If the solution is not possible, it will return false. For this input the assigned colors are: Node 0 -> color 1 Node 1 -> color 2 Node 2 -> color 3 Node 3 -> color 2
  • 6. EXAMPLE:- INPUT: graph = {0, 1, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 1}, {1, 0, 1, 0} OUTPUT: Solution Exists: Following are the assigned colors: 1 2 3 2 EXPLANATION: By coloring the vertices with following colors, adjacent vertices does not have same colors. INPUT: graph = {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1} OUTPUT: Solution does not exist
  • 7. EXPLANATION: No solution exits . NAIVE APPROACH: To solve the problem follow the below idea: Generate all possible configurations of colors. Since each node can be colored using any of the m available colors, the total number of color configurations possible is mV. After generating a configuration of color, check if the adjacent vertices have the same color or not. If the conditions are met, print the combination and break the loop. Follow the given steps to solve the problem:  Create a recursive function that takes the 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).
  • 8. every assigned color recursively call the function with next index and number of verticersive function returns true break the loop and returns true. ALGORITHMS:- Void m_coloring(index i) { int color; if(promising(i)) if(i==n) cout<<vcolor[1] through vcolor[n]; else for (color=1; color<=m; color++){ vcolor[i+1] = color; m_coloring(i+1);
  • 9. bool promising (index i) { index I; boot switch; switch= True; j=1; while (j< I && switch) if (W[i] [j] && vcolor [i] = = vcolor[j]) switch =false; j++; } return switch; }