You are on page 1of 35

PARALLEL ALGORITHM

GRAPH COLORING

PRESENTED BY:
VIJAY KUMAR YADAV (2K21/CO/516)
VIJAY PAL (2K21/CO/517)
INTRODUCTION

Graph coloring is a concept in graph theory where the vertices (nodes)


of a graph are assigned colors in such a way that no two adjacent
vertices have the same color. The objective is to minimize the number
of colors used while satisfying this condition. Each color represents a
distinct category or group, and the goal is to distinguish between
adjacent vertices by assigning them different colors.
Formally, given a graph G = (V,E), where V is the set of vertices and E is the set of
edges, a proper vertex coloring is a function c: V→C , where C is a set of colors,
such that for every edge (u , v) in E, c(u) != c(v). The minimum number of colors
required for such a coloring is called the chromatic number of the graph.
Graph coloring is a method to assign colors to the vertices of a graph so
that no two adjacent vertices have the same color.

Some graph coloring problems are:

Vertex coloring – A way of coloring the vertices of a graph so that no


two adjacent vertices share the same color.
Edge coloring – It is the method of assigning a color to each edge so
that no two adjacent edges have the same color.
Face coloring – It assigns a color to each face or region of a planar
graph so that no two faces that share a common boundary have the
same color.
Vertex Coloring
A vertex coloring is an assignment of labels
or colors to each vertex of a graph such that
no edge connects two identically colored
vertices. The most common type of vertex
coloring seeks to minimize the number of
colors for a given graph. Such a coloring is
known as a minimum vertex coloring.
Edge Coloring
In graph theory, edge coloring of a graph is an
assignment of “colors” to the edges of the
graph so that no two adjacent edges have the
same color with an optimal number of colors.
Two edges are said to be adjacent if they
are connected to the same vertex.
Face Coloring
The idea of a coloring of the faces of a
map is to assign each face of the graph
a color in such a way that two faces that
share an edge must get different colors.
Faces that meet only at a vertex are
allowed to be colored the same color.
CHROMATIC NUMBER
The chromatic number of a graph is the minimum number of colors
required to properly color its vertices such that no two adjacent
vertices share the same color.

Formally, given a graph G=(V,E), where V is the set of vertices and E is


the set of edges, the chromatic number χ(G) is the smallest positive
integer k such that there exists a proper vertex coloring of G using k
colors.
Determining the chromatic number of a graph is a fundamental problem
in graph theory and has applications in various areas such as scheduling,
register allocation in compilers, map coloring, and wireless channel
allocation.

Finding the chromatic number of a graph is often computationally


challenging, as it falls into the class of NP- Complete problem.
Graph coloring problem is both, a decision problem as well as
an optimization problem.
A decision problem is stated as, With given M colors and graph G,
whether a such color scheme is possible or not.
The optimization problem is stated as, Given M colors and graph G, find
the minimum number of colors required for graph coloring.
A “Greedy” Algorithm
• With a greedy algorithm, we choose some order in which to solve
our problem
• At each step, we make the best choice we can at the time
• We don’t go back and change our minds
In this case, we’ll put the vertices in
alphabetical order

We have some colors we want to use, let’s say:


Color #1 is blue
Color #2 is green
Color #3 is red
Color #4 is orange
Let’s start

The first vertex is CT


We color it using our first color, blue
If you don’t have colored pens,
just label the vertex with the
color number (1)
Next is DE
Since DE doesn’t border any vertices
we have colored yet, it can be blue also

Next is ME (Maine),
which can also be colored blue
Next is MA (Massachusetts)
Since MA is connected by an edge to a blue vertex,
it can’t be blue

So we have use our #2 color, green


Next is NH
NH borders blue and green states
So we have to use color #3: red
Up next is NJ
NJ borders a blue state, so
we use color #2: green

We could use color #3,


but according to the algorithm,
we use the lowest numbered color we can
Next is NY
NY borders blue and green states,
but no red states
So we can use red for NY
Next up is Pennsylvania
Since PA is connected to vertices colored
with colors 1, 2, and 3, we must use color #4
Next is Rhode Island
RI borders colors 1 and 2, so we use color #3

Finally we have Vermont


Vermont only borders colors 2 and 3,
so we can use color #1

We have finished our coloring with 4 colors


NP COMPLETE PROBLEM
NP Complete problem, any of a class of computational problems for
which no efficient solution algorithm has been found. Many
significant computer science problems belong to this class

Eg - traveling salesman problem and graph coloring problem.

Suppose, a problem X is NP-Complete if there is an NP problem Y,


such that Y is reducible to X in polynomial time
Basic Greedy Algorithm
1. Color first vertex with first color.
2. Do following for remaining v-1 vertices.
consider the currently picked vertex and color that has not
been used on any previously colored vertices adjacent to
it.
If all previously used colors appear on vertices adjacent to v,
assign a new color to it.
Analysis of Greedy Algorithm
The above algorithm doesn’t always use minimum number of colors.
Also, the number of colors used sometimes depend on the order in
which vertices are processed.
APPLICATION
There are many applications of graph coloring which are really
interesting to study about. Let’s list few of them –

• Exam scheduling

• Sudoku solver
Exam Scheduling
Let’s suppose algebra, physics, statistics and calculus are four courses
of study in our college. And let’s say that following pairs have
common students :

• Algebra and statistics

• Algebra and calculus

• Statistics and physics


Problem: Say algebra and statistics exam is held on same day then
students taking both courses have to miss at least one exam. They can’t
take both at same time. How do we schedule exams in minimum no of
days so that courses having common students are not held on same day

Solution: Graph coloring.


First draw a graph with courses as vertex and they are connected by
edges if they have common students. Second color the graph such
that no two adjacent vertices are assigned the same color as shown
below:

Look at the above graph. It solves our problem. We can conduct exam
of courses on same day if they have same color.
Our solution:
DAY 1: Algebra and Physics
DAY 2: Statistics and Calculus

This solves our problem of scheduling exams so that all students can
take exams without worrying about missing one.
Sudoku Solver
Sudoku Graph is a graph with 81 vertices (or nodes) . Each cell in the
Sudoku can be seen as a node of the graph.

Each node (or cell) has an edge to every other node (cell) in its
respective column, row, and 3 x 3 grid.
Graph will look like this :
This is a simplified image. As there are a lot of edges that are hidden. Each vertex has an edge
from it to every vertex in it’s column and row, but in this image, all of these edges are lying on
top of each other.

Or more specifically graph look like -


So we can say that Sudoku can be viewed as Graph and thus can be
solved by Graph Coloring with a Chromatic Number, G = 9.

It is no different to using 9 different colors to color the vertices in a way


that no two adjacent vertices have the same color.
REFERENCE
https://www.geeksforgeeks.org/graph-coloring-applications/
https://medium.com/code-science/sudoku-solver-graph-coloring-8f1
b4df47072

https://www.codeproject.com/Articles/801268/A-Sudoku-Solver-
using-Graph-Coloring
https://chat.openai.com/c/7fbc01a4-fa7e-462a-8a1c-f90633ef24b9
https://mathworld.wolfram.com/EdgeColoring.html

You might also like