# Approximation algorithms for covering a graph by vertex-disjoint paths of maximum total weight

• Published on
15-Jun-2016

• View
212

0

Embed Size (px)

Transcript

• Approximation Algorithms for Covering a Graph by Vertex-Disjoint Paths of Maximum Total Weight Shlomo Moran Faculty of Computer Science, Technion-Israel Institute of Technology, Haifa, Israel 32000

llan Newman Department of Computer Science, Hebrew University, Givat Ram, Jerusalem, Israel

Yaron Wolfstahl Faculty of Computer Science, Technion-Israel Institute of Technology, Haifa. Israel 32000

We consider the problem of covering a weighted graph G = ( V , E) by a set of vertex-disjoint paths, such that the total weight of these paths is maximized. This problem is clearly NP-complete, since it contains the Hamiltonian path problem as a special case. Three approximation algorithms for this problem are presented, exhibiting a complexity-performance trade-off. First, we develop an algorithm for covering undirected graphs. The time complexity of this algorithm is O(lEl IoglEl), and its performance-ratio is i. Second, we present an algorithm for covering undirected graphs, whose performance-ratio is 3. This algorithm uses a maximum weight matching algorithm as a subroutine, which dominates the overall complexity of our algorithm. Finally, we develop an algorithm for covering directed graphs, whose performance- ratio is :. This algorithm uses a maximum weight bipartite matching algorithm as a subroutine, which dominates the overall complexity of the algorithm.

1 INTRODUCTION

Let G = (V, E) be a (possibly directed) graph with no self-loops and parallel edges (or anti-parallel edges), and let WG: E- , Z+* be a weight function. A path in G is either a single vertex U E V or a sequence of distinct vertices ( u , , u2, . . . , uk), where (u i , ui+,) E E for 1 I i 5 k - 1 (in a directed graph, (ui, uj) is taken to be an edge from ui to uj). A path couer (abbrev. couer) of G is a set of vertex-disjoint paths that cover all the vertices of G. The weight of a cover S, denoted by WG(S), is the total sum of the weights of the edges

*Z' is the set of positive integers.

NETWORKS, Vol. 20 (1990) 55-64 @ 1990 John Wiley 81 Sons, Inc. CCC 0028-3045/90/010055-010\$04.00

• 56 MORAN, NEWMAN, AND WOLFSTAHL

included in S. A cover of the maximum possible weight is an optimal cover of G, and its weight is denoted by P(G).

The concept of graph covering arises in various applications, such as mapping parallel programs to parallel architectures [ 101 and code optimization [3]. Unfortunately, the optimal covering problem is NP-complete even for cubic 3-connected planar graphs where no face has fewer than five edges [8]. There are, however, several results on optimal covering of restricted classes of graphs. Boesch e t al. have derived in [2] an efficient optimal covering algorithm for undirected trees. Their result was generalized by Pinter and Wolfstahl [lo], who developed a linear optimal covering algorithm for un- directed graphs where no two cycles share a vertex. Moran and Wolfstahl have developed a linear optimal covering for cacti, i.e., undirected graphs where no edge lies on more than one cycle [9]. Bodlaender has developed a polynomial time algorithm [4] for optimal covering of classes of graphs with bounded treewidth (see [l] for a related result). Boesch and Gimpel [3] have reduced the problem of covering a directed acyclic graph to the matching problem. All the above works consider nonweighted graphs only, in which case an optimal cover can be equivalently defined as a cover with the minimum number of paths.

Motivated by the NP-completeness of the optimal covering problem, we set out to develop approximation algorithms for optimal covering of graphs. Define a covering algorithm to be an r-approximation algorithm if for any graph G = (V, E) and a weight function WG: E+ Z+, the algorithm produces a cover S such that [WG(S)]/[/3(G)]2 r. In this case, r is called the per- formance-ratio of the algorithm. Three r-approximation covering algorithms are presented. First, we develop a \$-approximation algorithm for covering undirected graphs, called Algorithm A. The time complexity of this algorithm is O(lEl log IEI). Second, we present a 3 -approximation algorithm for covering undirected graphs, called Algorithm B. This algorithm uses a maximum weight matching algorithm as a subroutine, the complexity of which dominates the overall complexity of Algorithm B. Finally, we develop a \$-approximation algorithm for covering directed graphs, called Algorithm C. This algorithm uses a maximum weight bipartite matching algorithm as a subroutine, the complexity of which dominates the overall complexity o f Algorithm C.

2. A &APPROXIMATION COVERING ALGORITHM

Our first approximation algorithm, named algorithm A, is presented below. The algorithm is intended for covcring undirected graphs. Informally, Al- gorithm A operates as follows: It initially constructs a cover constituting of all the vertices of G and no edges. This initial cover, where each vertex is a path by itself, has a weight of zero. The algorithm then proceeds to increase the weight of the cover by adding edges between endpoints of existing paths so as to create longer paths. The edges used to create longer paths from existing ones are chosen in descending order of weight. Once an edge e = ( u , v ) is

• VERTEX-DISJOINT PATHS OF MAXIMUM TOTAL WEIGHT 57

chosen for the cover, the edges that, by the choice of e , cannot be chosen later, are ruled out. (These are the redundant edges, i.e., edges incident to vertices x E { u , u}, where x is not an endpoint of a path in the cover.) When the weight of the cover cannot be increased any more, the algorithm ter- minates.

Algorithm A.

Input: Z + .

An undirected graph G = ( V, E) and a weight function WG: E-

Output: PA, a cover of G.

Method:

Initialize: E t 0 . For each V E V, p ( u ) + u , o ( u ) + u . (*If u E V is an endpoint of a path in the cover, then p ( u ) is the path covering u, and o(u) is the other endpoint of this path.*)

Sort the edges of E in descending order of weight.

Loop: while E # 0 do

Choose an edge e = ( u , U ) E E such that W,(e) is maximum. E + E - ( e } . If p ( u ) # p( v), then

do ( * u , u are endpoint of different paths*)

(*Add e to the cover*) (*Redundant edges . . .*)

(*. . . are ruled out.*) (*In the new path just created, update p ( ) . . .*)

(*. . . a n d o( ).*)

E+EU{e) . M + { ( x . y ) ~ E l x ~ { u . u } , o ( x ) # x } . E + E - M . /( 0 ( u )) + p ( u). I + 0 ( u ). 0 ( 0 ( u ) ) + 0 ( u ) . 0 ( 0 ( v)) + t .

od

od

Output: PA + { P I p is a maximal connected component in G = (V, El)}. Theorem 1. Algorithm A is a &approximation covering algorithm. Moreover, the algorithm can be implemented in O(lE1 - loglEl) time.

Proof. It is easy to see that A produces a cover of G: The extraction of the edges of M from E in each iteration ensures that no vertex of G = (V, E) is

• 58 MORAN, NEWMAN, AND WOLFSTAHL

of degree exceeding 2. The test p ( u ) # p ( u ) ensures that G contains no cycles. Thus, PA is a cover of G.

The following definitions are used to prove the claimed performance-ratio. Extend the notion of weight, such that for M c E, the weight of M is defined t o be WG(W = x e 6 ~ WG(e). An edge e E E is called an El-edge. Denote the number of El-edges incident to a vertex u E V by dA(u) . Given a path p E PA, let ~ ( p ) denote the set of E-edges included in p , and let Ep=

Let OPT(G) be an optimal cover of G. Observe that OPT(G) can be {e = (u , u)l e E E ( P ) , d A ( 4 = 1).

viewed as the union of three sets, namely, El, E2, and E3, where

( 1 ) E , = { e = ( u , u ) l e ~ Efl OPUG)). (2) E2 = {e = ( U, u)[ e E OPT( G ) - E, d ~ ( U) = dA( U) = 1 ) . (3) E 3 = { e = ( u , u ) l e ~ O P T ( G ) - E , m a x { d A ( u ) , d ~ ( ~ ) } = 2 } .

Let e = (u, u ) be an edge of E2. Note that u and u are covered by the same path p E PA where I ~ ( p ) l > 1, for otherwise, the algorithm would have included e in PA. Also, observe that WG(e) 5 mine,,Ep { WG(e)}. For otherwise, e.g., if WG(e) > WG(el), where el E Ep, the algorithm would have chosen e for PA, instead of e l . Hereafter, if e = ( u , u ) E E2 where u and u are covered by P E PA, let S(e) = Ep. Clearly, for each edge e E E2 where S(e) = { e l , ez}, w d e ) 5 t(WG(e1) + WG(e2)).

Let e = ( u , u ) be an edge of E3, where, w.l.o.g., ~ A ( u ) = 2. If ~ A ( u ) = 1 and Sl ={e l ,e2} is the set of El-edges incident to u, then W G ( e ) s min{ WG(el), WG(e2)}. For otherwise, e.g., if WG(e) > WG(el), the algorithm would have chosen e for PA, instead of el . Using a similar argument, one can verify that if dA(u) = 2 and S2 = {e3, e4} is the set of El-edges incident to u , then WG(e) I miner,s{ WG(e)} for some S E {S1, S2}. Hereafter, if e E E3 and S , , S2 are defined as above, then the set S satisfying the latter inequality is denoted by S(e) (if Sl and S2 both satisfy the inequality, let S(e) = S1). Clearly, for each edge e E E3 where S(e) = {el, e2}, WG(e) s\$( WG(e1) + W~(e2)) .

Using the said above, we find that

where

and

• VERTEX-DISJOINT PATHS OF MAXIMUM TOTAL WEIGHT 59

Let us now estimate the contribution of each edge eE E to W =

Assume first that e is an edge of ~ ( p ) - Ep.

W , + W, + W3. Let p be a path of PA, and let e be an edge on p .

If e E OPT(G), then WG(e) appears once in W,. Also, there are, at most, two edges e E E3, such that e E S(e), so WG(e) appears at most twice in W3, where in each such appearance it is multiplied by 4. Note that WG(e) does not appear in W,. Hence, e contributes most 2 - WG(e) to W . If e q! OPT(G), then WG(e) appears at most four times in W3, where, in each such appearance, it is multiplied by 4. Note that WG(e) does not appear in Wl and W,. Hence, e contributes at most 2 - WG(e) to W .

Assume next that e is an edge of Ep.

0 If e E OPT(G), then WG(e) appears once in W l . Also, there may be at most one edge eE E2 such that e is incident to e , so WG(e) appears at most once in W,, where it is multiplied by \$. Furthermore, there is at most one edge e E EB such that e E S(e ) , so WG(e) appears at most once in W3, where it is multiplied by 4. Hence, e contributes at most 2 - WG(e) to W .

0 If eq! OPT(G), then there may be a single edge e E E2, such that e is incident to e , so WG(e) appears at most once in W2, where it is multiplied by f. Also, there are, at most, two edges eE E3, such that e E S(e ) , so WG(e) appears at most once in W3, where in each appearance it is multiplied by f. Note that WG(e) does not appear in W,. Hence, e con- tributes at most \$ * WG(e) to W .

To summarize the above said, an edge e on a path P E PA contributes at most 2 * WG(e) to W . It follows that

We now turn to the complexity of the algorithm. Assume V = { u , , u,,. . . , u}. The following data structures are used. The set E is represented by a doubly linked list. The set E is represented by a list. The set V is represented by a table V[1 . . . n], where for each ui E V the entry V[i] contains the values of p ( u i ) , o(ui) , and a pointer to an incidence list of ui. This incidence list, denoted by L(u i ) , contains the vertices adjacent to ui in G. Each vertex uj in L(ui) is associated with a pointer to the edge (ui, ui) in E, called an E-pointer. Clearly, the initialize step is linear in IEI,, and the sort step can be implemented in O(lEl IogIEJ) time. Let e = ( u i , vj) E E be an edge chosen at the head of the loop. Since the list E is doubly linked, the extraction of e from E is done in O(1) time. The edges rendered redundant by the choice of e are found, and immediately deleted, by tracing the

• 60 MORAN, NEWMAN, AND WOLFSTAHL

E-pointers in the incidence lists of ui and uj . Thus, the extraction of M from E requires O(lM1) time, so the execution time of the loop is O(IE1). The output step is also linear in IE(. It follows that the run time of the algorithm is 0(( El * log(E1) time.

We note that the sorting step can be omitted when WG is constant, resulting in an O(lE1) algorithm. Furthermore, it can be shown that in graphs where WG(e) = k for each e E E , the algorithm produces a cover PA that satisfies p( G) 5 2 - WG(PA) - IPLl * k, where P A is the number of paths that are not isolated vertices. This bound is tight, that is, there are graphs where the execution of the algorithm attains equality. The proof is omitted.

3. A \$APPROXIMATION ALGORITHM FOR COVERING UNDIRECTED GRAPHS

In this section, we describe and analyze a second approximation algorithm for optimal covering of undirected graphs, named Algorithm B. In doing so, we rely on an algorithm for finding a maximum weight degree-constrained subgraph of a given graph. A polynomial algorithm for the latter problem can be derived from [5 ] , where the linear programming approach is taken. Ano- ther algorithm for the maximum weight degree-constrained subgraph problem, which uses matching techniques, is given in [ll].

Algorithm B

Input: Z+ .

An undirected graph G = (V, E ) and a weight function WG: E- ,

Output: P,, a cover of G.

Method:

Step 1 . Obtain a graph Gx = (V, X ) , X C E , where degGx(u) I 2 for each u E V and W G ( X ) is maximized. (*Gx consists of isolated paths and cycles.*) Let c be the set of cycles in Gx. Y +{el e is an edge of minimum weight on some c E C}

Output; PB + - { P I p is a maximal connected component in G' = ( v, El)}.

Step 2. Step 3. Step 4 . E ' + X - Y Step 5.

Theorem 2. Algorithm B is a \$-approximation covering algorithm.

Proof. It is immediate that PB is a cover of G, so we begin by proving the claimed performance-ratio.

• VERTEX-DISJOINT PATHS OF MAXIMUM TOTAL WEIGHT 61

Let OPT(G) be an optimal cover of G. Observe that W , ( X ) I W,(OPT(G)), since the weight of X is maximized over all subgraphs of G where the degree of no vertex exceeds 2.

Consider the sets C and Y defined in Steps 2 and 3, respectively, of the algorithm. For each cycle c E C , let W,(C) denote the sum of the weights of the edges on c. Each cycle C E C contains at least three edges, so there is at least one edge, e , on c with W,(e) 5 (wG(c ) /3 ) . It follows that

Hence,

The Theorem follows.

The complexity of Step 1 of Algorithm B is that of the available algorithm for finding a maximum weight degree-constrained subgraph of G = (V, E) (here the degree bound is 2). The latter problem was reduced in [ll] to the maximum weight matching proglem on a graph G1 = ( V1, El), where, in terms of G, both I V1l and [ E l l are O(lE1). The maximum weight matching problem, in turn, can be solved on a graph GI = ( V l , El) in O ( ( V I ~ . t(lE11, I V I ~ ) + 1 VII log1 Vllf) time, where t (m, n ) = O(m logloglogbn), b = max{m/n, 2) [6]. Hence. in terms of the original graph G, Step 1 can be executed in O(IE( . dlE(, + OClEl log(El) = O(IEI2 logloglogb(El) = O(IE(2 log loglogb IVl) time. Steps 2-5 of Algorithm B can clearly be executed in O(lE1) time, so Step 1 dominates the comp...