資料結構與演算法 ( 下 )

49
資資資資資資資資 ( 資 ) 呂呂(Hsueh-I Lu) http://www.csie.ntu.edu.tw/~hil/ Approximation algorithms 1

Upload: ohio

Post on 05-Jan-2016

37 views

Category:

Documents


2 download

DESCRIPTION

資料結構與演算法 ( 下 ). 呂學一 (Hsueh-I Lu) http://www.csie.ntu.edu.tw/~hil/. Outline. Approximation algorithms Vertex cover Metric traveling salesman problem Set cover. Vertex Cover Problem. Input: A graph G Output: A smallest vertex subset of G that covers all edges of G . - PowerPoint PPT Presentation

TRANSCRIPT

PowerPoint Presentation

() (Hsueh-I Lu)http://www.csie.ntu.edu.tw/~hil/Approximation algorithms1

OutlineApproximation algorithmsVertex coverMetric traveling salesman problemSet coverApproximation algorithms2

Vertex Cover ProblemInput:A graph GOutput:A smallest vertex subset of G that covers all edges of G.Known to be NP-complete Approximation algorithms3

IllustrationApproximation algorithms4Algorithm 1Let S be the empty set.While the graph G still have edges left, repeat the following steps:Let (x, y) be an arbitrary edge of G.Put x and y in S.Delete all edges of incident to x or y from G.Output S.Approximation algorithms5IllustrationApproximation algorithms6Theorem 1Approximation algorithms73 things to check: Q1Q1: Does Algorithm 1 give a feasible solution?For this vertex cover problem, a feasible solution is a node set that covers all the edges.Finding an optimal feasible solution is hard, but finding a feasible solution could be easy.For this vertex cover problem, the set of all nodes of the graph is a feasible solution.A1: Yes. (Why?)Approximation algorithms83 things to check: Q2Q2: Does Algorithm 1 run in polynomial time?An exponential-time algorithm is not qualified to be an approximation algorithm.A2: Yes. (Why?)Approximation algorithms93 things to check: Q3Q3: Does Algorithm 1 give an approximate solution with approximation factor at most 2?Other names: 2-approximate solution, factor-2 approximationApproximation algorithms10A3: Yes. Its a 2-approximationSuppose that the algorithm runs for k iterations. Let S be the output of Algorithm 1. Let OPT be any optimal vertex cover of G.If k = 0, then |S| = |OPT| = 0. Therefore, |S| is no more than 2*|OPT|.(Why |OPT|=0?) Approximation algorithms11A3: Yes. Its a 2-approximationIf k > 0, then |S| = 2k. To show that |S| is indeed no more than 2*|OPT|, it suffices to ensure that |OPT| is at least k.Observe that all those k edges (u, v) chosen by Algorithm 1 in those k iterations form a matching of G. Just for OPT (or any feasible solution) to cover this matching requires k nodes.Approximation algorithms12IllustrationApproximation algorithms13Q4: Is the analysis tight?That is, we want to make sure that we did not underestimate the quality of the approximate solution obtained by the algorithm. Q: Could it be the case that the previous algorithm is actually a 1.5-approximation algorithm for the vertex cover problem?A: No.Approximation algorithms14A4: Yes. It is tight.Approximation algorithms15It turns out that This factor-2 approximation is still the best known approximation algorithm.It would be a significant result even if you can you reduce the approximation factor by merely a small constant to, say, 1.99?Approximation algorithms16Vertex cover v.s. indep. setRecall that S is a vertex cover of graph G=(V, E) if and only if V S is an independent set of G.Question: Does a 2-approximation algorithm for vertex cover imply a 2-approximation for maximum independent set?Approximation algorithms17Not necessarilyFor instance, G has 100 nodes.A minimum vertex cover of G has 49 nodes.Therefore, a maximum independent set of G has 51 nodes.A 2-approximate solution for vertex cover may have 98 nodes, whose complement is an independent set with only 2 nodes. The approximation factor is much more than 2Approximation algorithms18IllustrationApproximation algorithms19Optimal independent Set: 51 nodesOptimal vertex cover: 49 nodesA 2-approximate vertex cover: 98 nodes2 nodesApproximation algorithms20Metric Traveling Salesman ProblemInput: A complete graph with edge weights that satisfy triangle inequalities.Output: A minimum-weight cycle passing through each node of the input graph exactly once.IllustrationApproximation algorithms21232113242:(shortest path)Algorithm 2Step 1: Find a minimum-weight spanning tree T of G.Step 2: Let R be an Euler tour of the edge duplicated version of T starting from an arbitrary node of T.Step 3: Let P be the short-cut version of R.Step 4: Output P.Approximation algorithms22Euler tour R of a dup. T Shortcut P of RApproximation algorithms23abcdfeR: a b c d c e c b f b a.P: a b c d e f aTedge,degree, Euler tour.Theorem 2Approximation algorithms24Q1 and Q2A1: Yes, the output is a feasible solution, i.e., a path of G visiting each path exactly once. Here we need the property that G is a complete graph, since otherwise the shortcut P of R may not be as feasible solution.A2: Yes, the algorithm runs in polynomial time.Approximation algorithms25Q3: Is P a 2-approximate solution?Let OPT be an optimal solution to the metric traveling salesman problem.Since OPT with a minimum-weight edge of OPT deleted is also a spanning tree of G, we know the weight of T is no more than that of OPT.The weight of R is exactly two times that of T.The weight of P is no more than that of R.Here we need the triangle inequalities of edge weights.Therefore, A3: Yes.Approximation algorithms26Algorithm 3: ChristofideStep 1: Find a minimum-weight spanning tree T of G.Step 2: Let X consist of the odd-degree nodes of T. Let M be a minimum-weight perfect matching of G on X.Step 3: Let R be an Euler tour of the union of T and MNote that it is the single-edge version of T instead of the duplicated version of T.Step 4: Output P = the shortcut version of R.Approximation algorithms27

IllustrationApproximation algorithms28abcdfePerfect matchingGiven a set X of 2k nodes of a graph, the perfect matching problem seeks a minimum weight set of k disjoint edges that are incident to X.It can be solved in polynomial time.Jack Edmonds, first polynomial-time algorithm: O(m n2).

Approximation algorithms29

Theorem 3Approximation algorithms30Q1 and Q2A1: Yes, the output is a feasible solution, i.e., a path of G visiting each path exactly once. Observe that X has an even number of nodes. So, M exists.Also observe that each node in the union of T and M has an even degree, so R exists.A2: Yes, the algorithm runs in polynomial time.Approximation algorithms31Q3: Is P a 1.5-approximate solution?Let OPT be an optimal solution to the metric traveling salesman problem. We know the weight of T is no more than that of OPT.The weight of M is no more than 0.5 times that of OPT. (WHY?)The weight of R is no more than 1.5 times that of OPT.The weight of P is no more than that of R.Therefore, A3: Yes.Approximation algorithms32M versus OPTLet XOPT be an optimal metric salesman tour for the subgraph G[X] of G induced by X.The weight of XOPT is no more than that of OPT.XOPT contains two edge-disjoint sets of perfect matching of G[X].The weight of M is no more than one half of that of XOPT.Approximation algorithms33IllustrationApproximation algorithms34Theorem 3Approximation algorithms35Set coverApproximation algorithms36The set cover problemApproximation algorithms37IllustrationApproximation algorithms38NP-completeIt is in NP. (Why?)

It is NP-hard. (Why?)Can you obtain a reduction from the vertex cover problem to the set cover problem?Approximation algorithms39Algorithm 4Approximation algorithms40Illustration: greedy algo.Approximation algorithms41Theorem 4Approximation algorithms42Q1 and Q2A1: Yes, the output is a feasible solution, i.e., a collection of subsets whose union is the ground set {1, 2, , n}.

A2: Yes, the algorithm runs in polynomial time.Approximation algorithms43Q3: Is I an O(log n)-approximate solution?Approximation algorithms44PriceApproximation algorithms45Illustration: greedy algo.Approximation algorithms461/31/81/11/1BoundApproximation algorithms47A3: Yes.Approximation algorithms48Theorem 4Approximation algorithms49