15-16 Graph Coloring

You might also like

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

Graph Theory (Coloring)

10/28/2016
Graph
Colorings
Colorings of edges a nd vertices of a graph G are
useful, when one is interested in classifying
relations between objects.
 A k-coloring of a graph G is an assignment of one
color to e a c h vertex of G such that no more than k
colors are used a nd no two adjacent vertices receive
the same color.
 A graph is called k-colorable iff it has a k-coloring.
Chromatic
number
The chromatic number of a graph G is the smallest
number k such that G is k-colorable, a nd it is denoted by
χ(G).
Application
s
 The problem of coloring a graph has several
applications such as scheduling, register allocation in
compilers, frequency assignment in Mobile radios, etc.
Terminolog
y
K-chromatic graph
 A graph whose chromatic number is k is called a k-
chromatic graph.
Coloring
 A coloring of a graph G assigns colors to the vertices
of G so that adjacent vertices are given different
colors
Exampl
e

The chromatic number is four. Therefore this is a 4-Chromatic


Graph
Exampl
e
There are a total of 16 people attending the rehearsal
dinner: A, B, C, … H
are relatives of the bride an d groom; I, J, K, … P are
members of the wedding party. If things weren’t stressful
enough, you are told that some of these people have
serious issues:
■ A doesn’t get along with F, G, or H,
■ B doesn’t get along with C, D, or H,
■ C doesn’t get along with B, D, E, G, or H,
■ D doesn’t get along with B, C, or E,
■ E doesn’t get along with C, D, F, or G,
■ F doesn’t get along with A, E, or G,
■ G doesn’t get along with A, C, E, or F,
■ H doesn’t get along with A, B, or C.
 Start by creating the “incompatibility” graph shown in
Figure (a).
 Figure (b) shows a legal coloring of the vertices of the
graph in Figure (a)
that uses four different colors.
 Figure (c) shows a legal coloring of the vertices of the
graph that uses just
three colors.
Conclusio
n
 The conclusion to our analysis is:
 (i) the minimum number of tables needed to sit the
wedding party is three, an d
 (ii) the seating assignment should put A, B, an d E in one
table (red), C an d F in a second table (blue), an d D, G,
an d H in the third table (green). The remaining
members of the wedding party c a n b e arbitrarily
assigned to fill up the remaining seats at the three
tables.
Coloring Complete
Graphs
 The graph in Figure (a) K5 is the complete graph on 5
vertices. In this graph
every vertex is adjacent to every other vertex, so no two
vertices c a n have the same color. The only possible way
to color K5 is to use a different color for e a c h vertex, as
in Figure (b). Thus, we c a n conclude that χ(K5) = 5.
Optimal
Coloring
 An optimal coloring of a graph G is a coloring of the
vertices of G using the fewest possible number of colors.
To put it in slightly more formal terminology, an optimal
coloring of G is a χ(G)-coloring of G.
 Greedy Algorithm for Graph Coloring
■ Step 1. Assign the first color (c 1 ) to the first vertex
(v1 ).
■ Step 2. Vertex (v 2 ) is assigned color (c 1 ) if it is not
adjacent to (v1 ); otherwise it gets assigned color (c 2 ).
■ Steps 3,4,…,n. Vertex (vi ) is assigned the first possible
color in the priority list of colors (i.e. the first color that
has not been assigned to one of the already colored
neighbors of vi).
Map Coloring with Dual
Graphs
 Figure (a) shows a small m a p with six states, and Figure
(b) shows its dual graph. Figure (c) shows an optimal 3-
coloring of the dual graph. We know that the 3-
coloring is optimal because the graph has triangles,
an d thus cannot b e colored with 2 colors. The
corresponding optimal coloring of the m a p is shown in
Figure (d).
Edge
Coloring
 Given a graph G=(V,E) how c a n we color the
edges such that edges that share a vertex d o not
share a color.
Line
Graph
 An Edge Coloring Problem c a n b e formulated as a
Vertex Coloring Problem.
 Let L(G) b e an auxiliary graph a nd G b e the graphs
which we are trying to color. L(G) contains a vertex
for every e d g e in G. There is an e d g e in
L(G) drawn between two vertices if their associated
edges in G share a vertex.
Example Auxiliary
Graph

A C

B B C
Example Auxiliary
Graph
A B
B

A E
E
D C

C D

A E
D C
Independent
Sets
 An independent set of a graph G is a subset of the
vertices such that no two vertices in the subset
are connected by an e d g e of G.

α(G)=3

 The independence number, α(G), is the cardinality of


the maximum independent set.
Independent
Set
 A subset I ⊆ V is called an independent set (stable set)
if
G(I) has no edges.
 An independent set is said to b e
maximal, if it is not a subset of any larger independent
set;
maximum, if there is no larger independent set in the
graph.
 For S ⊆ V , neighborhood of S is defined as N(S) = ∪v∈S
N(v).
An Example: maximal independent
set

 I = {6, 9} is the maximal independent set. mN(I ) = {1,


2, 3,
4, 5, 7, 8}
Approximate Colouring
Algorithm
 Sort the verices so that degree(v(i))>=degree(v(i+1))
 Colour v(0)
 For i=1 to n color v(i) so that there is no clash
 Complexity O(n 2 )
Maximal Independent Set
Algorithm
 Problem: What is the largest subset of vertices of V
such that no pair of vertices defines an e d g e of E.
 Algorithm:
Repeat until there is no vertex
Begin
Find the maximal independent set (MIS)
Reduce the graph by MIS
End
24 A Sequential Greedy algorithm

Suppose that I will hold the final MIS


Initially I 
G
Phase 1:

25

Pick a node v1 and a d d it to I

v1 G 
G1
26

Remove
v1 and neighbors
N
(v 1 )

G1
27

N
Remove v 1 and neighbors
(v 1 )

G2
Phase
28
2:
Pick a node v2 an d a d d it to
I

G2

v2
29

N
Remove v 2 an d neighbors
(v2 )

G2

v2
30

N
Remove v 2 and neighbors
(v2 )

G3
Phases 3,4,5,
31
…:
Repeat until all nodes are removed

G3
Phases 3,4,5,
32
…,x:
Repeat until all nodes are removed

Gx 1

No remaining nodes
33

At the end , set I will b e an MIS of G


G
Find the
MIS
 Repeat until there is no vertex
 Begin
 Select the vertex with the maximal degree
 Include it in MIS a nd reduce the graph by all the
adjacent nodes
 End

You might also like