Unformatted text preview: With this observation, we can now formulate MCPMP as a linear program: X Z = Min ce xe e2E X subject to: xe 1 for all S V with jS j odd xe 0 for all e 2 E . We can now see that the value Z of this linear program is a lower bound on the cost of any perfect matching. In particular, for any perfect matching M , we let 8 xe = :1 if e 2 M ; 0 otherwise. Clearly, this assignment is a feasible solution to the linear program, so we know that Z cM . This bound also applies to a minimum-cost perfect matching M , so we have Z cM . Note that this is a huge linear program having one constraint for each S V of odd cardinality. Though it is too large to be solved in polynomial time by any of the linear programming algorithms we have seen, the ellipsoid method can actually solve this program in polynomial time. We do not consider this solution technique; rather we let the linear program and its dual serve as a tool for developing and analyzing the algorithm. We now consider the dual linear program: X Z = Max yS
S V; jS j odd e2 S X yS 0 for all S V with jS j odd. Note that by strong duality, the value Z of this dual linear program is the same as the value Z of the primal program. This dual linear program is used to verify that the perfect matching output by the algorithm is actually within a factor of 2 of optimal. The algorithm outputs two things: 1. a perfect matching M 0, and 2. a dual feasible solution y such that X cM 0 2 yS :
S V; jS j odd S V; e2 S yS ce for all e 2 E Approx-11 Since y is dual feasible, we know that X yS Z cM S V; jS j odd where M is any perfect matching. Thus we have cM 0 2Z 2cM where M is a min-cost perfect matching. The algorithm is therefore given that it runs in polynomial time a 2-approximation algorithm for MCPMP. To be precise, the algorithm need not actually output the dual feasible solution y | it is only needed as an analysis tool to prove the factor of 2 approximation bound. In spite of the fact that there are an exponential number of yS variables, the algorithm could actually compute and output the yS values since it turns out that only a polynomial number of them are non-zero. When we nally get to exhibiting the algorithm, we will include the computation of the yS values. 4.2 From forest to perfect matching Rather than directly compute the perfect matching M 0, the algorithm rst computes a forest F 0 from which M 0 can be derived. In the forest F 0, all components have even size, and furthermore, F 0 is edge-minimal in the sense that if any edge of F 0 is removed, then the resulting forest has an odd size component. Additionally, the cost of F 0 is bounded by twice the value of the dual feasible solution; that is, X cF 0 2 yS :
S V; jS j odd We now show how to convert F 0 into a perfect matching M 0 such that cM 0 cF 0. The idea is as follows. Starting from the forest F 0, consider any vertex v with degree at least 3. Take two edges u; v and v; w; remove them and replace them with the single edge u; w. Since the edge costs obey the triangle inequality, the resulting forest must have a cost not more than cF 0. Thus, if we can iterate on this operation until all vertices have degree 1, then we have our perfect matching M 0. The only thing that can get in the way of the operation just described is a vertex of degree 2. Fortunately, we can show that all vertices of F 0 have odd degree. Notice then that this property is preserved by the basic operation we are using. As a direct consequence, the property that all components are even is also preserved. Therefore, if all vertices of F 0 have odd degree, we can iteration the basic operation to produce a perfect matching M 0 such that cM 0 cF 0. Notice that M 0 is produced after On iterations. Lemma 3 All vertices of F 0 have odd degree.
Approx-12 Proof: Suppose there is a vertex v with even degree, and let v be in component Removing v and all its incident edges partitions A into an even number k of smaller components A1; A2; : : : ; Ak . If all k of these components have odd size, then it must be the case that A has odd size. But we know that A has even size | all components of F 0 have even size | so there must be a component Ai with even size. Let vi denote the vertex in Ai such that v; vi is an edge of F 0. Now if we start from F 0 and remove the edge v; vi, we separate A into two even size components. This contradicts the edge-minimality of F 0. A of F 0. 4.3 The algorithm The algorithm must now output an edge-minimal forest F 0 with even size components and be able to compute a dual feasible solution y such that cF 0 2 P yS . At the highest level, the algorithm is: 1. Start with F = ;. 2. As long as there exists an odd size component of F , add an edge between two components at least one of which has odd size. Note that the set of components of F is initially just the set of vertices V . The choice of edges is guided by the dual linear program shown earlier. We start with all the dual variables equal to zero; yS = 0. Suppose at some point in the execution we have a forest F as shown below and a dual solution y. Look at the
q @ ,
q q q 1 @, ,@
q q q q q q q @ q q q @ q A q 2 3 4 5 A 6 q q @ ,
q q 7 components S of odd cardinality components 1, 4, 6 and 7, in this case. For these components, increase yS by some , leaving all other values of yS unchanged. That is, 8 yS :yS + if S is an odd size component of F yS otherwise. Make as large as possible while keeping yS dual feasible. By doing this, we make the constraint on some edge e tight; for some e the constraint X yS ce
S V; e2 S becomes X S V; e2 S yS = ce: Approx-13 This is the edge e that we add to F . If more than one edge constraint becomes tight simultaneously, then just arbitrarily pick one of the edges to add. We now state the algorithm to compute F 0. The steps that compute the dual feasible solution y are commented out by placing the text in curly braces. 1 2 3 4 5 6 7 8 9 10 11 12 F ; c di, which minimizes = e,p+dCjq n 1 if jCj is C odd where C = 0 otherwise i.e., the parity of C . F F feg 8C 2 C with jC j odd do 8i 2 C do di di + fLet yC yC + .g C C n fCp; Cq g fCp Cq g F 0 edge-minimal F C ffig j i 2 V g fThe components of F g fLet yS 0 for all S with jS j odd.g 8i 2 V do di 0 fdi = PS3i yS g while 9C 2 C with jC j odd do Find edge e = i; j such that i 2 Cp, j 2 Cq , p 6= q 4.4 Analysis of the algorithm
a dual feasible solution. Lemma 4 The values of the variables yS computed by the above algorithm constitute Proof:
We show this by induction on the while loop. Speci cally, we show that at the start of each iteration, the values of the variables yS are feasible for the dual linear program. We want to show that for each edge e 2 E , X yS ce:
S V; e2 S The base case is trivial since all variables yS are initialized to zero and the cost function ce is nonnegative. Now consider an edge e0 = i0; j 0 and an iteration. There are two cases to consider. In the rst case, suppose both i0 and j 0 are in the same component at the start of the iteration. In this case, there is no component C 2 C for which e0 2 C . Therefore, since the only way a variable yS gets increased is when S is a component, none of the variables yS with e0 2 S get increased at this iteration. By the induction Approx-14 hypothesis, we assume the iteration starts with X yS c0e ;
S V; e 2 S 0 and therefore, since the left-hand-side of this inequality does not change during the iteration, this inequality is also satis ed at the start of the next iteration. In the second case, suppose i0 and j 0 are in di erent components; i0 2 Cp and 0 2 Cq at the start of the iteration. In this case, we can write j X X X yS = yS + yS
0 0 S V; e 2 S 0 S V; S V; i 2S j 2S 0 + dj 0 ; = di
0 0 where di is de ned by yS : S V; i2S 0 and j 0 are in di erent components, if S contains The equality follows because since i both i0 and j 0, then S is not and never has been a component; hence, for such a set S , we have yS = 0. We know that during this iteration di0 will be incremented by
0 0 0 di = X if and only if yCp is incremented by , and this occurs if and only if Cp = 1. Let d0i0 and d0j 0 be the new values of di0 and dj 0 after this iteration. Then we have d0i0 = di0 + Cp ; and d0j 0 = dj 0 + Cq : Now, by the way is chosen, we know that 0 , d 0 e c, di+ Cj : Cp q Thus, at the beginning of the next iteration we have X yS = d0i0 + d0j 0
0 0 0 0 = di0 + Cp + dj 0 + Cq = di0 + dj 0 + Cp + Cq 0 , d 0 e di0 + dj 0 + c, di+ Cj Cp + Cq Cp q = ce : Finally, for completeness sake, we note that the constraint yS 0 is satis ed because yS = 0 initially and 0. 0 0 0 0 0 0 0 0 0 0 S V; e 2 S 0 Approx-15 As a nal observation, we note that when the algorithm selects an edge e0, the corresponding constraint in the dual linear program becomes tight. This means that for all edges e 2 F , we have X yS = ce:
S V; e2 S 4.5 A simulated run of the algorithm Since the algorithm as given can be di cult to visualize, here is an example of how it would execute. See Figure 1. 6 4 5 3 7 8 1 2 Figure 1: A sample run of the algorithm. The various values of di are indicated by the shaded regions around the components. We'll assume a Euclidean distance metric to ease visualization. Now, initially, all points 1 through 8 are in separate components, and di is 0 for all i. Since the metric is Euclidean distance, the rst edge to be found will be 7; 8. Since both components are of odd size, will be half the distance between them ce , 0 , 0=1 + 1. Since, in fact, all components are of odd size, every di will be increased by this amount, as indicated by the innermost white circle around each point. The set f7; 8g now becomes a single component of even size. In general, we can see the next edge to be chosen by nding the pair of components whose boundaries in the picture can be most easily made to touch. Thus, the next edge is 3; 5, since the boundaries of their regions are closest, and the resulting values Approx-16 of di are represented by the dark gray bands around points 1 through 6. Note that the component f7; 8g does not increase its di values since it is of even size. We continue in this way, expanding the moats" around odd-sized components until all components are of even size. Since there is an even number of vertices and we always expand odd-sized components, we are guaranteed to reach such a point. 4.6 Final Steps of Algorithm and Proof of Correctness Let F 0 = fe 2 F : F n feg has an odd sized componentg. We will show that the F 0 so obtained is a forest with components of even cardinality and that it is edge minimal with respect to this property. It is obvious that F 0 is a forest since F 0 F and F is a forest. We will also show that the cost of this forest F 0, is less than or equal to twice the dual solution. In section 4.2 we showed how to build a matching from this forest with the cost of the matching less than or equal to the cost of the forest. Thus, this gives us a 2-approximation algorithm for matching. As an example see the gure given below. F F' Figure 2: Example showing how to get F 0 from F . Theorem 5 Let F 0 = fe 2 F : F n feg has an odd sized componentg. Then
1. every component of F 0 has an even number of vertices and F 0 is edge minimal with respect to this property.. 2. Pe2F ce 2 PS yS .
0 Proof: Let us rst show that every component of F 0 has an even number of vertices. Suppose not. Then consider the components of F . Every component of F has an even number of vertices by design of the algorithm. Consider a component of F 0 which has an odd number of vertices and let us denote it as Ti0. Let Ti be the component Approx-17 that Ti0 belongs to in F . Let N1; : : : ; Nj be the components of F within Ti obtained by removing Ti0 see gure 3. Ti has an even number of vertices. Nk with 1 k j has an even number of vertices because, otherwise, the edge from Nk to Ti0 would belong to F 0 by de nition. But this implies that Ti0 is even, which is a contradiction.
T i N N1 T i'
2 Nk Nj Figure 3: Every component of F 0 has an even of vertices. A simple proof by contradiction shows that F 0 is edge minimal. Suppose F 0 is not edge minimal. Then there is an edge or set of edges which can be removed which leave even sized components. Consider one such edge e. It falls into one of two categories: 1. Its removal divides a component into two even sized components. But this means that e was already removed by the de nition of F 0. 2. Its removal divides a component into two odd sized components. Despite the fact that other edges may be removed, as well, an two odd sized component will remain in the forest. Thus, e cannot be removed. Now let us prove the second portion of the theorem. In what follows, though we do not explicitly notate it, when we refer to a set S of vertices, we mean a set S of vertices with jS j odd. We observe that by the choice of the edges e in F , we have X ce = yS for all e 2 F . Thus,
S :e2 S X
0 ce =
= X X
e2F S :e2 S X yS jF 0 S
S Thus we need to show, X
S yS jF 0 S j 2 X yS Approx-18 We will show this by induction. In what follows, bear in mind that F 0 is what we have, at the end of the algorithm. We will show the above relation holds at every iteration. Initially, yS = 0. Thus the LHS and RHS are both zero. Thus, this is true initially. Let us suppose it is true at any intermediate stage in the algorithm. We will show that it will remain true in the next iteration. From one iteration to the next the only yS that change are those with C 2 C with jC j odd. Thus if we show the increase in the LHS is less than the RHS we are done. i.e. X jF 0 C j 2 jfC 2 C ; jC j oddgj C 2C ;jC j odd or X jF 0 C j 2jfC 2 C ; jC j oddgj C 2C ;jC j odd Now, de ne a graph H with C 2 C as vertices, with an edge between Cp and Cq if there exists an edge in F 0 f Cp Cqg. We can partition these vertices into two groups based on their cardinality. Those that have even cardinality and those that have odd cardinality. Remove from this graph all vertices that have even cardinality and are isolated they have no edges incident to them. We will denote the resulting set of vertices of odd and even cardinality by Odd and Even respectively. Now PC2C;jCj odd jF 0 C j corresponds to the sum of the degrees of vertices in Odd in the graph H . And, jfC 2 C ; jC j oddgj, corresponds to the number of vertices in odd. Thus we need to show: X dH v 2jOddj
v2Odd where dH v denotes the degree of node v in the graph H . Since F 0 is a forest, H is also a forest and we have: Number of edges in H number of vertices in H . Or P P v2Odd dH v + v2Even dH v jOddj + jEvenj 2 or X X dH v 2jOddj + 2 , dH v We now claim that if v 2 Even then v is not a leaf. If this is true then 2,dH v 0 for v 2 Even and so we are done. Suppose there is a vi 2 Even which is a leaf. Consider the component C in H that vi is contained in. By the construction of H , each tree in F 0 is either contained solely in the vertices represented by C or it is strictly outside C . Since each tree in F 0 contains an even number of vertices C does w.r.t. the original graph, as well. So vi and C , vi each contains an even number of vertices. As a result, removing the Approx-19
v2Odd v2Even edge between vi and C , vi would leave even sized components, thus contradicting the minimality of F 0. N1 N2 Ti Ci Nj Nk Figure 4: dH v 2 for v 2 Even 4.7 Some implementation details The algorithm can be implemented in On2 log n. For this purpose, notice that the number of iterations is at most n , 1 since F is a forest. The components of F can be maintained as a union- nd structure and, therefore, all mergings of components take On n; n where is the inverse Ackermann function. In order to get the On2 log n bound, we shall show that every iteration can be implemented in On log n time. In order to nd the edge e to add to F , we maintain a priority queue containing the edges between di erent components of F . This initialization of this priority queue takes On2 log n time. In order to describe the key of an edge, we need to introduce a notion of time. The time is initially set to zero and increases by in each iteration the time can be seen to be the maximum of di over all vertices i. The key of an edge e = i; j is equal to the time at which we would have ce = di + dj if the parity of the components containing i and j don't change. The edge to be selected is therefore the edge with minimum key and can be obtained in On log n. When two components merge, we need to update the keys of edges incident to the resulting component since the parity might have changed. By keeping track of only one edge between two components the one with smallest key, we need to update the keys of On edges when two components merge. This can be done in On log n Olog n per update. To complete the discussion, we need to show how to go from F to F 0. By performing a post-order traversal of the tree and computing the parity of the subtrees encountered in a recursive manner, this step can be implemented in On time. Approx-20 ...
View Full Document