9
JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.1(1-9) Theoretical Computer Science ••• (••••) •••••• Contents lists available at ScienceDirect Theoretical Computer Science www.elsevier.com/locate/tcs Parameterized and approximation algorithms for finding two disjoint matchings Zhi-Zhong Chen a,, Ying Fan b , Lusheng Wang b a Division of Information System Design, Tokyo Denki University, Hatoyama, Saitama 350-0394, Japan b Department of Computer Science, City University of Hong Kong, Tat Chee Avenue, Kowloon, Hong Kong Special Administrative Region article info abstract Article history: Received 26 January 2014 Received in revised form 6 March 2014 Accepted 25 March 2014 Available online xxxx Keywords: Fixed-parameter algorithms Approximation algorithms Color-coding Universal sets Matchings We first present a randomized fixed-parameter algorithm for the NP-hard problem of deciding if there are two matchings M 1 and M 2 in a given graph G such that | M 1 |+| M 2 | is a given number k. The algorithm runs in O (2 k k(m + n)) expected time and can be derandomized to run in O (2 2k+12 log 2 (2k) kn(m + n)) time, where n (respectively, m) is the number of vertices (respectively, edges) in G. We then extend the algorithm to the weighted version of the problem. We further present a combinatorial approximation algorithm for the NP-hard problem of finding two disjoint matchings in a given edge- weighted graph G so that their total weight is maximized. The algorithm achieves an approximation ratio close to 0.76 and runs in O (m + n 3 α(n)) time, where α is the inverse Ackermann function. © 2014 Elsevier B.V. All rights reserved. 1. Introduction Throughout this paper, a graph means an undirected graph that may have parallel edges but no self-loops. A graph is simple if it has no parallel edges. A matching in a graph G is a set F of edges in G such that no two edges in F share an endpoint. A maximum matching in G is a matching in G whose cardinality is maximized over all matchings in G . Given a graph G , the maximum matching problem (MM for short) requires the computation of a maximum matching in G . MM is very fundamental in many areas and has been extensively studied in the literature. In this paper, we consider a generalization of MM, called the maximum two-matching problem (MTM for short). Given a graph G , MTM requires the computation of two disjoint matchings in G whose total cardinality is maximized. Motivated by call admittance issues in satellite based telecommunication networks, Feige et al. [8] introduced MTM (among others) and showed its APX-hardness. They also observed that MTM is obviously a special case of the well-known maximum coverage problem (see [13]): We wish to cover the maximum number of edges of a given graph G with two sets each of which is a matching of G . Since this special case of the maximum coverage problem can be approximated by a greedy algorithm within a ratio of 0.75 [13], so can be MTM. They then gave a randomized approximation algorithm for MTM that achieves an expected ratio of 10 13 0.769. Their algorithm is based on an LP approach and random rounding. In particular, their LP has an exponential number of constraints and hence can only be solved by using the ellipsoid method together with a separation oracle. Hence, their algorithm is extremely slow although its running time is polynomial. * Corresponding author. E-mail addresses: [email protected] (Z.-Z. Chen), [email protected] (L. Wang). http://dx.doi.org/10.1016/j.tcs.2014.03.030 0304-3975/© 2014 Elsevier B.V. All rights reserved.

Parameterized and approximation algorithms for finding two disjoint matchings

  • Upload
    lusheng

  • View
    217

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.1 (1-9)

Theoretical Computer Science ••• (••••) •••–•••

Contents lists available at ScienceDirect

Theoretical Computer Science

www.elsevier.com/locate/tcs

Parameterized and approximation algorithms for finding twodisjoint matchings

Zhi-Zhong Chen a,∗, Ying Fan b, Lusheng Wang b

a Division of Information System Design, Tokyo Denki University, Hatoyama, Saitama 350-0394, Japanb Department of Computer Science, City University of Hong Kong, Tat Chee Avenue, Kowloon, Hong Kong Special Administrative Region

a r t i c l e i n f o a b s t r a c t

Article history:Received 26 January 2014Received in revised form 6 March 2014Accepted 25 March 2014Available online xxxx

Keywords:Fixed-parameter algorithmsApproximation algorithmsColor-codingUniversal setsMatchings

We first present a randomized fixed-parameter algorithm for the NP-hard problem ofdeciding if there are two matchings M1 and M2 in a given graph G such that |M1| + |M2|is a given number k. The algorithm runs in O (2kk(m + n)) expected time and can be

derandomized to run in O (22k+12 log2(2k)kn(m + n)) time, where n (respectively, m) isthe number of vertices (respectively, edges) in G . We then extend the algorithm tothe weighted version of the problem. We further present a combinatorial approximationalgorithm for the NP-hard problem of finding two disjoint matchings in a given edge-weighted graph G so that their total weight is maximized. The algorithm achieves anapproximation ratio close to 0.76 and runs in O (m + n3α(n)) time, where α is the inverseAckermann function.

© 2014 Elsevier B.V. All rights reserved.

1. Introduction

Throughout this paper, a graph means an undirected graph that may have parallel edges but no self-loops. A graph issimple if it has no parallel edges. A matching in a graph G is a set F of edges in G such that no two edges in F share anendpoint. A maximum matching in G is a matching in G whose cardinality is maximized over all matchings in G . Given agraph G , the maximum matching problem (MM for short) requires the computation of a maximum matching in G . MM isvery fundamental in many areas and has been extensively studied in the literature.

In this paper, we consider a generalization of MM, called the maximum two-matching problem (MTM for short). Given agraph G , MTM requires the computation of two disjoint matchings in G whose total cardinality is maximized. Motivated bycall admittance issues in satellite based telecommunication networks, Feige et al. [8] introduced MTM (among others) andshowed its APX-hardness. They also observed that MTM is obviously a special case of the well-known maximum coverageproblem (see [13]): We wish to cover the maximum number of edges of a given graph G with two sets each of which isa matching of G . Since this special case of the maximum coverage problem can be approximated by a greedy algorithmwithin a ratio of 0.75 [13], so can be MTM. They then gave a randomized approximation algorithm for MTM that achievesan expected ratio of 10

13 ≈ 0.769. Their algorithm is based on an LP approach and random rounding. In particular, their LPhas an exponential number of constraints and hence can only be solved by using the ellipsoid method together with aseparation oracle. Hence, their algorithm is extremely slow although its running time is polynomial.

* Corresponding author.E-mail addresses: [email protected] (Z.-Z. Chen), [email protected] (L. Wang).

http://dx.doi.org/10.1016/j.tcs.2014.03.0300304-3975/© 2014 Elsevier B.V. All rights reserved.

Page 2: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.2 (1-9)

2 Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–•••

The simple case of MTM (SMTM for short) where the input graph is simple has been studied recently [8,15,6,5,14,4].Feige et al. [8] gave a simple approximation algorithm for SMTM that achieves a ratio of 0.8. This ratio was then improvedin a series of papers [15,6,5,14,4]. The best known ratio achieved by a polynomial-time approximation algorithm for SMTM

is roughly 0.842 [4]. All known approximation algorithms for SMTM start by using Hartvigsen’s polynomial-time algorithm[11] to compute a maximum-sized subgraph H of the input graph such that the degree of each vertex in H is at most 2and there is no cycle of length 3 in H . Unfortunately, Hartvigsen’s algorithm only works for simple graphs.

In this paper, we first consider the parameterized complexity of MTM. We show that MTM is fixed-parameter tractableby designing an O (22k+12 log2(2k)kn(m + n))-time algorithm for deciding if a given n-vertex m-edge graph G contains twodisjoint matchings M1 and M2 such that |M1| + |M2| is a given number k. To obtain the algorithm, we first use thecolor-coding technique of Alon et al. [1] to design a randomized algorithm that runs in O (2kk(m + n)) expected time andthen derandomize it by using an (n,2k)-universal set.

We then consider the weighted version of MTM (MWTM for short), where each edge of the input graph G is given anonnegative weight and the goal is to find two disjoint matchings whose total weight is maximized. In the parameterizedversion of MWTM, we are given G and a positive integer k and want to find two disjoint matchings M1 and M2 suchthat |M1| + |M2| = k and the total weight of edges in M1 ∪ M2 is maximized over all pairs (N1, N2) of disjoint matchingsin G with |N1| + |N2| = k. By extending the randomized algorithm for the parameterized version of MTM, we obtain arandomized algorithm for the parameterized version of MWTM. The algorithm runs in O (2kk(m + n log n)) expected timeand can be derandomized by using an (n,2k)-universal set.

We further design an approximation algorithm for MWTM. First note that MWTM is also a special case of the maximumcoverage problem: We wish to cover the maximum-weight set of edges of a given graph G with two sets each of whichis a matching of G . Since this special case of the maximum coverage problem can be approximated by a greedy algorithmwithin a ratio of 0.75 [13], so can be MWTM. However, all the ideas used in the known approximation algorithms [8,15,6,5,14,4] for MTM cannot be applied to MWTM because the algorithms call Hartvigsen’s algorithm [11] which only works fornonweighted simple graphs.

We can observe that the algorithm of Feige et al. [8] for MTM can be slightly modified into a randomized approximationalgorithm for MWTM that achieves an expected ratio of 10

13 ≈ 0.769. However, as mentioned before, Feige et al.’s algorithmis extremely slow. So, in this paper, we present a completely new (deterministic) approximation algorithm for MWTM thatachieves a ratio close to 0.76. Our new algorithm is combinatorial and runs in O (m + n3α(n)) time, where α is the in-verse Ackermann function. The algorithm is motivated by the approaches developed in [18,12,7] for the maximum travelingsalesman problem which is the problem of finding a maximum-weight Hamiltonian cycle in a given edge-weighted completegraph. The algorithm also uses our fixed-parameter algorithm for MWTM as a subroutine.

2. Basic definitions

Let G be a graph. We denote the vertex set of G by V (G), and denote the edge set of G by E(G). For a subset U ofV (G), G − U denotes the graph obtained from G by removing the vertices in U (together with the edges incident to them).For a subset F of E(G), G − F denotes the graph obtained from G by removing the edges in F . The degree of a vertex v inG is the number of edges incident to v in G . Two edges of G are adjacent if they have at least one common endpoint.

A cycle in G is a connected subgraph of G in which each vertex is of degree 2. A path in G is either a single vertex ofG or a connected subgraph of G in which exactly two vertices are of degree 1 and the others are of degree 2. The lengthof a cycle or path C is the number of edges in C and is denoted by |C |. A k-cycle is a cycle of length k. If the length of acycle or path P is odd, then we say that P is odd; otherwise, we say that P is even. A 2-matching of G is a subgraph H of Gwith V (H) = V (G) in which the degree of each vertex is at most 2. Note that each connected component of a 2-matchingis a path or cycle. A 2-matching C of G is even if each cycle in C is even. A semi-path set of G is a set F of edges in G suchthat each connected component of the graph (V (G), F ) is a path or a 2-cycle. A matching of G is a (possibly empty) set ofpairwise nonadjacent edges of G . A perfect matching of G is a matching M of G such that each vertex of G is incident to anedge in M . An independent set of G is a set of vertices no two of which are adjacent in G .

For a positive integer n, let Zn denote the set {0,1, . . . ,n − 1}. A 2-coloring of the vertices in G is a functionf : V (G) → Z2.

An (n,k)-universal set is a family F of hash functions from Zn to Z2 such that for every subset S of Zn with |S| = k andfor every (possibly empty) subset S ′ of S , some function h ∈ F maps each s ∈ S ′ to 1 and maps each t ∈ S − S ′ to 0. Thesize of F is the number of functions in F .

3. The parameterized algorithm for MTM

In this section, we design a randomized fixed-parameter algorithm for MTM and then derandomize it. Throughout thissection, fix a nonnegative integer k and a graph G with n vertices and m edges.

We want to decide whether G has an even 2-matching with k edges. To this end, we first remove all but two edgesbetween u and v from G for each pair {u, v} of vertices in G such that G has more than two parallel edges between uand v . This step removes redundant edges from G . After this step, let H be the simplified version of G , which is obtainedfrom G by keeping only one edge between every pair of adjacent vertices. We check if H has a connected component H ′

Page 3: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.3 (1-9)

Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–••• 3

with at least k · |V (H ′)| edges. If such H ′ exists, then we can find a path of length at least k in H ′ within O (n +m) time viadepth-first search (as first observed in [2]), and we are done. So, we may hereafter assume that each connected componentH ′ of H has less than k · |V (H ′)| edges. By this assumption, H has less than k · |V (H)| edges. Consequently, G has less than2kn edges. Hence, we can hereafter assume that m < 2kn.

To decide whether G has an even 2-matching of size k, we proceed as follows. First, for each vertex v of G , we choosecv ∈ Z2 uniformly at random and view cv as the color of v . That is, we randomly color the vertices of G with two colors.Note that the colors of the vertices of G are chosen independently. For an even 2-matching H of G , we say that H is properlycolored if no two adjacent vertices of H receive the same color.

Consider an even 2-matching H of size k in G . Let H1, . . . , Hb be the connected components of H . Each Hi (1 � i � b)is a path or an even cycle. Let �i be the length of Hi . Note that

∑bi=1 �i = k because H has exactly k edges. If Hi is an even

cycle, then Hi has �i vertices and hence H is properly colored with probability 22�i

. On the other hand, if Hi is a path, then

Hi has �i + 1 vertices and hence H is properly colored with probability 22�i+1 . Thus, H is properly colored with probability

at least∏b

i=11

2�i= 1

2∑b

i=1 �i= 1

2k .

Lemma 3.1. Suppose that G has a properly-colored 2-matching of size k. Then, we can find an even 2-matching of G of size k inO (km + kn) time.

Proof. To find an even 2-matching of G of size k, we perform the following steps:

1. Construct a bipartite graph B from G by deleting every edge whose endpoints have the same color.2. Try to find a 2-matching H of size k in B . If H is found, then report that G has an even 2-matching of size k; otherwise,

report that G has no even 2-matching of size k.

Since B is bipartite, a 2-matching of B is also an even 2-matching of B . Moreover, since B is a subgraph of G , an even2-matching of B is also an even 2-matching of G . So, no error is made when we report (in Step 2) that G has an even2-matching of size k. By assumption, G has a properly-colored 2-matching H of size k. Obviously, H remains in B and sowe can find an even 2-matching of G in Step 2.

We next analyze the time complexity. Clearly, Step 1 can be done in O (m + n) time. An obvious way to implementStep 2 is to compute a maximum 2-matching in B . However, this takes O (m

√n) time [9]. Fortunately, we only need to find

a 2-matching of size k in B . To see how this can be done in O (kn + km) time, first note that Gabow’s algorithm finds amaximum 2-matching in B by finding a maximum matching in an auxiliary graph B ′ , which is obtained by modifying B asfollows:

• Split each edge e into three edges by adding two new vertices u and v on e.(Comment: The new vertices added in this step are called external vertices. We also say that the edge between u and vcorresponds to the original edge e.)

• Delete every original vertex with at most two neighbors.• For each original vertex v with at least four neighbors, add dB(v) − 3 new vertices and connect each of them to the

neighbors of v .

Since B is bipartite, so is B ′ . For convenience, we refer to those vertices of B ′ other than the external vertices as the internalvertices. Note that each neighbor of an internal vertex in B ′ is an external vertex. We say that a matching of B ′ is valid ifthe matching covers all internal vertices of B ′ . If a matching M ′ of B ′ is invalid, then we can modify M ′ by selecting anarbitrary internal vertex v not covered by M ′ , selecting a suitable neighbor u of v in B ′ , deleting the edge of M ′ incidentto u if any, and adding the edge {u, v}. This modification increases the number of internal vertices covered by M ′ . So, byrepeating this modification of M ′ , we can transform an invalid matching of B ′ into a valid matching with the same or alarger size. Moreover, if we start with M ′ = ∅ and repeat this modification of M ′ #in times, then we obtain a valid matchingM ′ of B ′ with #in edges, where #in is the number of internal vertices in B ′ .

One can verify that each valid matching N ′ of B ′ corresponds to a 2-matching N of B with |N| = |N ′| − #in . To increasethe size of M ′ , we first find an augmenting path P with respect to M ′ in B ′ , then use P to augment M ′ into a largermatching, and further make M ′ valid if it is invalid. By repeating this process at most k times, M ′ becomes a valid matchingof B ′ of size at least k + #in and we can then obtain a 2-matching M of B from M ′ with |M| = |M ′| − #in � k.

However, |V (B ′)| and |E(B ′)| can be much larger than |V (B)| and |E(B)|, respectively. Fortunately, Gabow [9] discoversthat it is unnecessary to construct B ′ and maintain M ′ explicitly. In more details, we only memorize those edges of M ′between external vertices. Gabow [9] shows that even with this shrunk M ′ , we can find an augmenting path P with respectto the original M ′ in the original B ′ in O (|V (B)| + |E(B)|) time. His idea is to use the shrunk M ′ to construct a newbipartite graph B ′′ with |V (B ′′)| = O (|V (B)|) and |E(B ′′)| = O (|E(B)|) and then find an augmenting path P with respect tothe shrunk M ′ in B ′′ . Since B ′′ is bipartite, P can be found in O (|V (B ′′)| + |E(B ′′)|) time, and hence in O (|V (B)| + |E(B)|)time. �

Page 4: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.4 (1-9)

4 Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–•••

Theorem 3.2. We can decide, in O (2kk(m + n)) expected time, whether G has an even 2-matching with k edges.

Proof. By the above discussion, we know that with probability at least 12k , we can correctly decide, in O (km + kn) time,

whether G has an even 2-matching of size k. By repeating this process O (2k) times, we can correctly decide, with largeprobability and in O (2k(km + kn)) time, whether G has an even 2-matching of size k. �Theorem 3.3. It takes O (22k+12 log2(2k)kn(m + n)) time to decide whether G has an even 2-matching with k edges.

Proof. It suffices to derandomize the above algorithm. First, we construct an (n,2k)-universal set F . It is known that an(n,2k)-universal set of size at most n22k+12 log2(2k)+2 can be explicitly constructed in O (n22k+12 log2(2k)) time [3,16]. Everyfunction in F can be viewed as a 2-coloring of the vertices in G . So, instead of trying a random 2-coloring of the verticesin G , we then try every coloring in F in order to emulate our randomized algorithm. If at least one coloring in F enablesthe algorithm to report that G has an even 2-matching of size k, then G certainly has an even 2-matching of size k;otherwise, G has no even 2-matching of size k. The total time needed is clearly as stated in the theorem. �

We next explain how to extend the above algorithms to the parameterized version of MWTM. Suppose that G is nowedge-weighted. We define the weight of a subgraph H of G to be the total weight of edges in H . Since G is weighted, wecan no longer assume that m < 2kn. Fortunately, this assumption was made (in the unweighted case) only for the purposeof speeding up the algorithms in practice and has nothing to do with the time bounds stated in the above theorems. Wefirst decide if G has an even 2-matching with k edges (say, by using the above algorithms). If G has no even 2-matchingwith k edges, then we are done. So, we hereafter assume that G has an even 2-matching with k edges.

Our goal is to compute a maximum-weight even 2-matching with k edges in G , i.e., an even 2-matching with k edgesin G whose weight is maximized over all even 2-matchings with k edges in G . To this end, we start as before, namely,by assigning a color cv ∈ Z2 to each vertex v of G uniformly at random. Then, as before, the event that a particularmaximum-weight even 2-matching with k edges in G is properly colored occurs with probability at least 2−k . We hereafterassume that this event has occurred. Then, it remains to show how to compute a maximum-weight 2-matching with kedges in the bipartite graph B obtained from G by removing all edges whose endpoints have the same color.

Lemma 3.4. We can find a maximum-weight 2-matching with k edges in B in O (km + kn log n) time.

Proof. The proof is similar to that of Lemma 3.1. Gabow [9] shows that a maximum-weight 2-matching in B can be foundby finding a maximum-weight matching in an auxiliary graph B ′ , where the vertices and edges of B ′ are obtained from Bas in the proof of Lemma 3.1. The weights of edges in B ′ are determined as follows. For each edge e′ of B ′ , if both endpointsof e′ are external vertices, then e′ corresponds to an edge e in B and we let the weight of e′ be the same as that of e;otherwise, we let the weight of e′ be the maximum weight of an edge in B .

We define internal vertices and valid matchings of B ′ as in the proof of Lemma 3.1. So, as before, each valid matching N ′of B ′ corresponds to a 2-matching N of B with |N| = |N ′| − #in , where #in is the number of internal vertices in B ′ . To finda maximum-weight 2-matching with k edges in B , we start with a valid matching M ′ of B ′ that corresponds to the empty2-matching in B . To increase the size of M ′ , we first find a maximum-weight augmenting path P with respect to M ′ in B ′ ,where the weight of P is the total weight of edges in P but not in M ′ minus the total weight of edges in both P and M ′ .A well-known fact is that if M ′ is a maximum-weight matching with |M ′| edges in B ′ (i.e., the weight of M ′ is maximizedover all matchings with |M ′| edges in B ′), then M ′ remains so even after we use P to augment M ′ . Thus, after augmentingM ′ in this way for k times, M ′ becomes a maximum-weight matching with #in + k edges in B ′ and we can then use it toobtain a maximum-weight 2-matching M with k edges in B .

However, |V (B ′)| and |E(B ′)| can be much larger than |V (B)| and |E(B)|, respectively. Fortunately, Gabow [9] discoversthat it is unnecessary to construct B ′ and maintain M ′ explicitly. In more details, we only memorize those edges of M ′between external vertices. Gabow [9] shows that even with this shrunk M ′ , we can find a maximum-weight augmentingpath P with respect to the original M ′ in the original B ′ by first constructing a new graph B ′′ with |V (B ′′)| = O (|V (B)|)and |E(B ′′)| = O (|E(B)|) and then finding a maximum-weight augmenting path P with respect to the shrunk M ′ in B ′′ .It is known that P can be found in O (|E(B ′′)| + |V (B ′′)| log |V (B ′′)|) time [10], and hence in O (|E(B)| + |V (B)| log |V (B)|)time. �Theorem 3.5. We can find a maximum-weight even 2-matching with k edges in G in O (2kk(m + n log n)) expected time, or in

O (22k+12 log2(2k)kn(m + n log n)) deterministic time.

Proof. The proof is similar to those of Theorems 3.2 and 3.3. The only difference is to use Lemma 3.4 instead ofLemma 3.1. �

Page 5: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.5 (1-9)

Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–••• 5

4. The approximation algorithm for MWTM

Throughout this section, fix an instance (G, w) of MWTM, where G is an n-vertex m-edge graph and w is a functionmapping each edge e of G to a nonnegative real number w(e). After a simple O (m +n2)-time preprocessing, we can assumethat for every two vertices u and v of G , there are exactly two edges between u and v in G . To see that no generality islost with this assumption, first observe that if there are three or more edges between two vertices u and v in G , then wecan delete all but the heaviest two edges between u and v from G . On the other hand, if there is at most one edge betweentwo vertices u and v in G , then we can add one or more edges of weight 0 between u and v so that G has exactly twoedges between them. The mate of an edge e in G is the other edge in G that has the same endpoints as e. We may furtherassume that n is even, because if n is odd, we can add a new vertex and connect it to each of the other vertices with twoedges of weight 0. For a subset F of E(G), w(F ) denotes

∑e∈F w(e). The weight of a subgraph H of G is w(H) = w(E(H)).

Note that MWTM is equivalent to the problem of computing a maximum-weight even 2-matching of a given graph.For a random event A, Pr[A] denotes the probability that A occurs. For two random events A and B , Pr[A | B] denotes

the (conditional) probability that A occurs given the known occurrence of event B . For a random variable X , E[X] denotesthe expected value of X .

In the remainder of this section, we first design a randomized approximation algorithm for MWTM and then derandomizeit. Section 4.1 gives an outline of the randomized algorithm. Section 4.2 then describes the details that are missing inthe outline. Section 4.3 estimates the time complexity and the expected approximation ratio achieved by the randomizedalgorithm. Finally, Section 4.4 derandomizes the algorithm.

4.1. Outline of the algorithm

Our algorithm starts by computing a maximum-weight 2-matching C and a maximum-weight matching M of G . We mayassume that M is a perfect matching of G because n is even. Our algorithm then uses C and M to perform a preprocessingas follows.

1. Construct a graph K as follows: Initially, K is the graph (V (G), M). Next, for every 2-cycle C in C , add the heavier edgeof C to K .(Comment: Each connected component of K is a path, a 2-cycle, or an even cycle of length 4 or more.)

2. Modify C by performing the following step for every cycle C ′ of K with |C ′| � 4:(a) Delete all 2-cycles C from C such that one edge of C appears in C ′ .(b) Add C ′ to C .

Obviously, C remains to be a 2-matching of G after the preprocessing. So, the preprocessing does not increase w(C) becauseC was originally a maximum-weight 2-matching of G . The preprocessing does not decrease w(C) either, because otherwisewe would be able to obtain a heavier matching of G than M by modifying it by deleting the edges added to C in thepreprocessing while adding the edges deleted from C in the preprocessing.

We hereafter assume that our algorithm has done the preprocessing. If C is now even, then our algorithm just outputsC and stops. In the remainder of this paper, we assume that C is not an even 2-matching of G . Then, C has at least twoconnected components. Suppose that T is a maximum-weight even 2-matching of G . Let T int denote the set of all edges{u, v} of T such that some cycle C in C contains both u and v . Let Text denote the set of edges in T but not in T int. Letβ = w(T int)/w(T ).

Our algorithm then computes three even 2-matchings T1, T2, T3 of G , outputs the heaviest one among them, and stops.T1 is computed by modifying the odd cycles in C as follows. Fix a parameter ε > 0. For each odd cycle C in C , if C has morethan ε−1 edges, then remove the minimum-weight edge; otherwise, replace C by a maximum-weight even 2-matching NC

of the graph obtained from G by deleting all vertices not in C . By Theorem 3.5, the NC ’s can be computed in O (2ε−1ε−2n)

expected total time, or in O (22ε−1+12 log2(2ε−1)ε−3n) deterministic total time. Then, C becomes an even 2-matching. Obvi-ously, we have the following fact:

Fact 4.1. w(T1) � (1 − ε)w(T int) = (1 − ε)βw(T ).

When w(Text) is large, w(T int) is small and w(T1) may be small, too. The two even 2-matchings T2 and T3 together areaimed at the case where w(Text) is large. Their computation is given in the next subsection.

4.2. Computation of T2 and T3

To compute T2 and T3, we first perform the following two steps:

1. Compute a maximum-weight matching M ′ in an auxiliary graph H , where V (H) = V (G) and E(H) consists of those{u, v} ∈ E(G) such that u and v belong to different connected components of C .

Page 6: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.6 (1-9)

6 Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–•••

2. Fix an arbitrary ordering C1, . . . , Cr of the connected components of C such that the 2-cycles precede the others.(Comment: Since C is a maximum-weight 2-matching of G and the weight of each edge in G is nonnegative, the weightof the edge between the endpoints of each path P that is a connected component of C is 0. So, we can change P intoa cycle by adding the edge between its endpoints without changing its weight. In the remainder of this paper, for easeof explanation, we assume that each connected component of C is a cycle.)

We then process the cycles C1, . . . , Cr in turn. Roughly speaking, the processing can be sketched as follows:

3. For i = 1,2, . . . , r (in this order), process Ci by performing the following two substeps:(a) Mark some suitable edges {u, v} ∈ M ′ with {u, v} ∩ V (Ci) �= ∅.(b) Move some suitable edges of Ci to M while always maintain that M is a semi-path set of G .

To detail Steps 3a and 3b, we need several definitions and lemmas. In the remainder of this paper, for each integeri ∈ {1, . . . , r}, the phrase “at time i” means the time at which C1, . . . , Ci−1 have been processed and Ci is the next cycle tobe processed. For each integer i ∈ {1, . . . , r}, let Mi be the set M at time i. For convenience, let Mr+1 and Cr+1 be the valuesof M and C immediately after Step 3, respectively.

A set F of edges in G is available at time i if F ⊆ E(Ci), F ∩ M1 = ∅, and Mi ∪ F is a semi-path set of G . Since M1 ⊆ Mi andM1 is a perfect matching of G , each set available at time i is a matching in Ci . A matching-pair in Ci is an (unordered) pair{A, B} such that both A and B are (possibly empty) matchings in Ci . An available matching-pair at time i is a matching-pair{A, B} in Ci such that both A and B are available at time i. A matching-pair {A, B} in Ci covers a vertex u of Ci if at leastone edge in A ∪ B is incident to u.

If Ci is a 2-cycle, then we can obtain an available matching-pair {Ai, Bi} at time i that covers both vertices of Ci asfollows: if neither edge of Ci belongs to M1, then we simply let Ai consist of one edge of Ci and let Bi consist of the otheredge of Ci ; otherwise the lighter edge of Ci does not belong to M1 and we let both Ai and Bi consist of this edge of Ci .{Ai, Bi} is available because every cycle C j of C with j < i is a 2-cycle and we have done the preprocessing. Thus, if Ci is a2-cycle, the details of Steps 3a and 3b are as follows (i.e., they are replaced by the following three substeps):

(a) Compute an available matching-pair {Ai, Bi} at time i as follows: If neither edge of Ci belongs to M1, then let Ai consistof one edge of Ci and let Bi consist of the other edge of Ci ; otherwise let both Ai and Bi consist of the lighter edgeof Ci .

(b) For each vertex v ∈ V (Ci), if some edge e of M ′ is incident to v , then mark e.(c) Select one of Ai and Bi uniformly at random and move its edge from C to M .

If Ci is a cycle of length 3 or more, then it is easy to modify the proof of Lemma 1 in [12] to obtain a subroutine forcomputing an available matching-pair at time i that covers all vertices of Ci . Moreover, using the famous union-find datastructure, we can implement this subroutine in O (|Ci | · α(n)) time. The following lemma summarizes this result:

Lemma 4.2. If Ci is a cycle of length 3 or more, then we can compute an available matching-pair {Ai, Bi} at time i in O (|Ci | · α(n))

time that covers all vertices of Ci .

A maximal available set at time i is a set F available at time i such that for every e ∈ E(Ci) − F , F ∪ {e} is not available attime i. Now, we are ready to describe the details of Steps 3a and 3b for those cycles Ci of C with |Ci | � 3. Indeed, they arereplaced by the following four substeps:

(a) Compute an available matching-pair {Ai, Bi} at time i in O (|Ci | · α(n)) time that covers all vertices of Ci .(b) Extend both Ai and Bi to maximal available sets at time i.

(Comment: Using the famous union-find data structure, we can implement this substep in O (|Ci | ·α(n)) time by scanningthe edges of Ci in an arbitrary order and checking if each of them can be added to Ai and/or Bi .)

(c) For each vertex v ∈ V (Ci) such that both Ai and Bi have an edge incident to v , if some edge e of M ′ is incident to v ,then mark e.

(d) Select one of Ai and Bi uniformly at random and move its edges from C to M .

Finally, we finish the computation of T2 and T3 by performing the following three steps:

4. Add to C those edges {u, v} ∈ M ′ such that both u and v are of degree at most 1 in C .(Comment: Let M ′

4 denote the set of edges in M ′ that are added to C at this step. For each cycle C in C , |E(C)∩ M ′4|� 2.)

5. For each odd cycle C in C , if |E(C) ∩ M ′| = 2 and exactly one edge in E(C) ∩ M ′ is marked, then delete one edge inE(C) ∩ M ′ from C at random in such a way that the marked edge is deleted with probability 2/3; otherwise, select oneedge in E(C) ∩ M ′ uniformly at random and delete it from C .(Comment: Let M ′

5 denote the set of edges in M ′ that remain in C immediately after this step.)6. Set T2 and T3 to be C and the graph (V (G), M), respectively.

Page 7: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.7 (1-9)

Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–••• 7

4.3. Analysis of the approximation ratio

Our algorithm is clearly correct. We next analyze its approximation ratio. The following lemma has been proved in [7];we include its proof here for self-containedness.

Lemma 4.3. Let F be an available set at time i. Suppose that e1 = {u1, u2} and e2 = {u2, u3} are two adjacent edges in Ci such that Fcontains no edge incident to u1 , u2 , or u3 . Then, F ∪ {e1} or F ∪ {e2} is available at time i.

Proof. If F ∪ {e1} is available at time i, then we are done. So, assume that F ∪ {e1} is not available at time i. Considerthe graph Hi,F = (V (G), Mi ∪ F ). Since M1 is perfect and F contains no edge incident to u1, u2, or u3, the degree of eachu j ∈ {u1, u2, u3} in Hi,F is 1. Now, since F ∪ {e1} is not available at time i, some connected component (a path) Q of Hi,Fcontains both u1 and u2 (no matter whether e1 ∈ M1 or not). Because a path can have at most two vertices of degree 1,u3 is not a vertex of Q . So, {u2, u3} /∈ M1 and Mi ∪ F ∪ {e2} is a semi-path set of G . Consequently, F ∪ {e2} is available attime i. �Corollary 4.4. Suppose that F is a maximal available set at time i. Then, Ci − F is a collection of vertex-disjoint paths each of length 1,2, or 3.

Proof. By Lemma 4.3, F is not empty and Ci − F is a collection of vertex-disjoint paths each of length at most 3. On theother hand, since Ci is a cycle and F is a matching in Ci , each connected component of Ci − F is a path of length atleast 1. �

A matching-pair {A, B} in Ci favors a vertex u of Ci if A contains an edge e1 ∈ E(Ci) incident to u and B contains anedge e2 ∈ E(Ci) incident to u (possibly e1 = e2). An available set F at time i is dangerous for an (unordered) pair {e1, e2} ofedges in M ′ if Ci − F contains a connected component that is a length-2 path one of whose endpoints is an endpoint of e1and the other is an endpoint of e2.

Lemma 4.5. Let {A, B} be an arbitrary matching-pair in Ci that covers all vertices of Ci . If A (respectively, B) is dangerous for a pair{e1, e2} of edges in M ′ , then {A, B} favors exactly one endpoint of the length-2 path in Ci − A (respectively, Ci − B) between anendpoint of e1 and an endpoint of e2 .

Proof. Suppose that A is dangerous for a pair {e1, e2} of edges in M ′ . Let P be the length-2 path in Ci − A between anendpoint v1 of e1 and an endpoint v2 of e2. Let v3 be the vertex in V (P ) − {v1, v2}. Since {A, B} covers v3, B containseither the edge {v1, v3} or the edge {v2, v3}. If {v1, v3} ∈ B , then {A, B} favors v1. On the other hand, if {v2, v3} ∈ B , then{A, B} favors v2. �

A maximal available matching-pair at time i is an available matching-pair {A1, A2} at time i such that both A1 and A2 aremaximal available sets at time i.

Lemma 4.6. Let e = {v1, v2} be an edge in M ′ . Then, Pr[e ∈ M ′5]� 1

6 .

Proof. Let D be the event that e ∈ M ′4. By the algorithm, Pr[D] � 1

4 . Suppose that D has occurred. Let C be the connectedcomponent of C containing e immediately after Step 4. If C is even or |E(C) ∩ M ′| � 3, then the probability that e isnot deleted in Step 5 is at least 2

3 , implying that Pr[e ∈ M ′5] � 1

6 . So, suppose that C is odd and |E(C) ∩ M ′| < 3. Then,|E(C) ∩ M ′| = 2.

Let e′ = {u1, u2} be the edge in E(C) ∩ M ′ other then e. Let P1 and P2 be the connected components of C − {e, e′}.Since C is odd, one of P1 is even and the other is odd. Without loss of generality, we may assume that P1 is even andP2 is odd. By Corollary 4.4, the length of P1 is 2. Without loss of generality, we may further assume that v1 and u1are the endpoints of P1. Let Ci be the cycle in C immediately before Step 3 that contains P1 as a subgraph. Then, themaximal available matching-pair {Ai, Bi} at time i computed in Step 3b is dangerous for {e, e′}. So, by Lemma 4.5, {Ai, Bi}favors v1 or u1. If {Ai, Bi} favors u1, then e′ is marked in Step 3c and the probability that e is not deleted in Step 5 is 2

3 ,

implying that Pr[e ∈ M ′5] � 1

6 . Thus, suppose that {Ai, Bi} favors v1. Then, e is marked in Step 3c and the probability that e

is not deleted in Step 5 is 13 . Fortunately, since {Ai, Bi} favors v1, the probability that D occurs is at least 1

2 , implying that

Pr[e ∈ M ′5]� 1

6 . �Recall T , T int, Text, and β (they are defined in Section 4.1).

Lemma 4.7. Let δw(T ) be the expected total weight of edges moved from C to M at Step 3. Then, E[w(T3)] � (0.5 + δ)w(T ) andE[w(T2)] � ((1 − δ) + 1 (1 − β))w(T ).

12
Page 8: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.8 (1-9)

8 Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–•••

Proof. Since T3 contains M1 (a maximum-weight perfect matching of G) as a subset and also contains the edges movedfrom C at Step 3, it is clear that E[w(T3)]� (0.5 + δ)w(T ).

By Lemmas 4.6, E[w(M ′5)] � 1

6 w(M ′). Thus, after Step 5, E[w(C)] � (1 − δ)w(T ) + 16 w(M ′). Now, since w(M ′) �

12 w(Text) = 1

2 (1 − β)w(T ), we have E[w(T2)] � ((1 − δ) + 112 (1 − β))w(T ). �

Theorem 4.8. For any fixed ε > 0, there is a randomized approximation algorithm for MWTM achieving an expected approximationratio of 19(1−ε)

25−24ε and running in O (m + n3 + 2ε−1ε−2n) expected time.

Proof. We first estimate the running time of our algorithm. The computation of C , M , and M ′ can be done in O (n3) time [9].The NC ’s can be computed in O (2ε−1

ε−2n) expected total time. Step 3 can be done in O (n ·α(n)) total time. The other stepstake O (n) time. Thus, the total time complexity is as stated in the theorem.

We next estimate its approximation ratio. By Fact 4.1 and Lemma 4.7, we have the following three inequalities:

w(T1) � (1 − ε)βw(T ), (4.1)

E[

w(T2)]�

((1 − δ) + 1

12(1 − β)

)w(T ), (4.2)

E[

w(T3)]� (0.5 + δ)w(T ). (4.3)

Adding inequalities (4.2) and (4.3), we have

E[

w(T2)] + E

[w(T3)

]�

(1.5 + 1

12(1 − β)

)w(T ). (4.4)

Multiplying both sides of inequality (4.4) by 12(1 − ε) and adding the resulting inequality to inequality (4.1), we get

w(T1) + 12(1 − ε)(E[

w(T2)] + E

[w(T3)

])� 19(1 − ε)w(T ). (4.5)

By inequality (4.5), we have

E[max

{w(T1), w(T2), w(T3)

}]� 19(1 − ε)

25 − 24ε· w(T ). (4.6)

Therefore, the algorithm achieves an expected approximation ratio of 19(1−ε)25−24ε . �

4.4. Derandomization

The above randomized algorithm makes random choices only in Steps 3d and 5. To derandomize Step 5, we just modifyit as follows:

5. For each odd cycle C in C , delete one edge e ∈ E(C) ∩ M ′ from C such that the weight e is minimized over all edges inE(C) ∩ M ′ .

When processing cycle Ci in Step 3, we need one random bit in Step 3d. So, Step 3 needs r random bits in total. In theabove analysis of the randomized algorithm, only the proof of Lemma 4.6 is based on the mutual independence betweenthese random bits. Indeed, by carefully inspecting the proof, we can see that the proof is still valid even if the random bitsare only pairwise independent. So, we can derandomize it via conventional approaches. Therefore, we have the followingtheorem:

Theorem 4.9. For any fixed ε > 0, there is an O (m + n3α(n) + 22ε−1+12 log2(2ε−1)ε−3n)-time approximation algorithm for MWTM

achieving a ratio of 19(1−ε)25−24ε .

Proof. As before, the computation of C , M , and M ′ can be done in O (n3) time. Moreover, the NC ’s can be computed inO (22ε−1+12 log2(2ε−1)ε−3n) total time. To implement Step 3, we need to generate r = O (n) pairwise independent randombits. A conventional way to do this uses two random seeds s1 and s2 both of value O (r). So, the sample space of (s1, s2)

is of size O (r2). For each sample (s1, s2) in the space, we perform Steps 3 through 6 to obtain an output OUT(s1, s2). Thistakes a total time of O (r2n · α(n)) because Steps 3 through 6 can be done in O (n · α(n)) time. We then find the sample(s1, s2) in O (r2) time such that the weight of OUT(s1, s2) is maximized, and further output OUT(s1, s2). �

Page 9: Parameterized and approximation algorithms for finding two disjoint matchings

JID:TCS AID:9687 /FLA Doctopic: Algorithms, automata, complexity and games [m3G; v 1.131; Prn:3/04/2014; 14:22] P.9 (1-9)

Z.-Z. Chen et al. / Theoretical Computer Science ••• (••••) •••–••• 9

5. Open problems

An obvious question is to ask if we can improve the running time of our parameterized algorithm for MTM. Anotherobvious question is to ask if we can design a combinatorial approximation algorithm for MWTM that achieves a better ratiothan 0.769.

Feige et al. [8] have considered the problem of computing t disjoint matchings in a given graph G such that the totalnumber of edges in the matchings is maximized, where t is a fixed positive integer. The special case of this problem wheret = 3 and the input graph is simple has been considered by Kosowski [14] and Rizzi [17]. It seems interesting to designparameterized or approximation algorithms for this problem and its special cases.

Acknowledgements

We thank the anonymous referees for very helpful comments. ZZC was supported in part by the Grant-in-Aid for Scien-tific Research of the Ministry of Education, Science, Sports and Culture of Japan, under Grant No. 24500023. LW is supportedby a grant from the Research Grants Council of the Hong Kong Special Administrative Region, China [Project CityU 122511].

References

[1] N. Alon, R. Yuster, U. Zwick, Color-coding, J. ACM 42 (1995) 844–856.[2] H.L. Bodlaender, On linear time minor tests with depth-first search, J. Algorithms 14 (1993) 1–23.[3] J. Chen, et al., Randomized divide-and-conquer: improved path, matching, and packing algorithms, SIAM J. Comput. 38 (2009) 2526–2547.[4] Z.-Z. Chen, S. Konno, Y. Matsushita, Approximating maximum edge 2-coloring in simple graphs, Discrete Appl. Math. 158 (2010) 1894–1901. A pre-

liminary version appeared in: Proceedings of 6th International Conference on Algorithmic Aspects in Information and Management (AAIM 2010), in:Lecture Notes in Comput. Sci., vol. 6124, 2010, pp. 78–89.

[5] Z.-Z. Chen, R. Tanahashi, Approximating maximum edge 2-coloring in simple graphs via local improvement, Theoret. Comput. Sci. 410 (2009)4543–4553 (special issue on AAIM 2008). A preliminary version appeared in: Proceedings of 4th International Conference on Algorithmic Aspectsin Information and Management (AAIM 2008), in: Lecture Notes in Comput. Sci., vol. 5034, 2008, pp. 84–96.

[6] Z.-Z. Chen, R. Tanahashi, L. Wang, An improved approximation algorithm for maximum edge 2-coloring in simple graphs, J. Discrete Algorithms 6 (2008)205–215. A preliminary version appeared in: Proceedings of 3rd International Conference on Algorithmic Aspects in Information and Management(AAIM 2007), in: Lecture Notes in Comput. Sci., vol. 4508, 2007, pp. 27–36.

[7] Z.-Z. Chen, L. Wang, An improved randomized approximation algorithm for Max TSP, J. Comb. Optim. 9 (2005) 401–432.[8] U. Feige, E. Ofek, U. Wieder, Approximating maximum edge coloring in multigraphs, in: Proceedings of the 10th International Conference on Integer

Programming and Combinatorial Optimization (IPCO), in: Lecture Notes in Comput. Sci., vol. 2462, 2002, pp. 108–121.[9] H. Gabow, An efficient reduction technique for degree-constrained subgraph and bidirected network flow problems, in: Proceedings of the 15th Annual

ACM Symposium on Theory of Computing (STOC’83), 1983, pp. 448–456.[10] H. Gabow, Data structures for weighted matching and nearest common ancestoers, in: Proceedings of the 1st Annual ACM–SIAM Symposium on

Discrete Algorithms (SODA’90), 1990, pp. 434–443.[11] D. Hartvigsen, Extensions of matching theory, Ph.D. thesis, Carnegie-Mellon University, 1984.[12] R. Hassin, S. Rubinstein, Better approximation for Max TSP, Inform. Process. Lett. 75 (2000) 181–186.[13] D. Hochbaum, Approximation Algorithms for NP-Hard Problems, PWS Publishing Company, Boston, 1997.[14] A. Kosowski, Approximating the maximum 2- and 3-edge-colorable subgraph problems, Discrete Appl. Math. 157 (2009) 3593–3600.[15] A. Kosowski, M. Malafiejski, P. Zylinski, Packing [1,�]-factors in graphs of small degree, J. Comb. Optim. 14 (2007) 63–86.[16] M. Naor, L.J. Schulman, A. Srinivasan, Splitters and near-optimal derandomization, in: Proceedings of the 36th Annual Symposium on Foundations of

Computer Science (FOCS), 1995, pp. 182–191.[17] R. Rizzi, Approximating the maximum 3-edge-colorable subgraph problem, Discrete Math. 309 (2009) 4166–4170.[18] A.I. Serdyukov, An algorithm with an estimate for the traveling salesman problem of maximum, Upr. Sist. 25 (1984) 80–86 (in Russian).