Lecture 07
Lecture 07
Graph Theory
Lecture - 7
2
Edge Coloring
11/25/2024
A graph G and an integer k, k-edge-coloring of G is a
mapping from the set of the edges of G to a set of k
elements called colors so that two edges sharing an
endpoint are associated in the mapping with different
colors.
The edge chromatic index of a graph G is the lowest
integer k such that a k-coloring of G exists. This integer is
denoted by q(G). E.g. q(G) = 3 for the given figure below.
For each color, the set of the edges having the
same color forms is called a matching,
that is a set of edges of the graph such that
no two edges share a common endpoint.
3
11/25/2024
Basic Result
• It is easy to verify that the chromatic index is bounded as
follows:
Δ ≤ q(G) ≤ m
where m is the number of edges of the graph and Δ its
maximum degree. 3rd figure is known as Petersen’s graph
(chromatic index = 4).
11/25/2024
Chromatic Index
• Property: If G is a complete graph with n
vertices, then
q(G) = n – 1, if n is even
q(G) = n, if n is odd
Example (Matching Problem)
11/25/2024
• We can also ask what the minimum number of days
necessary is so that all the games can take place. Given
that each team plays each other team exactly once, we
need to plan n(n-1)/2 games.
11/25/2024
• Let’s draw the graph described above, putting the n vertex
in the centre and the other vertices in a circle
around vertex n.
On the first day, we organize a game between teams 1 and n,
2 and n-1, 3 and n-2, and so forth until the game between n/2
and n/2+1.
On the following days, we reproduce what happened the day
before, but we simply rotate the matchings clockwise.
Example (The Timetabling Problem)
11/25/2024
• Timetable problem can be seen as a form of
scheduling where the task is to allocate activities to
available slots within resources respecting some
constraints.
• There has been a lot of algorithms developed for this
particular problem using different techniques like
Graph Coloring, Tabu Search, Genetic Algorithm,
Optimization problem and so on..
•
Example (The Timetabling Problem)
11/25/2024
• Letus consider an example, In a college there are m
professors x1, x2, …, xm and n subjects y1, y2, …, yn to
be taught.
• Given that professor xi is required to teach subject yj
for pij periods.
• Constructa bipartite multigraph G with vertices x1, x2,
…, xm, and y1, y2, …, yn such that vertices xi and yj are
connected by pij edges.
• Initially
consider a single period. The timetable for this
single period corresponds to a matching in the graph
and, conversely, each matching corresponds to a
possible assignment of professors to subjects taught
Example (The Timetabling Problem)
11/25/2024
• Thus, the solution to the timetabling problem consists
of partitioning the edges of G into the minimum
number of matching's. Equivalently, we must properly
color the edges of G with the minimum number of
colors.
• Suppose there are four professors x1, x2, x3, x4 and five
subjects y1, y2, y3, y4, y5 to be taught.
Example (The Timetabling Problem)
11/25/2024
• Then, from the edge coloring of G, we obtain a solution
of the given timetabling problem as shown below:
• Edge Coloring:
({x1, y1}, green), ({x1, y1}, red), ({x1, y3}, blue),
({x1, y4}, yellow),
({x2, y2}, yellow), ({x2, y4}, green),
({x3, y2}, green), ({x3, y3}, yellow), ({x3, y4}, red),
({x4, y4}, blue), ({x4, y5}, yellow).
Example (The Timetabling Problem)
11/25/2024
Vertex Coloring
11/25/2024
Suppose C = [c1 , c2, . . .} is a set of undefined
objects called colors. A C-coloring (or C- vertex
coloring) f of a graph G is a map:
f: V(G) → C.
The sets Vi = [x: f(x) = Ci } are called color classes.
Alternatively, a coloring could be defined as a
partition of V(G) into color classes.
A proper coloring of G is a coloring in which no two
adjacent vertices belong to the same color class. In
other words,
x ~ y ⇒ f(x) ≠ f(y) .
A proper coloring is called an n-coloring if C has n
elements. If G has an n-coloring, then G is called n-
colorable. 14
Timetabling Problem by Vertex Coloring
11/25/2024
• Recall that the line graph L(G) of G has as vertices the
edges of G and two vertices in L(G) are connected by an
edge if and only if the corresponding edges in G have a
vertex in common.
• The line graph L(G) is a simple graph and a proper vertex
coloring of L(G) yields a proper edge coloring of G using the
same number of colors.
• Thus, to solve the timetabling problem, it needs to find a
minimum proper vertex coloring of L(G). We demonstrate
the solution with a small example.
Timetabling Problem by Vertex Coloring
11/25/2024
• Suppose there are four professors x1, x2, x3, x4 and five
subjects y1, y2, y3, y4, y5 to be taught.
• The teaching requirement matrix p = [ pij ] is as shown:
p y1 y2 y3 y4 y5
x1 2 0 1 1 0
x2 0 1 0 1 0
x3 0 1 1 1 0
x4 0 0 0 1 1
11/25/2024
• Vertex Coloring: Now each edge of previous graph G
represents as vertex in L(G). (1, green), (2, red), (3, blue),
(4, yellow), (5, yellow), (6, green), (7, green), (8, yellow), (9,
red), (10, blue), (11, yellow).
• This, in turn, yields a minimum proper
vertex 4-coloring of the bipartite
multigraph G:
Chromatic number
11/25/2024
•A clique in a graph G is a complete subgraph maximal
under inclusion. The cardinality of a maximum clique is
denoted by ω(G).
• The chromatic number of a graph G is the smallest
number k such that G is k-colorable, and it is denoted
by χ(G). An obvious lower bound for χ(G) is ω(G):
ω(G) ≤ χ(G) ∀G.
• "G is n-chromatic" to mean that χ(G ) = n.
18
Example
11/25/2024
• Six
friends decide to spend the afternoon playing
chess. Everyone will play everyone else once. They
have plenty of chess sets but nobody wants to play
more than one game at a time. Games will last an
hour (thanks to their handy chess clocks). How
many hours will the tournament last?
Solution
11/25/2024
• Representeach player with a vertex and put an edge
between two players if they will play each other. In this
case, we get the graph K6:
• We must color the edges; each color represents a
different hour. Since different edges incident to the
same vertex will be colored differently, no player will be
playing two different games (edges) at the same time.
Thus, we need to know the chromatic index of K 6.
• Notice that for sure q(K6)≥5, since
there is a vertex of degree 5.
It turns out 5 colors is enough.
Therefore, the friends will play for 5 hours.
Counting Vertex Coloring
11/25/2024
• How many ways are there to color a given graph?
Count all possible colorings that are not identical, whether or not
any two are isomorphic.
For example, consider K2, a single edge with vertices y and z.
Write (A, B) to mean the coloring in which y is colored A and z is
colored B. K2 requires two colors, and there are two different
colorings, (A, B) and (B, A).
If three colors were available, there would be the six colorings (A,
B), (A, C), (B, A), (B, C), (C, A) and (C, B). (Not all available colors
actually have to be used.)
• Wewrite pG(x) for the number of different colorings of G
with x colors. qG(x) will denote the number of these
colorings in which all x colorings are actually used. SO
pK2(2) = qK2(2) = 2, PK2(3) = 6 and qK2(3) = 0. Clearly 21
11/25/2024
Total Number of Proper
Coloring
• The total number of proper colorings in x colors is found by
summing this term over k. It will be zero if k < χ(G) (no proper
colorings exist) or k > v(G) (the number of colors actually
used cannot exceed the number of vertices). So
22
11/25/2024
Example
• To count the proper colorings of Kv(Complete Graph),
suppose the vertices have been ordered in some way
and x colors are available. The first vertex can be
assigned any of the x colors. There are then x – 1
colors for the second vertex, x – 2 for the third, and so
on, so
k
• For example:
k–1 k–2
23
11/25/2024
Applications
• The problem of coloring a graph has several
applications such as scheduling, register allocation in
compilers, frequency assignment in Mobile radios, etc.
24
11/25/2024
Terminology
• 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
25
11/25/2024
Example
27
11/25/2024
Example (cont)
11/25/2024
• There are a total of 16 people attending the rehearsal
dinner: A, B, C, … H are relatives of the bride and
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.
29
11/25/2024
• 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.
30
11/25/2024
Conclusion
• The conclusion to our analysis is:
• (i) the minimum number of tables needed to sit the
wedding party is three, and
• (ii) the seating assignment should put A, B, and E in
one table (red), C and F in a second table (blue), and
D, G, and H in the third table (green). The remaining
members of the wedding party can be arbitrarily
assigned to fill up the remaining seats at the three
tables.
31
11/25/2024
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 can have the same color. The only
possible way to color K5 is to use a different color for
each vertex, as in Figure (b). Thus, we can conclude
that χ(K5) = 5.
32
Optimal Coloring
11/25/2024
• An optimal coloring of a graph G is a coloring 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 (c1) to the first
vertex (v1).
■ Step 2. Vertex (v2) is assigned color (c1) 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).
33
11/25/2024
Approximate Colouring
Algorithm
• Sort the vertices 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(n2)
34
11/25/2024
A Sequential Greedy algorithm
Initially I
G
35
11/25/2024
Phase 1:
v1 G G1
36
11/25/2024
Remove v1and neighbors N (v1)
G1
37
11/25/2024
Remove v1and neighbors N (v1)
G2
38
11/25/2024
Phase 2:
G2
v2
39
11/25/2024
Remove v2 and neighbors N (v2 )
G2
v2
40
11/25/2024
Remove v2 and neighbors N (v2 )
G3
41
11/25/2024
Phases 3,4,5,…:
Repeat until all nodes are removed
G3
42
11/25/2024
Phases 3,4,5,…,x:
Repeat until all nodes are removed
Gx 1
No remaining nodes
43
11/25/2024
At the end, set I will be an MIS of G
G
44
Map Coloring with Dual
11/25/2024
Graphs
• Figure (a) shows a small map 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,
and thus cannot be colored with 2 colors. The
corresponding optimal coloring of the map is shown in
Figure (d).
45
11/25/2024
Edge Coloring
• Given a graph G=(V,E) how can we color the edges such
that edges that share a vertex do not share a color.
• A k-edge-coloring q of a graph G is a map from E(G) to {I,
2, ... , k}, with the property that if e and f are edges with a
common vertex, then q(e) ≠ q(f).
46
11/25/2024
Line Graph
• An Edge Coloring Problem can be formulated as a
Vertex Coloring Problem.
• Let L(G) be an auxiliary graph and G be the graphs
which we are trying to color. L(G) contains a vertex
for every edge in G. There is an edge in L(G) drawn
between two vertices if their associated edges in G
share a vertex.
47
11/25/2024
Example Auxiliary Graph
A C
B B C
48
11/25/2024
Example Auxiliary Graph
A B
B
A E
E
D C
C D
A B
B
A E
E
D C
C D
49
Independent Sets
11/25/2024
• 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 edge of G.
α(G)=3
50
11/25/2024
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 be
maximal, if it is not a subset of any larger independent
set;
maximum, if there is no larger independent set in the
graph. A set that can not be extended to a larger
independent set.
• For S ⊆ V , neighborhood of S is defined as N(S) = ∪v∈S
N(v).
51
11/25/2024
An Example: maximal
independent set
54
11/25/2024
Find the MIS
Greedy(G):
S = {}
While G is not empty:
Let v be a node with maximum degree in G
S = union(S, {v})
remove v and its neighbors from G
return S
55
11/25/2024
Greedy Algorithm for
Maximum Independent Set
Greedy(G):
S = {}
While G is not empty:
Let v be a node with minimum degree in G
S = union(S, {v})
remove v and its neighbors from G
return S
56