Download presentation
Presentation is loading. Please wait.
Published bySonia Poyner Modified over 10 years ago
1
Set Cover 資工碩一 9562635 簡裕峰
2
Set Cover Problem 2.1 (Set Cover) Given a universe U of n elements, a collection of subsets of U, S ={S 1,…,S k }, and a cost function c : S -> Q+, find a minimum cost subcollection of S that covers all elements of U.
3
Set Cover - ex Unit – U = {a, b, c, d, e} – S = {S 1, S 2, S 3, S 4 } – S 1 = {a, b, c} – S 2 = {b, c, d} – S 3 = {d, e} – S 4 = {a, c} Weighted – U = {a, b, c, d, e} – S = {S 1, S 2, S 3, S 4 } – S 1 = {a, b, c}, c(S 1 )=5 – S 2 = {b, c, d}, c(S 2 )=2 – S 3 = {d, e}, c(S 3 )=3 – S 4 = {a, c}, c(S 4 )=2
4
Set Cover Define the frequency of an element to be the number of sets it is in. Let us denote the frequency of the most frequent element by f. The various approximation algorithms for set cover achieve one of two factors : – O(log n) – f
5
Set Cover & Vertex Cover When f = 2 : (Ex2.7) – U = {a, b, c, d, e} – S 1 = {a, b} – S 2 = {a} – S 3 = {d, e} – S 4 = {c, e} – S 5 = {b, c, d} Factor 2 approximation algorithm in Chapter 1 S1 S5 S4S3 S2 ab d c e
6
Set Cover & Vertex Cover When f = 2 : (Ex2.7) – U = {a, b, c, d, e, f} – S 1 = {a, b} – S 2 = {a, f} – S 3 = {d, e} – S 4 = {c, e} – S 5 = {b, c, d} Factor 2 approximation algorithm in Chapter 1 S1 S5 S4S3 S2 ab d c e f
7
2.1 The Greedy algorithm Algorithm 2.2 Greedy set cover algorithm Iteratively pick the most cost-effective set and remove the covered elements, until all elements are covered.
8
2.1 The Greedy algorithm Unit – U = {a, b, c, d, e} – S = {S 1, S 2, S 3, S 4 } – S 1 = {a, b, c} – S 2 = {b, c, d} – S 3 = {d, e} – S 4 = {a, c} Weighted – U = {a, b, c, d, e} – S = {S 1, S 2, S 3, S 4 } – S 1 = {a, b, c}, c(S 1 )=5 – S 2 = {b, c, d}, c(S 2 )=2 – S 3 = {d, e}, c(S 3 )=3 – S 4 = {a, c}, c(S 4 )=2
9
2.1 The Greedy algorithm Let e 1,…,e n be this numbering. Lemma 2.3 Prove
10
2.1 The Greedy algorithm Theorem 2.4 The greedy algorithm is an H n factor approximation algorithm for the minimun set cover problem, where H n = 1 + ½ + … + 1/n. Prove : The total cost = By lemma 2.3, this is at most H n x OPT
11
2.1 The Greedy algorithm Example 2.5 The following is a tight example for algorithm 2.2 … 1+ε 1/n 1/(n-1) 1
12
2.2 Layering Let w : V -> Q+ be the function assigning weights to the vertices of the given graph G = (V,E). Degree-weighted: if there is a constant c > 0 such that the weight of each vertex v V is c x deg(v).
13
2.2 Layering Degree-weighted – w(S 1 ) = 2c – w(S 2 ) = 1c – w(S 3 ) = 2c – w(S 4 ) = 2c – w(S 5 ) = 3c S1 S5 S4S3 S2 ab d c e
14
2.2 Layering Lemma 2.6 Let w : V -> Q+ be a degree-weighted function. Then w(V) ≤ 2OPT. Prove OPT ≥ |E|, w(V) ≤ 2|E|
15
2.2 Layering Let us define the largest degree-weighted function in w as follow: – Remove all degree zero vertices from the graph – Over the remaining vertices, compute c = min{ w(v) / deg(v)}, – t(v) = c x deg(v) is the desired function – w`(v) = w(v) – t(v) to be the residual weight function.
16
2.2 Layering DkDk D k-1 D1D1 D0D0 W1W1 W0W0 W k-1 G0G0 G1G1 G k-1 GkGk
17
2.2 Layering 7 5 73 3 4 3 2 41 3 1 4 3 32 0 3
18
4 3 32 3 2 1 01 2 2 31
19
7 3 5 4 7 3 4 ~ 3 3 3 2 2 ~ 1 x ~ 1
20
2.2 Layering Theorem 2.7 The layer algorithm achieves an approximation guarantee of factor 2 for the vertex cover problem, assuming arbitrary vertex weights. Prove 1. ? The vertices we chosen is a vertex cover.
21
2.2 Layering Prove 2.8 Let C* be an optimal vertex cover w(C) ≤ 2 OPT If v W j, w(v) = If v V – C, w(v) ≥
22
2.3 Application to shortest superstring Problem 2.9 Given a finite alphabet ∑, and a set of n strings, S = {s 1,…,s n } ∑+, find a shortest string s that contains each s i as a substring. Without loss of generality, we may assume that no string s i is a substring of another string s j, i≠j.
23
2.3 Application to shortest superstring Algorithm 2.10 S 1. Use the greedy set cover algorithm to find a cover for the instance S. Let set( ),…, set( ) be the sets picked by this cover. 2.Concatenate the string,…,, in any order. 3.Output the resulting string. Say s.
24
2.3 Application to shortest superstring Lemma 2.11 s OPT ≤ OPTs ≤ 2OPT OPT : the length of the shortest superstring sS OPTs : an optimal solution to S
25
2.3 Application to shortest superstring
26
Theorem 2.12 This algorithm is a 2H n factor algorithm for the shortest superstring problem, where n is the number of strings in the given instance.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.