Uploaded by Hưng Trần

edge-coloring

advertisement
Graph Algorithms
Edge Coloring
Graph Algorithms
The Input Graph
⋆ A simple and undirected graph G = (V, E) with n vertices
in V , m edges in E, and maximum degree ∆.
Graph Algorithms
1
Matchings
⋆ A matching, M ⊆ E, is a set of edges such that any 2
edges from the set do not intersect.
− ∀(u,v)6=(u′ ,v′)∈M (u 6= u′, u 6= v ′, v 6= u′, v 6= v ′).
⋆ A perfect matching, M ⊆ E, is a matching that covers all
the vertices.
− ∀u∈V ∃{(u, v) ∈ M }.
Graph Algorithms
2
Example: Matching
Graph Algorithms
3
Example: Maximal Matching
Graph Algorithms
4
Example: Maximum Size Matching
Graph Algorithms
5
Example: Perfect Matching
Graph Algorithms
6
Edge Covering
⋆ An edge covering, EC ⊆ E, is a set of edges such that any
vertex in V belongs to at least one of the edges in EC.
− ∀v∈V ∃e∈EC (e = (u, v)).
Graph Algorithms
7
Example: Edge Covering
Graph Algorithms
8
Example: Minimal Edge Covering
Graph Algorithms
9
Example: Minimum Size Edge Covering
Graph Algorithms
10
Matching and Edge Covering
Definition An isolated vertex is a vertex with no neighbors.
Proposition: EC + M = n for G with no isolated vertices.
Proof outline: Show that EC + M ≥ n and EC + M ≤ n
which imply EC + M = n.
Graph Algorithms
11
EC + M ≥ n
⋆ Construct a matching M ′.
⋆ Consider the edges of EC in any order.
⋆ Add an edge to M ′ if it does not intersect any edge that is
already in M ′.
⋆ The rest of the edges in EC connect a vertex from M ′ to
a vertex that is not in M ′.
⋆ Therefore, the number of edges in EC is the number of
edges in M ′ plus n − 2M ′ additional edges.
Graph Algorithms
12
EC + M ≥ n
EC = M ′ + (n − 2M ′)
= n − M′
≥ n−M
(∗ since M ≥ M ′ ∗)
⇒ EC + M ≥ n .
Graph Algorithms
13
EC + M ≤ n
⋆ Construct an edge covering EC ′.
⋆ EC ′ contains all the edges of the maximum matching M .
⋆ For each vertex that is not covered by M , add an edge that
contains it to EC ′.
⋆ Due to the maximality of M , there is no edge that covers
2 vertices that are not covered by M .
⋆ Therefore, the number of edges in EC ′ is the number of
edges in M plus n − 2M additional edges.
Graph Algorithms
14
EC + M ≤ n
EC ′ = M + (n − 2M )
= n−M
⇒ EC ≤ n − M
(∗ since EC ′ ≥ EC ∗)
⇒ EC + M ≤ n .
Graph Algorithms
15
Edge Coloring
Definition I:
⋆ A disjoint collection of matchings that cover all the edges
in the graph.
⋆ A partition E = M1 ∪ M2 ∪ · · · ∪ Mψ such that Mj is a
matching for all 1 ≤ j ≤ ψ.
Definition II:
⋆ An assignment of colors to the edges such that two
intersecting edges are assigned different colors.
⋆ A function c : E → {1, . . . , ψ} such that if v 6= w and
(u, v), (u, w) ∈ E then c(u, v) 6= c(u, w).
Observation: Both definitions are equivalent.
Graph Algorithms
16
Example: Edge Coloring
Graph Algorithms
17
Example: Edge Coloring with Minimum Number of Colors
Graph Algorithms
18
The Edge Coloring Problem
The optimization problem: Find an edge coloring with
minimum number of colors.
Notation: ψ(G) – the chromatic index of G – the minimum
number of colors required to color all the edges of G.
Hardness: A Hard problem to solve.
⋆ It is NP-Hard to decide if ψ(G) = ∆ or ψ(G) = ∆ + 1
where ∆ is the maximum degree in G.
Graph Algorithms
19
Bounds on the Chromatic Index
⋆ Let ∆ be the maximum degree in G.
⋆ Any edge coloring must use at least ∆ colors.
− ψ(G) ≥ ∆.
⋆ A greedy first-fit algorithm colors the edges of any graph
with at most 2∆ − 1 colors.
− ψ(G) ≤ 2∆ − 1.
⋆ There exists a polynomial time algorithm that colors any
graph with at most ∆ + 1 colors.
− ψ(G) ≤ ∆ + 1.
Graph Algorithms
20
More Bounds on the Chromatic Index
Notation: M (G) – size of the maximum matching in G.
⋆ M (G) ≤ ⌊n/2⌋.
l
m
Observation: ψ(G) ≥ Mm
(G) .
⋆ A pigeon hole argument: the size of each color-set is at
most M (G).
m
l
m
Corollary: ψ(G) ≥ ⌊n/2⌋
.
Graph Algorithms
21
Vertex Coloring vs. Edge Coloring
⋆ Matching is an easy problem while Independent Set is a
hard problem.
⋆ Edge Coloring is a hard problem while Vertex Coloring is a
very hard problem.
Graph Algorithms
22
Coloring the Edges the Star Graph Sn
⋆ In a star graph ∆ = n − 1.
⋆ Each edge must be colored with a different color
⇒ ψ(Sn) = ∆.
Graph Algorithms
23
Coloring the Edges of the Cycle Cn
⋆ In any cycle ∆ = 2.
⋆ For even n = 2k, edges alternate colors and 2 colors are
enough ⇒ ψ(C2k ) = ∆.
⋆ For odd n = 2k + 1, at least 1 edge is colored with a third
color ⇒ ψ(C2k+1) = ∆ + 1.
Graph Algorithms
24
Complete Bipartite Graphs
Bipartite graphs: V = A ∪ B and each edge is incident to
one vertex from A and one vertex from B.
Complete bipartite graphs Ka,b: There are a vertices in A,
b vertices in B, and all possible a · b edges exist.
Graph Algorithms
25
Coloring the Edges of K3,4
Graph Algorithms
26
Coloring the Edges of K3,4
Graph Algorithms
27
Coloring the Edges of K3,4
Graph Algorithms
28
Coloring the Edges of K3,4
Graph Algorithms
29
Coloring the Edges of Complete Bipartite Graphs
⋆ ∆ = max {a, b} in the complete bipartite graph Ka,b.
⋆ Let the vertices be v0, . . . , va−1 ∈ A and u0, . . . , ub−1 ∈ B.
⋆ Assume a ≤ b.
⋆ Color the edges in b = ∆ rounds with the colors 0, . . . , ∆−1.
⋆ In round 0 ≤ i ≤ ∆ − 1, color edges (vj , u(j+i) mod b) with
color i for 0 ≤ j ≤ a.
Graph Algorithms
30
Complete Graphs – Even n
⋆ ψ(Kn) = n − 1 = ∆ for an even n.
− n − 1 disjoint perfect matchings each of size n/2.
− m = (n − 1)(n/2) in a complete graph with n vertices.
Graph Algorithms
31
Complete Graphs – n = 2k power of 2
⋆ If k = 1 color the only edge with 1 = ∆ color.
⋆ If k > 1, partition the vertices into two Kn/2 cliques A and
B each with 2k−1 vertices.
⋆ Color the complete bipartite Kn/2,n/2 implied by the
partition V = A ∪ B with n/2 colors.
⋆ Recursively and in parallel, color both cliques A and B with
n/2 − 1 = ∆(Kn/2) colors.
⋆ All together, n − 1 = ∆ colors were used.
Graph Algorithms
32
Coloring the edges of K8
Graph Algorithms
33
Coloring the edges of K8
Graph Algorithms
34
Coloring the edges of K8
Graph Algorithms
35
Coloring the edges of K8
Graph Algorithms
36
Complete Graphs – Odd n
⋆ ψ(Kn) = n = ∆ + 1 for an odd n.
− ψ(Kn) ≤ ψ(Kn+1) = n because n + 1 is even.
n(n−1)
− ψ(Kn) ≥ (n(n−1)/2)
=
n
because
there
are
edges
((n−1)/2)
2
in Kn and the size of the maximum matching is n−1
2 .
Graph Algorithms
37
Coloring the Edges of Odd Complete Graphs
⋆ Arrange the vertices as a regular n-polygon.
⋆ Color the n edges on the perimeter of the polygon using n
colors.
⋆ Color an inside edge with the color of its parallel edge on
the perimeter of the polygon.
Graph Algorithms
38
Coloring the Edges of K7
Graph Algorithms
39
Coloring the Edges of K7
Graph Algorithms
40
Coloring the Edges of K7
Graph Algorithms
41
Coloring the Edges of K7
Graph Algorithms
42
Coloring the Edges of Odd Complete Graphs
Correctness: The coloring is legal:
⋆ Parallel edges do not intersect.
⋆ Each edge is parallel to exactly one perimeter edge.
Number of colors: ψ(K2k+1) = 2k + 1 = ∆ + 1.
Graph Algorithms
43
Coloring the Edges of Even Complete Graphs – Algorithm I
⋆ Let the vertices be 0, . . . , n − 1.
⋆ Color the edges of Kn−1 on the vertices 0, . . . , n − 2 using
the polygon algorithm.
⋆ For 0 ≤ x ≤ n − 2, color the edge (n − 1, x) with the only
color missing at x.
Graph Algorithms
44
Coloring the Edges of K8
Graph Algorithms
45
Coloring the Edges of K8
Graph Algorithms
46
Coloring the Edges of K8
Graph Algorithms
47
Coloring the Edges of Even Complete Graphs – Algorithm I
Correctness: The coloring is legal:
⋆ The coloring of Kn−1 implies a legal coloring for all the
edges except those incident to vertex n − 1.
⋆ Exactly 1 color is missing at a vertex x ∈ {0, . . . , n − 2}.
⋆ This is the color of the perimeter edge opposite to it.
⋆ The n − 1 perimeter edges are colored with different
colors.
Number of colors: ψ(K2k ) = 2k − 1 = ∆.
Graph Algorithms
48
Coloring the Edges of Even Complete Graphs – Algorithm II
⋆ Let the vertices be 0, . . . , n − 1.
⋆ In round 0 ≤ x ≤ n − 2, color the following edges with the
color x:
− (n − 1, x).
− (((x − 1) mod (n − 1)), ((x + 1) mod (n − 1))).
− (((x − 2) mod (n − 1)), ((x + 2) mod (n − 1))).
..
..
− (((x−( n2 −1)) mod (n−1), ((x+( n2 −1)) mod (n−1))).
Correctness and number of colors: The same as Algorithm
I since both algorithms are equivalent!
Graph Algorithms
49
Coloring the Edges of Even Complete Graphs – Algorithm II
6
5
4
0
7
1
3
2
Graph Algorithms
50
Coloring the Edges of Even Complete Graphs – Algorithm III
⋆ Let 0 ≤ i < j ≤ n − 1 be 2 vertices.
⋆ Case j = n − 1:
color the edge (i, j) with the color i.
⋆ Case i + j is even:
color the edge (i, j) with the color i+j
2 .
⋆ Case i + j is odd and i + j < n − 1:
color the edge (i, j) with the color i+j+(n−1)
.
2
⋆ Case i + j is odd and i + j ≥ n − 1:
color the edge (i, j) with the color i+j−(n−1)
.
2
Correctness and number of edges: The same as Algorithm
I and Algorithm II since all three algorithms are equivalent!
Graph Algorithms
51
Coloring the Edges of Even Complete Graphs – Algorithm III
6
5
4
0
7
1
3
2
Graph Algorithms
52
Greedy First Fit Edge Coloring
Algorithm: Color the edges of G with 2∆ − 1 colors.
⋆ Consider the edges in an arbitrary order.
⋆ Color an edge with the first available color among
{1, 2, . . . , 2∆ − 1}.
Correctness: At the time of coloring, at most 2∆ − 2 colors
are not available. By the pigeon hole argument there exists
an available color.
Graph Algorithms
53
Complexity
⋆ m edges to color.
⋆ O(∆) to find the available color for any edge.
⋆ Overall, O(∆m) complexity.
Graph Algorithms
54
Coloring the Vertices of the Line Graph L(G)
⋆ Coloring the edges of G is equivalent to coloring the vertices
of the line graph L(G) of G.
⋆ If the maximum degree in G is ∆ then the maximum degree
in L(G) is ∆(L(G)) = 2∆ − 2.
⋆ The greedy coloring of the edges of G with 2∆ − 1 colors
is equivalent to the greedy coloring of the vertices of L(G)
with ∆(L(G)) + 1 = 2∆ − 1 colors.
Graph Algorithms
55
Coloring the Vertices of the Line Graph L(G)
Graph Algorithms
56
Subgraphs Definitions
⋆ For colors x and y, let G(x, y) be the subgraph of G
containing all the vertices of G and only the edges whose
colors are x or y.
⋆ For a vertex w, let Gw (x, y) be the connected component
of G(x, y) that contains w.
Graph Algorithms
57
Observation
⋆ G(x, y) is a collection of even size cycles and paths.
Graph Algorithms
58
Exchanging Colors Tool
⋆ Exchanging between the colors x and y in the connected
component Gw (x, y) of G(x, y) results with another legal
coloring.
w
Graph Algorithms
w
59
Coloring the edges of Bipartite Graphs with ∆ Colors
⋆ Color the edges with the colors {1, 2, . . . , ∆} following an
arbitrary order. Let (u, v) be the next edge to color.
⋆ At most ∆ − 1 edges containing u or v are colored ⇒ one
color cu is missing at u and one color cv is missing at v.
⋆ If cu = cv then color the edge (u, v) with the color cu = cv .
u(c u)
v( c v)
Graph Algorithms
60
Coloring the Edges of Bipartite Graphs with ∆ Colors
⋆ Assume cu 6= cv .
⋆ Let Gu(cu, cv ) be the connected component of the subgraph
of G containing only edges colored with cu and cv .
⋆ Gu(cu, cv ) is a path starting at u with a cv colored edge.
u(c u)
v( c v)
Graph Algorithms
61
Coloring the Edges of Bipartite Graphs with ∆ Colors
⋆ The colors in Gu(cu, cv ) alternate between cv and cu.
⋆ The first edge in the path starting at u is colored cv ⇒
any edge in the path that starts at the side of u must be
colored with cv .
⋆ v does not belong to Gu(cu, cv ) because cv is missing at v.
u(c u)
v( c v)
Graph Algorithms
62
Coloring the Edges of Bipartite Graphs with ∆ Colors
⋆ Exchange between the colors cu and cv in Gu(cu, cv ).
⋆ cv is missing at both u and v: color the edge (u, v) with
the color cv .
v( c v)
u(c u)
Graph Algorithms
v( c v)
u(c v)
63
Complexity
⋆ m edges to color.
⋆ O(∆) to find the missing colors at u and v.
⋆ O(n) to change the colors in Gu(cu, cv ).
⋆ Overall, O(nm) complexity.
Graph Algorithms
64
Coloring the Edges of Any Graph with ∆ + 1 Colors
⋆ Color the edges with the colors {1, 2, . . . , ∆ + 1} following
an arbitrary order. Let (v0, v1) be the next edge to color.
⋆ At most ∆ − 1 edges containing v0 or v1 are colored ⇒ one
color c0 is missing at v0 and one color c1 is missing at v1.
v1(c 1)
Graph Algorithms
v0(c 0)
65
Coloring the edges of Any Graph with ∆ + 1 Colors
⋆ If c0 = c1 then color the edge (v0, v1) with the color c0 = c1.
v1(c 1)
Graph Algorithms
v0(c 0)
66
Coloring the Edges Any Graph with ∆ + 1 Colors
⋆ Assume c0 6= c1.
⋆ Construct a sequence of distinct colors c0, c1, c2, . . . , cj−1, cj
and a sequence of edges (v0, v1), (v0, v2), . . . , (v0, vj ).
− Color ci is missing at vi for 0 ≤ i ≤ j.
− ci is the color of the edge (v0, vi+1) for 1 ≤ i ≤ j.
v3(c 3)
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
67
Constructing the Sequence
v1 (c 1)
Graph Algorithms
v0(c 0)
68
Constructing the Sequence
v2 (c 2)
v1 (c 1)
Graph Algorithms
v0(c 0)
69
Constructing the Sequence
v3(c 3)
v2 (c 2)
v1 (c 1)
Graph Algorithms
v0(c 0)
70
Constructing the Sequence
v3(c 3)
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
71
Constructing the Sequence
⋆ The edge (v0, v1) and the colors c0, c1 are initially defined.
⋆ Assume the colors c0, c1, . . . , cj−1 and the edges
(v0, v1), (v0, v2), . . . , (v0, vj ) are defined:
− ci is missing at vi for 0 ≤ i ≤ j − 1.
− ci is the color of the edge (v0, vi+1) for 1 ≤ i ≤ j − 1.
⋆ Let cj be a color missing at vj .
⋆ If there exists an edge (v0, vj+1) colored with cj , where
vj+1 ∈
/ {v1, . . . , vj }, then continue constructing the
sequence with the defined cj and vj+1.
Graph Algorithms
72
The Process Terminates
⋆ Since v0 has only ∆ neighbors, the construction process
stops with one of the following cases:
Case I: There is no edge (v0, v) colored with cj .
Case II: For some 2 ≤ k < j: cj = ck−1
⇒ the edge (v0, vk ) is colored with cj .
Graph Algorithms
73
Case I
⋆ The color cj is missing at v0.
v3(c 3)
v2 (c 2)
vj-1(c j-1)
vj (c j )
v1 (c 1)
v0(c 0, c j)
Graph Algorithms
74
Case I
⋆ Shift colors: Color (v0, vi) with ci for 1 ≤ i ≤ j − 1.
v3
vj-1
v2
v1
Graph Algorithms
v0(c 0, c j)
vj (c j )
75
Case I
⋆ cj is missing at both v0 and vj : color (v0, vj ) with cj .
v3
vj-1
v2
v1
Graph Algorithms
v0(c 0, c j)
vj (c j )
76
Case II
⋆ For some 2 ≤ k < j: cj = ck−1
⇒ (v0, vk ) is colored with cj .
vk (c k)
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
77
Case II
⋆ Shift colors: color (v0, vi) with ci for 1 ≤ i ≤ k − 1.
⋆ The edge (v0, vk ) is not colored.
⋆ cj is missing at both vk and vj .
v k( c j )
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
78
Case II
⋆ Consider the sub-graph G(c0, cj ) of G containing only the
edges colored with c0 and cj .
⋆ G(c0, cj ) is a collection of paths and cycles; v0, vk , vj are
end-vertices of paths in G(c0, cj ).
⋆ Not all of the 3 vertices v0, vk , vj are in the same connected
component of G(c0, cj ).
Case II.I v0 and vk are in different connected components of
G(c0, cj ).
Case II.II v0 and vj are in different connected components
of G(c0, cj ).
Graph Algorithms
79
Case II.I
⋆ v0, vk are in different connected components of G(c0, cj ).
v k( c j )
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
80
Case II.I
⋆ Exchange between c0 and cj in the vk -path in G(c0, cj ).
v k(c 0)
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
81
Case II.I
⋆ c0 is missing at both v0 and vk : color (v0, vk ) with c0.
v k(c 0)
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
82
Case II.II
⋆ v0, vj are in different connected components of G(c0, cj ).
v k( c j )
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
83
Case II.II
⋆ Shift colors: Color (v0, vi) with ci for k ≤ i ≤ j − 1.
⋆ The edge (v0, vj ) is not colored.
v k( c j )
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
84
Case II.II
⋆ The shift process does not involve c0 and cj ⇒ v0 and vj
are still in different connected components of G(c0, cj ).
⋆ cj is missing at vj and c0 is missing in v0.
v k( c j )
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
vj (c j )
v0(c 0)
85
Case II.II
⋆ Exchange between c0 and cj in the vj -path in G(c0, cj ).
v k( c j )
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
v j (c 0)
v0(c 0)
86
Case II.II
⋆ c0 is missing at both v0 and vj : color (v0, vj ) with c0.
v k( c j )
v2 (c 2)
v1 (c 1)
Graph Algorithms
vj-1(c j-1)
v j (c 0)
v0(c 0)
87
Complexity
⋆ m edges to color.
⋆ O(∆2) to find v1, . . . , vj .
⋆ O(n) to exchange colors.
⋆ Overall, O(nm + ∆2m) complexity.
Graph Algorithms
88
Download