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

2 Graph Theory Graph Coloring

Uploaded by

minec4492
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

2 Graph Theory Graph Coloring

Uploaded by

minec4492
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Graph theory

Graph coloring

Z.GUELLIL
Graph Coloring
• Graph coloring can be described as the process of assigning labels (or
colors) to the vertices of a graph.
• A proper graph coloring is an assignment of colors to the vertices of a graph
such that no two adjacent vertices have the same color.
• We say that G is k-colorable.
• Formally: For a graph G = (V, E), where V is the set of vertices and E is the
set of edges,
oa proper coloring is a function c: V → S,
owhere S is a set of colors,
osuch that c(u) ≠ c(v) for all edges (u, v) ∈ E.
Chromatic number
• The chromatic number of a graph G is the smallest number of colors
needed to achieve a proper coloring of the graph.

3-colourable

Objective: use minimum number of colors .


Chromatic number
• The chromatic number of a graph G is the smallest number of colors
needed to achieve a proper coloring of the graph.

when there are no edges…

-1-
Chromatic number
• The chromatic number of a graph G is the smallest number of colors
needed to achieve a proper coloring of the graph.
Trees

when there are no edges…

-1- -2-
Chromatic number
• The chromatic number of a graph G is the smallest number of colors
needed to achieve a proper coloring of the graph.
Trees

when there are no edges…

-1- -2-

A graph is 2-colorable if and only if it is bipartite.

-3-
Chromatic number
• The chromatic number of a graph G is the smallest number of colors
needed to achieve a proper coloring of the graph.
Trees

when there are no edges…

-1- -2-

A graph is 2-colorable if and only if it is bipartite. complete graph

-3-
 (Kn ) = n -4-
Greedy Coloring
• Colors each vertex in a sequential order, assigning the smallest possible color
that hasn't been used by its adjacent vertices.
• Positive aspects :
oSimple and easy to implement.
oRuns in linear time with respect to the number of vertices and edges.
• Negative aspects :
oDepends heavily on the vertex ordering. It can use more colors than
necessary if the vertices are not ordered optimally.
oMay produce suboptimal colorings (i.e., use more than the chromatic
number).
Welsh and Powell algorithm 1/2
• A variation of the greedy algorithm that sorts vertices by degree (number of
neighbors) before coloring.
• Algorithm:
1.Sort vertices in descending order of degree.
2.Assign the first color to the first vertex in the ordered list and to every
vertex not adjacent to it.
3.Repeat step 2 with a new color for the uncolored vertices until all
vertices are colored.
Welsh and Powell algorithm 2/2
• Positive aspects :
oGenerally, produces better colorings than the basic greedy algorithm
since higher-degree vertices are colored first.
oSimple to implement and has better performance for dense graphs.
• Negative aspects :
oStill not guaranteed to find the chromatic number.*
oIt is affected by the tie-breaking method when vertices have the same
degree.
Example
• Five students have to take written exams.
➢ Student 1: A, D, C
➢ Student 2: E, B, C
➢ Student 3: C, F, A
➢ Student 4: A, B
➢ Student 5: D, F
• If each writing lasts 1/2 day, what is the minimum number of days that
should be planned?
1/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color
2 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red
3/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red
4/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red YEL
5/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red YEL YEL
6/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red YEL YEL
7/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red YEL GR YEL
8/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red YEL GR GR YEL
9/9 Welsh and Powell
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red YEL GR BLUE GR YEL
DSatur Algorithm 1/2
• Colors vertices based on saturation degree, prioritizing those with the highest
number of differently colored neighbors.
• Algorithm:
1.Order vertices by degree.
2.Color a vertex of maximal degree with the first color.
3.Choose a vertex with maximal saturation degree. If there's a tie, choose the
vertex with highest degree in the uncolored subgraph.
4.Color the chosen vertex with the lowest possible color number.
5.Repeat steps 3-4 until all vertices are colored.
DSatur Algorithm 2/2
• Positive aspects :
oGenerally produces better colorings than Greedy or Welsh-Powell
oTends to produce colorings closer to the chromatic number, especially for
dense graphs.
oAdapts to the graph structure during the coloring process
• Negative aspects :
oSlightly more complex to implement due to the need to track saturation
degrees and dynamically update them after each coloring step.
oHeuristic algorithms like DSatur are designed to find good solutions
quickly, but they may not always find the best possible solution.
1/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color
saturation
0 0 0 0 0 0
degree
2/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red
saturation
0 0 0 0 0 0
degree
3/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red
saturation
0 1 1 1 1 1
degree
4/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red Yel
saturation
1 1 2 2 2 1
degree
5/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red Yel Gr
saturation
2 2 2 3 2 1
degree
6/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red Yel Gr Blue
saturation
3 3 3 3 2 1
degree
7/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red Yel Gr Blue Blue
saturation
4 4 3 3 2 2
degree
8/8 DSatur Algorithm
D

A C

F B

Summit C A D F B E
Degree 5 4 3 3 3 2
Color Red Yel Gr Blue Blue Gr
saturation
4 4 3 3 2 2
degree
• Applying the coloring algorithm, it took four colors to color this graph.

• Since (A, C, D, F) forms a complete subgraph of order 4,

• the chromatic number of this graph is 4.

• It will therefore take 2 days to organize this exam.


• Vertex coloring: A proper vertex coloring problem for a
given graph G is to color all the vertices of the graph with
different colors in such a way that any two adjacent (having
an edge connecting them) vertices of G have assigned
different colors.
• Edge coloring : the edge coloring of a graph G = (V, E) is a
mapping, which assigns a color to every edge, satisfying
condition that no two edges sharing a common vertex have
the same color.
Graph Edge Coloring
Chromatic Index = min
# colors needed

Vizing's Theorem: every simple undirected graph may be edge


colored using a number of colors that is at most one larger than
the maximum degree Δ of the graph.
• "class one" graphs for which Δ colors suffice ,
• "class two" graphs for which Δ + 1 colors are necessary.

You might also like