A weighted matroid intersection algorithm

A weighted matroid intersection algorithm

JOURNAL 2,328-336 (1981) OF ALGORITHMS A Weighted Matroid Intersection Algorithm ANDRAS FRANK* Research Institute for Telecommunication, Budapes...

415KB Sizes 22 Downloads 112 Views

JOURNAL

2,328-336 (1981)

OF ALGORITHMS

A Weighted Matroid Intersection Algorithm ANDRAS FRANK* Research

Institute

for Telecommunication,

Budapest,

Hungary

Received November 5, 1980; revised May 10, 1981

Two matroids M, = (S, 4,) and M, = (S, $), and a weight function s on S (possibly negative or nonintegral) are given. For every nonnegative integer k, find a k-element common independent set of maximum weight (if it exists). This problem was solved by J. Edmonds [3, 41 both theoretically and algorithmically. Since then the question has been investigated by a number of different authors; see, for example, [l, 6-101. The purpose of this note is to make a simpler primal-dual algorithm and thereby give a clearer constructive proof for Edmonds’ matroid polyhedral intersection theorem. The idea behind the procedure is that the meaning of the dual part in Lawler’s primal-dual algorithm can be made much simpler. We shall not need the dual variables assigned to the closed sets of the two matroids. Instead, we are working by splitting the weights of the elements. At the end of the algorithm the optimal dual variables can simply be computed from the final splitting. The reader is assumed to be familiar with such basic concepts of matroid theory as “independent set,” “circuit,” “greedy algorithm,” etc. [9, 111. The weight of a subset X of S is s(X) = Z(s(x): x E X). If Tis a family of subsets of S we say that F E Tis s-maximal in Tif s(F) L s(X) for X E 9. Before describing the algorithm we need some simple lemmas. The main content of the Greedy Algorithm theorem [2] is: LEMMAI. ForagivenmatroidM=(S,$),letgk I E 4k is s-maximal in g k if and on& if

={X:XE$,IXI=k}.

(1) x fj! I, I + x 6! $ imply s(x) I s(y), for every y E C(I, x) and (2) xBI,I+xEgimplys(x)Is(y),foreveryyEI, *This note was written while the author was visiting the University of Waterloo, JanuaryApril, 1980.

328 Ol%-6774/81/0400328-09$02.00/O Copyright 0 I98 I by Academic F’ress, Inc. All rights of repmduction in any form reserved.

WEIGHTED

MATROID

INTERSECTION

329

ALGORITHM

where C(I, x) denotes the uni&e circuit in I + x. Cl LEMMAS. L.etBbes-maximalin$k.L.etx,,x, ,..., x,andy,,y2 be distinct elements, yi E B, xi @ B (i = 1,2,. . . , 1) such that

,...,

yi

(3) B + xi @ 4 and yi E C( B, xi), C4) s(xi)

= s(Yih

(5) s( yi) = s( yj) and i
in Sk.

Proof Since s(B’) = s(B) and 1B’ I= k we have to prove the independence of B’. By induction on 1. The case I= 1 is trivial so let I> 1. Let yi be that element which minimizes (s( yj), j) lexicographically. Then i # j implies yi B C( B, xi); the contrary case would imply s( yi) L s( yj) by (1) and (4), and so s( yi) = s(5) because of the choice of y,, whence i >j by (5), contradicting the inequality (s( yi), i) < (s( yj), j). Now the induction hypothesis holds for B, = B - y, + xi and x1, x 2,...,Xi-l,Xi+l,...,X~,Y1,Y2,.--,Yi-~,Yi+l,~~~,Y~ from which the lemma follows. 0 Denote SF, = 9: n 9:. LEMMA 3. Let I E $:, and s,, s2 be functions on S with the property that s, + s2 = s and I is si-maximal in gik (i = 1,2). Then I is s-maximal in $t2. Proof Trivial. Cl For each possible k, the algorithm constructs I, s,, s2 satisfying the hypotheses of Lemma 3. The procedure starts with k = 0. Then k is increased one by one. An essential property of the algorithm is that, in every stage, the current I E 9t2 is s-maximal in $&. Suppose we have I E SF,,sl, s2 which satisfy the hypotheses of Lemma 3 and which have been constructed by the algorithm previously. From these we shall make I’ E 9:. ’ , s;, s; satisfying again the hypotheses of Lemma 3. Atthebeginningk=O,I= 0,s, ~0,s~ =s. Let mi = max(si( y): y @ 1, I + y E gi) (i = 1,2). Let Xi = {x:x B I, I + x E gi,si(x) = mi} (i = 1,2). Define an awriliary digraph G on S as follows: I. If x 6!.!I, I + x 6! $,, y E C,(I, x),s,(x) = si(y) then let (xy) be an edge. II. If x 6! I, I + x 6! 4, y E C,(I, x), s*(x) = s2( y) then let (yx) be an edge.

ANDIdSFRANK

330

By the well-known labeling technique [9], decide whether there exists a path from the set X, to X,. Case 1. If the path in question exists let U be a path of minimum number of vertices. (U is considered as a vertex set, and we shall need only that U is minimal.) Let I’ = I @ U, where @ denotes the symmetric s; = si (i = 1,2).

difference, and let

CLAIM 1. I’, s;, s; satisfy the conditions of Lemma 3 for k + 1. Proof. Let us denote the vertices of U by x,,, y,, x,, y2, x2,. . . , y,, xI (x0 E X,, x, E X,). By Lemma 1, B = I + x0 is s,-optimal in $[+I. Observe that the hypotheses of Lemma 2 hold for k + 1 and for B E y,. (Properties (3) and (4) are true because g+‘, x,, x 2,...,XI,Y,,Y2,...9 of the definition of G, (5) follows from the minimality of U.) Thus I’ is s,-optimal in 9:+‘. That I’ is s,-optimal in $:+’ can similarly be proved with the difference that one should rename the vertices of U just in reverse order (i.e., its last vertex will be x0 while the first one x,). 0 CLAIM 2. Proof

s(I’)

- s(I)

Obvious.

Cl

Case 2.

= m, + m2.

If there is no path let T consist of vertices having reached from

X2. Let s;(x) = s,(x) =

+ s

s,(x)

ifx E T ifx f?! T

and s;(x) = s(x) - s;(x). S = min(S,, 6,, 6, a,), where 6, = min(s,(y) S, = min(m, 6, = min(s,(y)

- s*(x): - s,(x):

- s2(x):

I + x 6! g,, x E T - I, y E C,(I, I+xE$,xET-I),

x) - T),

I+x@$~,xES-(TUI), Y E C,(L x) n T), I+xE$~,xES-(TUI)).

6, = min(m,

- s2(x):

(The minimum

is defined to be cc when it is taken over the empty set.)

CLAIM 3.

6=-o.

We prove that S, and 6, > 0. That S,, 6, > 0 can be proved similarly. If y E C,(I, x) - T then s,(y) 2 s,(x) by Lemma 1. But s,(y) = s,(x) would mean that (xy) is an edge in G leaving T, which is impossible. So 6, > 0. If x E S - (T U I) then x @ X2; thus the definition of m2 implies 8, > 0. Cl

WEIGHTEDMATROIDINTERSECTIONALGORITHM CLAIM 4.

331

I’ = I, s’, and s; satisfy the conditions of Lemma 3.

Proof: We prove only that I’ = I is s;-optimal in 9:. The s;-optimality can be proved similarly. By Lemma 1, we have to prove that (1) and (2) hold for s;. Choose elements x, y so that y E C,(I, x). If, indirectly, s;(y) < s;(x) then, because of s,(y) 2 s,(x), s;(x) = s,(x) + S and s;(y) = si(y) are implied. But 6 I 6, I s,(y) - si(x), that is, s’,(x) I s’,(y), a contradiction. Thus (1) holds. Choose elements x, y so that y E I, x 6! I and I + x E g,. If, indirectly, s;(y) < s;(x) then, because of sl(y) 1 s,(x), we have s;(y) = s,(y) and s;(x) = s,(x) + 6. But m, I s,(y) and 6 I S, I m, - s,(x), from which s;(x) 5 s;(y), a contradiction. Thus (2) holds. 0 Now again apply the algorithm starting with I’, s;, s;. Observe that the new T’ (if Case 2 occurs again) properly includes T, furthermore Xi 2 Xi (i = 1,2). C onse q uently, after no more than 1S 1applications of this loop of the algorithm, either Case 1 is attained or S becomes cc. The latter case means that the current I is of maximum cardinality since k = 1I I= r,(T) + rz(S - T). (Obviously, 1I’ 15 r,(T’) + r2(S - T’) for any common independent set I’ and T’ c S.)

COMPLEXITYOFTHEALGORITHM

The matroids are defined by the help of an oracle, which decides, in at most g steps, for an independent set I and an element x @ I, whether I + x is independent or not and in the latter case, determines the fundamental circuit C(I, x). The addition, subtraction, and comparison of two real numbers are considered as one step each. Let ISI = n and K denote the maximum cardinality of a common independent set (yet to be determined). The labeling technique requires at most n* steps to find a path or the subset T. However, if Case 2 occurs the current labels can be used again, because T’ > T, Xi _> X,, Xi 1 X2. Consequently, if Case 1 has occurred at any time, after no more than g-n* steps, Case 1 will have occurred again. Therefore the complexity of the algorithm can be bounded by 0( go Kmn*) I O(gn3). Remark. If the algorithm starts with s, = 0 then m, = 0, and S, = cc throughout the process. We have not exploited this simplification, in order to keep the symmetry between M, and M2 and to provide the possibility of starting with any 1, s,, s2 satisfying the conditions of Lemma 3.

ANDtiSFRANK

332

WEIGHTEDINTERSECTIONALGORITHM Input: Output:

Matroids M,, M, on S. Weight function s on S. Maximum cardinality K of a common independent set and T c S, for which r,(T) + r2(S - T) = K and Ik; a k-element common independent set of maximum weight (0IkIK)and st and st: for which sf + s’; = s and Zk is s:-maximal in $/ (i = 42).

Step 1

1.0. s, - O,s, = s, k = 0, Ik = 0. 1.1. Make the auxiliary graph. Determine X, and X,. 1.2. Find a path U from ._X, to X, by the labeling technique, using the labels having defined but not deleted previously. If it exists, go to step 3. Step 2

2.0. 2.1. cardinality 2.2.

Let T denote the Count 6. If S = and K = r,(T) + Let s,(x) = s,(x) 2.3. Go to 1.1.

set of vertices having labels. do, Let K = k, the current Ik has maximum rZ(S - T). HALT. + &s,(x) = s*(x) - 6 whenever x E T.

Step 3 Ik @ U. Let k: = k + 1. Ik is optimal

3.0. Let Ik+,:=

in 9& record

it. 3.1. Delete all the labels. 32, . s::=s

1,

sk*=s 2’

2’

3.3. Go to 1.1.

Now we show some consequences of the algorithm. Since neither m, nor Claim 2 implies a result of Krogdahl

ml increases during the algorithm [7, 91. COROLLARY. Sk+, -Sk s-maximal member of S:‘,.


-Sk-,,

where sj denotes the weight of an

We have proved the following. THEOREM. I E $fY is s-maximal if and only if there exist two weightings s, and s2 such that s, + s2 = s and I is s,-maximal in 5: (i = 1,2). If, in addition, s is integer valued then si can be chosen to be integer valued.

WEIGHTED

MATROID

INTERSECTION

ALGORITHM

333

The main consequence of the algorithm is a min-max theorem on the maximum weight sk of a k-element common independent set. The most convenient way to formulate it is to describe it as a linear program. Let Aj denote a 0- 1 matrix, the columns of which correspond to the elements of S while the rows correspond to the closed subsets of Mi. Let e denote a row vector consisting of )S 1 1’s. The following result is a version of Edmonds’ matroid polyhedral intersection theorem [3]. THEOREM.

Consider the dual pair of linear programs:

ex = k xro

max sx If the primal program ( * ) has a feasible solution it has an integral optimal solution. Moreover, if s is integral the dual program has an integral optimal solution. Proof. The primal optimal solution is defined as the incidence vector of Ik, where Ik is the optimum element of SF,, constructed by the algorithm. The dual optimal solution can be obtained from s, and s2. Let Ik = {e,, e2,. . . , ek} = {f,, f2,. . . , fk} so that

s,(e,) 2s,(e,)

2 +--Ls,(e,)

and s,(f,) 1

s2(h)

b

0

c

A

Example

for weighted

d

matroid

intersection

algorithm.

2 -m-1 sz(fd

334

ANDtiS

case

FRANK

--m--e2.1

[ Case

1. k =3 I.= (a.c.e)

Let E, = sp,(e,, e2,. . . , ei) and l$ = spI( f,, Y,(K)

l7

f2,. . . , 6.). Define

= sl(ei) - sl(ej+l)9

fori= 1,2 ,..., k- 1. Y,(l;;) = 4.6) - s*(f;+J Let t = s,(ek) + s2( fk). Using (1) and (2), a simple counting shows that

WEIGHTEDMATROIDINTERSECTIONALGORITHM

335

(y,, yr, t) is a feasible solution to ( * * ). The value of the objective function on (Y,,y2,0 is

*hW - sde2N+ 2Me2)- sded>+ *** +(k - *)Wh> - Sk)) + 1(s2(fi) - s2(hN +2(s,Ud - sz(LN+ - . . +(k - 1)@2(fk--l) - s2(Q) + k . t = r$Sdei)- Wed + i GA) - &(fk) + k * t i=l = 5 s(e,) = s(Zk). i=l

This proves the optimality of the primal and dual solutions. Moreover, if s is integer then so are si and s2 and thus y,,y2, as well. Cl Another consequence of the algorithm

deserving mention is:

For every k L 0, if $‘2+’ # 0, there exists an optimal solution to ( * * ) which, at the same time, is an optimal solution to ( * * ) for k + 1 instead of k. COROLLARY.

(This is the so called t-phenomenon;

see [S].)

Proof. Consider that stage of the algorithm when Zk+ , is arising. The vector (y,, y2, t) belonging to the current s,, s2 satisfies the requirements. The original version of Edmonds’ theorem can similarly be obtained: THEOREM.

[3].

A, [A1

Consider the dual pair of linear programs

(hY2)

IS

2

YlTY2 2 0

x 10,

max sx

~Ey,(z)r,(z)

+ %2(z)r2(z)

The primal program has an integral optimal solution. If s is integer valued the dual program has an integral optimal solution. Proof. For simplicity suppose that none of the matroids contains loops. Let us slightly modify the algorithm. Suppose that the algorithm starts with s, s 0, s2 = s, in which case m, = 0 and 13, = cc throughout the algorithm. Furthermore when Case 2 occurs set 6 = min( a,, 6,, S,, m2). If s I 0 the zero vectors appropriately dimensioned satisfy the requirements. If s 9 0, m2 is strictly positive when the algorithm is starting. Obviously the algorithm works in the same way as before until the value of 6 takes the current m2. (This case will certainly occur.) Now performing the changes in s, and s2 m2 becomes 0 (first time during the algorithm). Let Zk,s,,s2 denote the

336

ANDRAS FRANK

corresponding common independent set and weightings belonging to this stage. Now we have m, = m2 = 0 and s,(ek) 2 0, s2( fk) L 0. (Of course e,, . . . , ek and fi, . . . , fk may change when s,, s2 are changed.) Let y,(E,) and ~~(4) be defined as before but now for i = 1,2,. . . , k. Then y, L 0, y2 10 and, as can be simply checked, the incidence vector x of Ik and y,, y2 are optimal solutions to the primal and dual programs. Moreover, if s is integer valued then so are y, and y2. REFERENCES 1. G. CALVILLO, “Optimum Branching Systems,” Ph.D. thesis, University of Waterloo, 1978. 2. J. EDMONDS,Matroids and the greedy algorithm, Math. Programming l(l970). 3. J. EDMONDS, Submodular functions, matroids and certain polyhedra, in “Combinatorial Structures and Their Applications” (R. Guy, H. Hanani, N. Sauer, and F. Schonheim, Eds.), Proceedings, International Conference, Calgary, Alberta, Canada, 1969. 4. J. EDMONDS, Matroid intersection, in “Discrete Optimization,” Amtals of Discrete Mathematics, Vol. 4, North-Holland, Amsterdam, 1979. 5. H. GR~~FLINAND A. J. HOFFMAN,On matroid intersection, Cumbinatorica [a new Hungarian quarterly], in press. 6. M. IRI AND N. TOMIZAVA, An algorithm for finding an optimal independent assignment set, J. Operations Res. SIX. Japan 19 (1976), 32-57. 7. S. KROGDAHL, A combinatorial proof of Lawler’s matroid intersection algorithm, tmpublished manuscript, 1975. 8. E. LADLER, Matroid intersection algorithm, Math. Programming 9 (1975), 31-56. 9. E. LAWLER, “Combinatorial Optimization: Networks and Matroids,” Holt Rinehart Winston, New York, 1976. 10. M. CHUNG-FAN, L. CHEN-HUNG, AND L. MAO-CHENG, Optimum restricted base of a matroid, to appear. 11. D. WELSH, “Matroid Theory,” Academic Press, London/New York, 1976.