



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Version: 0.
A natural tendency in solving algorithmic problem is to locally do whats seems to be the right thing. This is usually referred to as greedy algorithms. The problem is that usually these kind of algorithms do not really work. For example, consider the following optimization version of V C:
Problem: VCM Instance: A graph G, and integer k. Output: Return the smallest subset S ⊆ V(G), s.t. S touches all the edges of G.
For this problem, the greedy algorithm will always take the vertex with the highest degree (i.e., the one covering the largest number of vertices), add it to the cover set, remove it from the graph, and repeat. We will refer to this algorithm as GreedyVertexCover.
Figure 1: Example.
It is not too hard to see that this algorithm in fact, does not output the optimal vertex-cover. Indeed, consider the graph in Figure 1: Clearly, the optimal solution is the black vertices, but the greedy algorithm would pick the four white vertices. This of course still leaves open the possibility that while we do not get the optimal vertex cover, but we still get a vertex cover which is “relatively good”?
Definition 1.1 A minimization problem is an optimization problem, where we look for a valid solution that minimizes a certain target function.
Example 1.2 In the VCM problem the (minimization) target function is the size of the cover. Formally Opt(G) = minS ⊆V(G),S cover of G |S |. The VertexCover(G) is just the set S realizing this minimum.
Definition 1.3 Let Opt(G) denote the value of the target function for the optimal solution.
Thus, a vertex-cover of size“close” to the optimal solution would be considered to be good.
Definition 1.4 Algorithm Alg for a minimization problem M achieves an approximation factor α if for all inputs, we have: Alg(G) Opt(G)
≤ α.
We will refer to Alg as an α-approximation algorithm for M.
As a concrete example, an algorithm is a 2-approximation for VCM, if it outputs a vertex-cover which is at most twice the size of the optimal solution for vertex cover. So, how good (or bad) is the GreedyVertexCover algorithm de- scribed above? Well, the graph in Figure 1 shows that the approxima- tion factor of GreedyVertexCover is at least 4 /3. It turns out that in fact, GreedyVertexCover, has in fact much worse performance. To this end, consider the following bipartite graph: Gn = (L ∪ R, E), where L is a set of n vertices. Next, for i = 2 ,... , n, we add a set Ri of bn/ic vertices, to R, each one of them of degree i, such that all of them (i.e., all vertices of degree i at L) are connected to distinct vertices in R. The execution of GreedyVertex- Cover on such a graph is shown on the right. Clearly, in Gn all the vertices in L have degree at most n − 1, since they are connected to (at most) one vertex of Ri, for i = 2 ,... , n. On the other hand, there is a vertex of degree n at R (i.e., the single ver- tex of Rn). Thus, GreedyVertexCover will first remove this vertex. We claim, that GreedyVertexCover will remove all the vertices of R 2 ,... , Rn and put them into the vertex-cover. To see that, observe that if R 2 ,... , Ri are still active, then all the nodes of Ri have degree i, all the vertices of L have degree at most i − 1, and all the vertices of R 2 ,... , Ri− 1 have degree strictly smaller than i. As such, the greedy algorithms will use the vertices of Ri. Easy induction now implies that all the vertices of R are going to be picked by GreedyVertexCover. This implies the following lemma.
Lemma 1.5 The algorithm GreedyVertexCover is Ω(log n) approximation to the optimal solution to V- CM.
Proof: Consider the graph Gn above. The optimal solution is to pick all the vertices of L, which are n. On the other hand, the greedy algorithm picks the set R. We have that
∑^ n
i= 2
|Ri| =
∑^ n
i= 2
⌊ (^) n i
∑^ n
i= 2
( (^) n i
≥ n
∑^ n
i= 1
i − 2 n = n(Hn − 2).
As such, the approximation ratio for GreedyVertexCover is ≥
n(Hn − 2) n = Ω(log n).
Theorem 1.6 The greedy algorithm for VertexCover achieves Θ(log n) approximation, where n is the num- ber of vertices in the graph.
Proof: The lower bound follows from Lemma 1.5. The upper bound follows from the analysis of the greedy of S C, which will be done shortly.
One can still do much better than the greedy algorithm in this case. In particular, let ApproxVertexCover be the algorithm that chooses an edge from G, add both endpoints to the vertex cover, and remove the two vertices (and all the edges adjacent to these two vertices) from G. This process is repeated till G has no edges. Clearly, the resulting set of vertices is a vertex-cover.
s
w
u
C v
s
w
u
C v
D
(a) (b) (c) (d)
Figure 2: The TSP approximation algorithm: (a) the input, (b) the duplicated graph, (c) the extracted Eule- rian tour, and (d) the resulting shortcut path.
Lemma 2.2 A graph G has a cycle that visits every edge of G exactly once (i.e., an Eulerian cycle) if and only if G is connected, and all the vertices have even degree. Such a cycle can be computed in O(n + m) time, where n and m are the number of vertices and edges of G, respectively.
Our purpose is to come up with a 2-approximation algorithm for TSP 4 ,-M. To this end, let Copt denote the optimal TSP tour in G. Observe that Copt is a spanning graph of G, and as such we have that
ω
Copt
≥ ω
cheapest spanning graph of G
But the cheapest spanning graph of G, is the minimum spanning tree (MST) of G, and as such ω(Copt) ≥ ω(MST(G)). And the MST can be computed in O(n log n + m) = O(n^2 ) time, where n is the number of vertices of G,and m =
(n 2
is the number of edges. Let T denote the MST of G, and covert T into a tour by duplicating every edge twice. Let H denote the new graph. We have that H is a connected graph, every vertex of H has even degree, and as such H has an Eulerian tour (i.e., a tour that visits every edge of H exactly once). As such, let C denote the Eulerian cycle in H. Observe that
ω(C) = ω(H) = 2 ω(T ) = 2 ω(MS T (G)) ≤ ω
Copt
Next, we traverse C starting from any vertex v ∈ V(C). As traverse C we skip visiting vertices that we already visited, and in particular, the new tour we extract from C will visit the vertices of V(G) in the order they first appear in C. Let π denote the new tour of G. Clearly, since we are performing shortcutting, and the triangle inequality holds, we have that ω(π) ≤ ω(C). The resulting algorithm is depicted in Figure 2. It is easy to verify, that all the steps of our algorithm can be done in polynomial time. As such, we have the following result.
Theorem 2.3 Given an instance of TSP with the triangle inequality (TSP 4 ,-M) (namely, a graph G with n vertices and
(n 2
edges, and a cost function ω(·) on the edges that comply with the triangle inequality), one can compute a tour of G of length ≤ 2 ω(Copt), where Copt is the minimum cost TSP tour of G. The running time of the algorithm is O(n^2 ).
2.1.2 A 3 / 2 -approximation
Let us revisit the concept of matchings.
Definition 2.4 Given a graph G = (V, E), a subset M ⊆ E is a matching if no pair of edges of M share endpoints. A perfect matching is a matching that covers all the vertices of G. Given a weight function w on the edges, a min-weight perfect matching, is the minimum weight matching over all perfect matching, where ω(M) =
e∈M
ω(e).
The following is a known result, and we had shown a somewhat weaker version of it in class.
Theorem 2.5 Given a graph G and weights on the edges, one can compute the min-weight perfect matching in polynomial time.
Definition 2.6 Let G be complete graph over V, with a weight function w on the edges, that comply with the triangle inequality. For a subset S ⊆ V, let GS be the induced subgraph over S. Namely, it is a complete graph over S , with the prices over the edges determined by w.
Lemma 2.7 Let G = (V, E) be a complete graph, S a subset of the vertices of V of even size, and w a weight function over the edges. Then, the weight of the min-weight perfect matching in GS is ≤ ω(T S P(G))/ 2.
S σ
π
Proof: Let π be the cycle realizing the TSP in G. Let σ be the cycle resulting from shortcutting π so that it uses only the vertices of S. Clearly, ω(σ) ≤ ω(π). Now, let Me and Mo be the sets of even and odd edges of σ respectively. Clearly, both Mo and Me are perfect matching in GS , and
ω(Mo) + ω(Me) = ω(σ).
We conclude, that min(w(Mo) , w(Me)) ≤ ω(TSP(G))/2.
1
4
2
3 5 7
6
We now have a creature that has the weight of half of the TSP, and we can compute it in polynomial time. How to use it to approximate the TSP? The idea is that we can make the MST of G into an Eulerian graph by being more careful. To this end, consider the tree on the right. Clearly, it is almost Eulerian, except for these pesky odd degree vertices. Indeed, if all the vertices of the spanning tree where even, then the graph would be Eulerian (see Lemma 2.2). In particular, in the depicted tree, the “problematic” vertices are 1, 4 , 2 , 7. Specifically, the problematic vertices are all all the odd degree vertices in the MST T.
Lemma 2.8 The number of odd degree vertices in any graph G′^ is even.
Proof: Observe that μ =
v∈V(G′) d(v)^ =^2 |E(G′)|. Let^ U^ =^
v∈V(G′),d(v) is even d(v), and observe that^ U^ is even as it is the sum of even numbers. Thus, Thus, ignoring vertices of even degree, we have
α =
v∈V,d(v) is odd
d(v) = μ − U = even number,
since μ and U are both even. Thus, the number of elements in the above sum of all odd numbers must be even, for the total sum to be even.