0% found this document useful (0 votes)
120 views

Graph Coloring DA-1341572615794729

The document discusses the m-colorability problem, which involves determining if the nodes of a graph can be colored with m colors such that no two adjacent nodes have the same color. It specifically addresses the m-colorability decision problem of determining if a graph can be colored with given colors and the m-colorability optimization problem of finding the minimum number of colors needed. It provides examples of coloring graphs and notes that a graph's chromatic number provides the minimum number of colors needed. The 4-color theorem states that any planar graph can be colored with at most 4 colors. Backtracking algorithms using state space trees are described for solving graph coloring problems.

Uploaded by

Abitha D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

Graph Coloring DA-1341572615794729

The document discusses the m-colorability problem, which involves determining if the nodes of a graph can be colored with m colors such that no two adjacent nodes have the same color. It specifically addresses the m-colorability decision problem of determining if a graph can be colored with given colors and the m-colorability optimization problem of finding the minimum number of colors needed. It provides examples of coloring graphs and notes that a graph's chromatic number provides the minimum number of colors needed. The 4-color theorem states that any planar graph can be colored with at most 4 colors. Backtracking algorithms using state space trees are described for solving graph coloring problems.

Uploaded by

Abitha D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Presented by

Abitha D
1st M.Sc Comp Sci
 Let G be a graph and m be a given positive integer.
 We want to discover whether the nodes of G can be
colored in such a way that no two adjacent nodes have
the same color yet only m colors are used.

M-Colorability Problem:
 The colors can be given, just we want to know whether
the graph can be colored by using these colors.
 We just know whether the graph can be colored or not
by using the given colors.
 This problem is known as m-colorability decision
problem.
M-Colorability Optimization Problem:
We define one more problem, if a graph G is given,
we want to know minimum how many colors required
for coloring the graph.
This problem is known as m-colorability optimization
problem.
Note:
If d is the degree of the given graph, then it can be colored with
d+1 colors.

The figure 7.11 can be colored with three colors 1, 2, and 3.


It can be seen that the nodes of the graph can be colored based
on the condition; no two adjacent nodes have the same color.
It can also be seen that three colors are needed to color the
graph and hence the graph’s chromatic number is 3. (i.e. m=3)
Definition: A graph is said to be planar iff it can be drawn in a plane
in such a way that no two edges cross each other (no intersection
points).
Eg:

A special case of the m-colorability decision problem is the 4-color


problem for planar graphs.
The 4-color theorem:

For every planar graph, the chromatic number is ≤ 4.

The
The four color theorem states that any planar map can
be colored with at most four colors.

In graph terminology, this means that using at most


four colors, any planar graph can have its nodes colored
such that no two adjacent nodes have the same color.
Eg:
Given any map, that can be easily transformed into a
graph.
Each region of the map becomes a node, and if two
regions are adjacent, then the corresponding nodes are
joined by an edge.

Graph coloring problem can be solved by using a state


space tree, whereby applying a backtracking method required
results are obtained.
BACKTRACKING: GRAPH COLORING ALGORITHM

We represent a graph by its adjacency matrix


G[1:n, 1:n], where G[i,j]=1 if (i,j) is an edge of G, and
G[i,j]=0 otherwise.

The colors are represented by integers 1, 2, …, m


and the solutions are given by (x1, ….., xn), where xi is
the color of node i.
Finding all m-colorings of graph:
Algorithm mcoloring(k) {
// This algorithm was formed using the recursive backtracking schema. The graph
is //represented by its Boolean adjacency matrix G[1:n, 1:n]. All assignments of 1,
2,..., m //to the vertices of the graph such that adjacent vertices are assigned
distinct integers //are printed. k is the index of the next vertex to color.
repeat {
NextValue (k);
if ( x[k] = 0 ) then return;
if ( k = n ) then
write ( x[1:n] );
else
mcoloring ( k + 1 );
} until ( false );
}
Total time spent by mcoloring algorithm is O(nmn)
Generating a next color:
Algorithm NextValue(k) {
// x[1], .., x[k-1] have been assigned integer values in the range [1,m] such that
adjacent //vertices have distinct integers. A value for x[k] is determined in the range [
0,m]. x[k] is //assigned next highest number while maintaining distinctness from the
adjacent vertices of //vertex k. If no such color exists, then x[k] is 0.
repeat {
x[k] := (x[k] + 1) mod (m+1); //Next highest value
if (x[k] = 0) then return; // All colors have been used.
for j := 1 to n do {
// Check if the color is distinct from adjacent colors.
if (G[k,j] = 0) and (x[k] = x[j]) then break;
}
if (j = (n+1) ) then return; // New color found
} until ( false );
}
The time spent by NextValue algorithm is O(mn).
State space tree representation:

Suppose, if a graph having n nodes, the


maximum number of colors required for
coloring a graph is n. There is no problem

 The problem is minimum colors required for


coloring the graph with n nodes.
The state space tree for mcoloring when n=3 and m=3.
A 4-node graph and all possible 3-colorings:

You might also like