You are on page 1of 63

Graph Colouring

Graph Coloring Problem

• Graph coloring is an assignment of "colors", almost always taken


to be consecutive integers starting from 1 without loss of generality,
to certain objects in a graph. Such objects can be vertices, edges,
faces, or a mixture of the above.

• Application examples: scheduling, register allocation in a


microprocessor, frequency assignment in mobile radios, and pattern
matching
Graph Colouring

Graph Colouring Problem:


Given a graph, colour all the vertices so that
two adjacent vertices get different colours.

Objective: use minimum number of colours.

3-colourable
Vertex Coloring Problem

• Assignment of colors to the vertices of the graph such that proper


coloring takes place (no two adjacent vertices are assigned the same
color)

• Chromatic number: least number of colors needed to color the graph

• A graph that can be assigned a (proper) k-coloring is k-colorable, and


it is k-chromatic if its chromatic number is exactly k.
Optimal Colouring

Definition. min #colors for G is chromatic number, (G)

What graphs have chromatic number one?

when there are no edges…

What graphs have chromatic number 2?

What graphs have chromatic number larger than 2?

A path? A cycle? A triangle?


Simple Cycles

 (Ceven ) = 2

 (Codd ) = 3
Complete Graphs

 (Kn ) = n
Wheels

W5
 (Wodd ) = 4  (Weven ) = 3
Vertex Coloring Problem

• The chromatic number for Cn = 3 (n is odd) or 2 (n is even),


• Kn = n, Km,n = 2

• Cn: cycle with n vertices; Kn: fully connected graph with n vertices;
• Km,n: complete bipartite graph

C4 C5
K4 K2, 3
Vertex Coloring Problem

• The Four color theorem: the chromatic number of a planar graph is


no greater than 4

• Example: G1 chromatic number = 3, G2 chromatic number = 4


• (Most proofs rely on case by case analysis).

G1 G2
Trees

root

Pick any vertex as “root.”


if (unique) path from root is

even length:

odd length:

Can prove more formally using induction.


2-Colourable Graphs

When exactly is a graph 2-colourable?

This is 2-colourable.

2 colourable: tree, even cycle, etc.

Not 2 colourable: triangle, odd cycle, etc.


Bipartite Graphs

When exactly is a graph 2-colourable?

Is a bipartite graph 2-colourable?

Is a 2-colourable graph bipartite?

Fact. A graph is 2-colourable if and only if it is bipartite.


Bipartite Graphs

When exactly is a graph bipartite?

Can a bipartite graph has an odd cycle? NO

If a graph does not have an odd cycle, then it is bipartite?


Bipartite Graphs

When exactly is a graph bipartite?

No such edge because no 5-cycle


1. The idea is like colouring a
tree.
2. Pick a vertex v, colour it red.
3. Colour all its neighbour green.
4. Colour all neighbours of green
vertices red
5. Repeat until all vertices are
No such edge because no triangle coloured.

If a graph does not have an odd cycle, then it is bipartite?

Theorem. A graph is bipartite if and only if it has no odd cycle.


Chromatic Number

How do we estimate the chromatic number of a graph?

If there is a complete subgraph of size k,


then we need at least k colours? YES

Is the converse true?

If a graph has no complete subgraph of size 4,


then we can colour it using 4 colours? NO

What graphs are 3-colourable?

No one knows a good characterization…


Map Colouring

Colour the map using minimum number of colours so that


two countries sharing a border are assigned different colours.
Map Colouring

Can we draw a map so that there are 5 countries


such that any two of which are adjacent? NO

Can we draw a map which need 5 colours? NO

Conjecture (1852) Every map is 4-colourable.

“Proof” by Kempe 1879, an error is found 11 years later.

(Kempe 1879) Every map is 5-colourable.

Theorem (Apple Haken 1977). Every map is 4-colourable.

The proof is computer assisted, some mathematicians are still not happy.
Planar Graphs

- Each vertex is a region.


- Two regions have an edge
if they are adjacent.

This is a planar graph.

A graph is planar if there is a way to


draw it in the plane without edges crossing.
Planar Graphs

A graph G is called planar if G can be drawn in the plane with its


edges intersecting only at vertices of G. Such a drawing of G is
called an embedding of G in the plane.

Application Example: VLSI design (overlapping edges requires extra


layers), Circuit design (cannot overlap wires on board)

Examples: K1,K2,K3,K4 are planar, Kn for n > 4 are non-planar

K4
Planar Graphs

• Example: Q3
Non-Planar Graphs

Can we draw a map so that there are 5 countries


such that any two of which are adjacent? NO
Non-planar Graphs

K3,3 is Nonplanar

v1 v2 v3 v1 v5 v1 v5

R21
R2 R22 R1
R1 v3

v4 v5 v6 v4 v2 v4 v2
Faces/Regions

An important concept of a planar graph is its faces (or regions).

II

IV II
I

4 Faces/Regions
Region Boundaries

d
Region Boundaries

abca
b

d
Region Boundaries

abca
b

abda
a

d
Region Boundaries

abca
b

abda
a

acda
d
outer region
Region Boundaries

abca
b

abda
a
bcdb

acda
outer region d
Region Boundaries: Bridge
Region Boundaries: Bridge
f

a c e

efge
abcda

abcefgecda

outer region
Region Boundaries: Dongle
Region Boundaries: Dongle
s

r y x

v
t
w

rstur

outer region
u
Region Boundaries: Dongle
s

r y x

v
t
w

u
Region Boundaries: Dongle
s
stvxyxvwvturs

r y x

v
t
w

rstur

u
Face length

two length 5 faces length 7 face


Euler’s Formula

If a connected planar graph has v vertices, e edges, and f faces, then

v –e +f = 2

v=5, e=5, f=2 v=6, e=10, f=6 v=9, e=8, f=1


Proof of Euler’s Formula

• Proof of Euler’s formula: By Induction on the number of edges.


Base Case: for G1 , e1 = 1, v1 = 2 and f1= 1

v
u
f1

n+1 Case: Assume, fn = en – vn + 2 is true. Let {an+1, bn+1} be the


edge that is added to Gn to obtain Gn+1 and we prove that
fn = en – vn + 2 is true.

Can be proved using two cases.


Proof of Euler’s Formula

• Case 1:

fn+1 = fn + 1, en+1 = en + 1, vn+1 = vn => fn+1 = en+1 – vn+1 + 2

an+1

bn+1
Proof of Euler’s Formula

• Case 2:

fn+1 = fn, en+1 = en + 1, vn+1 = vn + 1 => fn+1 = en+1 – vn+1 + 2

an+1

R
bn+1
Proof of Euler’s Formula

If a connected planar graph has v vertices, e edges, and f faces, then

v –e +f = 2

Proof by induction on the number of vertices.

Base case (v=1):

v=1 f=e+1
Proof of Euler’s Formula

If a connected planar graph has v vertices, e edges, and f faces, then

v –e +f = 2

Induction step (v>1):

“contract” the red edge

v’=v-1, e’=e-1, f’=f

Number of faces is the same, although some faces get shorter.

By induction, v’-e’+f’=2. This implies v-e+f=2.


Application of Euler’s Formula

Claim. If G is a simple planar graph with at least 3 vertices, then

e <= 3v-6

Let be the face lengths.

Note that

Contributes because each edge contributes 2 to the sum


Contributes
one to two two to one
faces face
Application of Euler’s Formula

Claim. If G is a simple planar graph with at least 3 vertices, then

e <= 3v-6

Let be the face lengths.

Note that

Since the graph is simple, each face is of length at least 3.

So

Since e = v+f-2, this implies


Application of Euler’s Formula

Claim: Let G = (V, E) be a connected simple planar graph with


v vertices ( v ≥ 3) , e edges, and no cycles of length 3 then e
≤ 2v -4

Proof: Similar to Corollary 1 except the fact that no cycles of


length 3 imply that degree of face must be at least 4.
Application of Euler’s Formula

Claim. If G is a simple planar graph with at least 3 vertices, then

e <= 3v-6

Claim. Every simple planar graph has a vertex of degree at most 5.

1. Suppose every vertex has degree at least 6.


2. Then e >= 6v/2 = 3v.
3. A contradiction.
6-Colouring Planar Graphs

Claim. Every simple planar graph has a vertex of degree at most 5.

Theorem. Every planar graph is 6-colourable.

v 1. Proof by induction on the number of vertices.


2. Let v be a vertex of degree at most 5.
3. Remove v from the planar graph G.
4. Note that G-v is still a planar graph.
5. By induction, G-v is 6-colourable.
G-v
6. Since v has at most 5 neighbours,
7. v can always choose a colour (from the 6 colours).
5-coloring Planar Graphs

This result can be strengthened by more careful treatment.


The result is known as “five-colour theorem”

Theorem: Every planar graph is 5-colourable..


Application of Euler’s Formula

Can we draw a map so that there are 5 countries


such that any two of which are adjacent? NO

Can this graph have a planar drawing?

Claim. If G is a simple planar graph with at least 3 vertices, then

e <= 3v-6

This graph has v=5 and e=10, and so does not satisfy the claim.
Trees
• A connected graph without cycles is called a tree.
• (i.e. a tree is a connected acyclic graph)

• A vertex of degree 1 is called a terminal vertex or a leaf, the other


vertices are called internal nodes.
Trees
• Any tree with n vertices has n – 1 edges.
Trees
• If a connected graph with n vertices has n – 1 edges, then
it is a tree.
Trees
• Every pair of vertices is connected by a unique path.
Trees
• Any tree with more than one vertex has at least one vertex
of degree 1.
Rooted Trees
• A Rooted tree is a tree in which one vertex is distinguished
and called a root.
Rooted Trees
• Level of a vertex is the number of edges between the
vertex and the root.
• The height of a rooted tree is the maximum level of any
vertex.
Rooted Trees
• Children, siblings and parent vertices in a rooted tree
• Ancestor, descendant relationship between vertices
Binary Trees

• Binary tree is a rooted tree where each internal vertex


has at most two children: left and right.
• Left and right subtrees
Binary Trees

• Full binary tree/Complete binary tree


– Application: Representation of algebraic expressions
Binary Trees

• Any binary tree with t leaves and height h satisfies the


inequality: t  2h
Spanning Trees
• A subgraph T of a graph G is called a spanning tree
when T is a tree and contains all vertices of G.

• Every connected graph has a spanning tree


Spanning Trees
• Any two spanning trees have the same number of edges

• A weighted graph is a graph in which each edge has an


associated real number weight

• A minimal spanning tree (MST) is a spanning tree with


the least total weight of its edges (need not be unique)

You might also like