\ 194 -

1 \ Automata, Languages and ~rogrammlng 1

, verifying Concurrent Processes Using 12th Colloquium 18 pages.1982, Nafplion, Greece, July 15-19,1985 iomatisingthe ~ogicof Computer Program- 182.

s.Proceedings, 1881. Edited by 0. Kozen.

;iw Techniques I- Requirement6 and Logical 3, 1978, Edited by S.B.Yao, S.B. Navathe, .nit. V. 227 pages, 1982.

Design Techniques 11: Proceedings, 1979. T.L.Kunii.V, 229-399 pages. 1992. cificalion. Proceedings, 1981. Edited by J. 366.1982.

X2ProgiammingLogic.X,292 pages.108

~age8.1982. Edited by Wilfried Brauer I

on Automated Deduciion, Proceedings veland.VII. 389 pages. 1982. sopoulou. G. Per8ch.G. Goos, M. Daismann rchgassner, An Attribute Grammar lor the ida. IX, 511 pages. 1982. guages and programming.Edited by M. Niel- VII, 614 pages, 1982. 3. Hun, â Zimmermann. GAG: A Practical ', 156 pages. 1982. Springer-Verlag Berlin Heidelberg New York Tokyo Efficient Algorithms for Graphic Intersection and Parity s (Extended Abstract) algori by shorte impro Harold N.Gabow ' Matthias Stallmanu s Department of Computer Science Department of Computer Science O(n 1 University of Colorado North Carolina State University and c Boulder, CO 80309 Raleigh, NC 27695-8206 for s USA USA well- A Abstract matrc An algorithm for matmid intersection, baaed on the phase approach of Dinic for \ network flow and Hopcmft and Karp for matching, is presented. An implementation for the b graphic matmids uses time O(n1P m) if m is Of# fg n), and similar expressions indep otherwise. An implementation to find k edge-disjoint spanning trees on a graph uses eleme time O(VP nlP m) if m is 0(n lg n) and a similar expression otherwise; when m is main 0(fD I@) this improves the previous bound, 0(t? p2). hpmved algorithms for other undir problems are obtained, including maintaining a minimum spanning on a ( subject to changing edge coats, and finding shortest pairs of disjoint paths in a network. two, An algorithm for graphic matmid parity is presented that runs in time O(n m (a6 n). a pal This improves the previous bound of 0(n2 m). if an, The probl = 0, 1. Introduction. Matroid parity generalizes a broad class of combinatorial optimization problems that ! For i includes network flow and matching [La]. Yet it can still be solved efficiently [Lo,SG]. This paper presents more efficient algorithms for several cases of the parity problem. Section 2 develops a phase algorithm for , the "bipartite" parity 3. T problem. This generalizes the phase algorithms of Dinic for network flow, Hopcmft and Karp for matching, and Even and Tarjan for 0-1 network flow [D,HK,ETL It is shown inter that a phase algorithm for matroid intersection reduces to four matroid problems, the recei static-base/dynamic-base /cocycle problems. Some of the results in Section 2 for 1 overlap recent work of Tovey and Trick [TT), and even more recently Cunningham [C]. inter The overlap (indicated precisely in Section 2) is not adequate to achieve the time bounds for I of this paper. equil An efficient implementation of the intersection algorithm for graphic matmids is presented in Sections 3-5. Section 3 gives an overview and timing analysis. The time is cone 0(n112 m) if m is O(n3fl Ig n). This is identical to the Hopcroft-Karp bound for matching, a special case of graphic matmid intersection. The four matroid problems Defu mentioned above make other cases more difficult. The time is O(n m213 1$13 n) if m is ¡1 a fl(n Ig n) and a similar expression otherwise. f Planar graphs can be handled more efficiently because of duality. Section 3 gives a f bound of 0(n3I2 fg n). The approach also gives an algorithm for maintaining a minimum all t on a planar graph subject to changing edge costs. The time is 0(lg n) per update, improving the O(Ig2 n) bound of Frederickson IF]. ace Section 3 also givw an implementation of the intersection algorithm to find k Not6 edge-disjoint spanning trees on a graph. It uses time 0(i31? n1D m) if m is Q(n lg n) and that a similar expression otherwise. When m is O(kIl? nap) this improves the bound of folio O(* n2) due to Roskind and Tarjan [RT]. The, ' This work was supported in part by NSF Grant #MCS-8302648. 21s. Parity Section 4 solves the static-tree cocycle problem used in the graphic intersection algorithm. The solution also speeds an algorithm of Suurballe and Tarjan for finding shortest pairs of disjoint paths in a network [Su TI. The time bound is O(m + n Ig n), improved from 0(m lg^,^ n). Section 6 solves the dynamic-tree cocycle problem. mann Section 6 presents an efficient parity algorithm. The time bound is 1 Com~uterScience 0(n m If n), improving the bound of O(n2 m) of [SG]. In the parity problem the cycle a. State University and cocycle problems involve pairs of edges. This seems to make traditional techniques !7695-8206 for solving cycle and cocycle problems inapplicable. We reduce the problem to a well-studied problem of computational geometry, range searching. Many of the ideas of this paper apply to other , such as job scheduling matroids [GT84] and linear matroids. We will discuss these extensions in a future paper. iroach of Dinic for We close this section with some terminology. The reader is assumed familiar with implementation for the basic notions of matroids (see, e.g., [A, La, W]). It e is an element and B a base (or similar expressions independent set), C(e,Sf denotes the fundamental cycle of e in B. The span of a set of H on a graph uses elements A is denoted q(A). If T C S are seta of elements then S / T denotes the ; when m is matroid restricted to S, with T contracted. A graphic matroid is derived from an ' ilgorithms for other undirected graph; its independent sets are the forests. on a planar graph Consider a matroid M over a set of elements E that is partitioned into blocks of size ~athsin a network. two, called parity pairs. Thus each element e has a mate, denoted 2, such that {e, 2) is time 0(n m If n). a parity pair. A matching M is an independent set consisting of parity pairs, i.e., e â M if and only if s  M. A maximum matching has the greatest number of pairs possible. The (cardinality) parity problem is to find a maximum matching. The matroid intersection problem is the "bipartite" version: M is the direct sum of matroids Mi on elements E', i = 0,1, and every parity pair contains one element from each matroid. T: ;ation problems that Sections 4-6 use these terms for a tree \T\ denotes the number of vertices in T. For edge w of T, v'a subtree is the tree of w containing v. 1 efficiently [Lo,SGL T - jarity problem. ie "bipartite" parity 3. The phane algorithm for matroid htenection. now, ~op~roftand This section derives results that are needed for a phase algorithm for matroid K,ET]. It is shown intersection. It concludes by sketching the algorithm. Some of the results have been itroid problems, the recently obtained using different methods. Tovey and' Trick [TT]derive a phase algorithm esults in Section 2 for polymatroidal network flow. This problem, which generalizes network flow and matroid ly Cunningham [C]. intersection, was introduced by Lawler and Martel [LM], who prove much of the theory eve the time bounds for the phase algorithm. Our Corollary 2.1 is similar to [TT]. Cunningham [C] derives equivalents of our Corollaries 2.1-2.2. graphic matroids is We begin with some facts that apply to the . The basic lalysis. The time is concept is the augmenting path: >ft-Karp bound for r matroid problems Definition 2.1. An augmenting path for a matching M consists of distinct elements $I3 Iglls n) if m is , B, f M, 0 5 i 5 k, b,, 6. â M, 0 < i 5 k, such that the sets Mf=(M+\)+a,+a,- 6,-8 ,...- ti++(0$i5k),and Section 3 gives a Mi=(M+#,)+a,+a,-b,-8 +~,-~-b,(O

Theorem 2.1. In a matroid parity problem, let hi and N be matchings, with IN = IAfl + 2k Then there is a sequence of paths P, ,..., Pi such that Pi is an augmenting path for =M9PI9... 9~.l,q-MCN-M,qnMCM-N,andallpathsPi Suppose i Â¥ are disjoint. by induction ai Proof. For kl, modify N to a matching contained in M U N whose span includes '(e,+,) 5 i t 2, sp(fvf). Then use a swapping argument, as in [SG]. For k>1 use induction. ' Next supy ~~(ff~,~~).by The rest of thii section is restricted to the matroid intersection problem. Recall that in matroid intersection the ground set E is the disjoint union of qronnd sets Ei i = 0.1. It is convenient to extend this notation so that for any set of elements S, S1 S HE', i then the same = 0,l. Also, without loss of generality restrict the definition of an alternating path (and that if e, is in also augmenting path) so that the first element a. €E Thus any a, ? EL M, a, â El - M, ti â Mi, 8,  Ma. The matru maximal sap se Definition 2.1. If I is an independent set, eJ is a swap for I if sp(I @ {ea) = q(fl and 2.1(iii). The ne either e â Mi, J â ELM, or e â E1 - M f â M1. Corollary 2.2. I Thus in an alternating path the pairs 4, &u, and 8,, a, are swaps. and let n = lh The cardinality intersection problem is solved by repeatedly finding an augmenting Proof. It suffici path of shortest length [La], which we call a sap. The structure of saps is analyzed by that IPuJ ? If introducing a "leveln function: For any element e, the level He) is the length of a shortest The comtr alternating path ending with e. In the following discussion, fx a matching M. The level function I is always defined with respect to M, even though other matchings will be matroid (Mi U constructed. The basic fact about levels is that in a sequence of saps of the same length, M^ n N. Thl each sap has its elements on consecutive levels. This is proved as follows. (Mt1 u Jv) 1 ( (4U iV) I (A Lemma 2.1. If e,{ is a swap for M then 10 5 l(e) + 1. for MI in the s: Proof. If I0 > l(e) +I, the sequence of swaps defining I(e) preserve the validity of swap e,l, so 10 = l(e) +l. . For netwoi find a sap. Fi For a set of elements S define Sjk = {el e â 5, j S l(e) 5 k}. Also define S, augment changi Sw how to handle Lemma 2.2. Let N = M 9 PI @ ... @ P where k > 0, each Pi is an augmenting path for M @ PI 9 ... 9 Pi.,, and each swap e,J of Pi has I(/)= l(e) + 1. Then corresponding t 48-1 and bf, = = Â¥"'WOl) for i = 2 mod 4 Et4, C ~P(N~~- N4,+l), for i = 3 mod 4. Lemma 2.3. Le Proof. First suppose N = M. Let e be an unmatched element. If e ? El then l(e) = 1 level l(e) = i z mod 4, and Lemma 2.1 shows the elements of C(e,M) are on level l(e) + 1 or lower. Ii the swap in P, e â Eo then l(e) = 0 mod 4, and Lemma 2.1 shows the elements of C(e,M\ are on level and only if it i: l(e) - 1 or higher. Proof. We pro' It is easy to see that the swaps of Pi do not change the spans of the Lemma. a ground set El. A sap sequence is a sequence PI ,..., Pi of disjoint paths Pi of the same length, such show that Cl,j+i First obser that PI is a sap for M 9 PI 9 ... 9 Pi_,. 2.2, Corollary 2.1. Let P, ,..., Pk be a sap sequence, and let P = el ,..., be an augmenting Lemma mi path for the matching M 9 PI 9 ... 9 Pi. ad ~P(N~,~.~): Ml,l-l)a as desip (:) l(ei) 5 i, for all i. (ii) It lfl = lPll then I($) = i, for all i. Next observ fiiil It some edge e, is in some P, then IP! > .IP.!. .. +e-y>=*?( proof. Prove the ~&&yby induction on k. ' By the inductive assertion (it) holds for all paths PI, so Lemma 2.2 applies. We first show that (8) holds by induction on i. Assume The algoritb that ((4 5 i for some odd level i. Step 1: Determi Suppose i = 1 mod 4, so e, â El. The swaps preceding e, do not change sp(Niu.,), by induction and Lemma 2.2. Since e, â ~p(Ni,~+~), 5 i + 1. Since +, = ;,+,, I)5 i + 2, as desired. Next suppose i s 3 mod 4, so el â 5". The swaps preceding c, do not change S~(N&,,~~),by induction. Since any element / ? EO on a level greater than i + 1 is in ÈP(N~,~)1('1+1) 5 i + 1. Since e, = %,, l(e,+,) 5 i + 2. e conch e that (I) is true. The same argument shows that if l(e,) < i for some i then the same holds for all subsequent i, so IP] > lP,l. This implies (is). For (ii:) note that if e, ia in P, then = I(+) - 1. a The matroid intersection algorithm consists of phases, where each phase augments a maximal sap sequence. The length of a sap increases from phase to phase, by Corollary 2.1(iifl. The next result allows the number of phases to be bounded precisely.

Corolhry 2.2. For a matching M let s denote the number of matched elements in a asp, and let n = IAfl + A denote the cardinality ofa maximum matching. Then 8 A 5 n. Proof. It suffices to show that the A disjoint paths PI of Theorem 2.1 can be chosen so that lPMl1 S 141. For then each path has ? t matched elements, so t A < n. The construction of Theorem 2.1 allows Plt1 to be chosen as a sap for MI in the matroid U N) fl N). This implies that N C U and fl C Aer matchin- will be (4 / (MI Mw U MI N, MI N & of the s&e length, M,+, n N. Thus lPl+,l is the length of a tap for M,+, in the matroid fellows. (MI+,U N) / (MI+,n N), which is at least the length of a sap for M,,, in the matroid 3t (MI U N) I (MI n N). By Corollary 2.1(9 the latter is at least than the length of a sap for MI in the same matroid, which is lPitll. a ve the validity of swap For network flow a phase is implemented by repeatedly searching a "level graphn to find a aap. For matroid intersection this approach is complicated by the fact that each The next result shows Also define  Sy. augment changes the valid swaps, thus changing the level graph. how to handle the changes efficiently. Divide the given matroid M into matroida M( is an augmenting path corresponding to levels that are paired in swaps. That is, i bges over all odd levels 5 1. Then 4-1 and MI = (MU / (M - My+,). Note that Mytl is a base of M,

Lemma 2.3. Let PI ,..., P, be a sap sequence. Let e be an element that is on an odd e â El then l(e) = 1 level l(e) = i and is not in any P,. Let J be an element with I(/) = i + 1. Let g,,h, be I(+ t 1 or lower. If the swap in P, with Q) = i, j = 1, ..., t. Then eJ is a swap for M C3 P, C3 ... @ P, if of C(e,h$ are on level and only if it is a swap for Mi,++l @ {gl,b, ,..., a,,!+> in the matroid M,. Proof. We prove the case e f. M; e ? M is similar. e f. M implies that e is in the of the Lemma. a ground set El. Let N = El n (M C3 PI C3 ... C3 Pk) and C = C(e,JVl. It suffices to the same length, such show that C,,l+l is a cycle in M,. First observe that is dependent in hf,: The greatest level in C is i + 1, by so C , 4 be an augmenting Lemma 2.2, and no element of N + e is on level 0, = CLw. Since Cl,l_l C Nw

ertion (it) holds for all nduction on i. Assume The algorithm for a phase is as follows: Step 1: Determine the level l(e) of every element e. I I

Step P: Construct the matroid M) and its base Mi,,+,, for every odd level 5 48-1. In Step 8: Find a path c, ,..., e,, where l(q) = i, = %,, and %,bis a swap for the matroi current base of Ma,,. Augment the matching along the path. Repeat this step until the depth- desired path does not exist. T edge- Step 1 is done by breadth-first search. This search is easily programmed using can bi algorithms for two matroid problems: In each problem, a base B is given and does not partiti change. Every matmid element is to be output at most once. The static-base cycle proble problem is to execute a sequence of operations, for k cycte(e): For element e EB, output all elements in e's fundamental cycle match (that have not been output already). and 2 The static-base cocycle problem is to execute a similar sequence of operations, cocycle(e): For element e ?B, output all elements in e's fundamental cocycle Theon (that have not been output already). (-5 (If J gets output in an operation for e then e,J is a swap.) (ill Step 3 is done by depth-first search. This search, is programmed using algorithms for these dynamic versions of the two problems: A base B is given, but it changes. v Every matroid element of the matroid is to be output at most once. The dynamic-base to the cycle problem is to execute a sequence of operations cycle(e), defined as above, and also T upddt(e,fl: Execute the swap e,J, thus changing the base B. for cy The dynamic-base cocycle problem is defined similarly. G cox The depth-first search calls the routine for cycle(e) or cocycle(e) to find the next proble element of the path. When the first element is output, the routine is suspended and the search is continued. If the search is unsuccessful, eventually the cycle or cocycle routine Theor is resumed, the next output element is handled similarly. If the search is successful the time I routine is aborted. The augment step does updates for all swaps that lead to success. In many matroids the dynamic-base problem is harder than the static. In this case it T is more efficient to find the last few saps one by one. This leads to following outline for subjec the matroid intersection algorithm. Here p is a parameter, determined by the efficiency of Comll the static- and dynamic-base algorithms. can bi Step 1. Run p consecutive phases, each phase finding a maximal sap sequence and augmenting it. Use the static- and dynamic-base algorithms. Step 8. Find the remaining saps one at a time, augmenting by each one. Use the 1' static-base algorithms. Let tl I for sc S. Graphic matroid intersection. match This section presents the graphic matroid intersection algorithm and its analysis. It (Step first outlines algorithms for the two cycle problems. Intersection problems that can be (1) solved using only cycle algorithms- planar graphic matroid intersection and k disjoint At m spanning trees, are discussed. Then the analysis of the intersection algorithm for gene& seard graphic matroids is given. (Details of the cocycle algorithms are in Sections 4-6.) 'I The static-tree cycle problem is solved by set merging. The algorithm maintains the edges partition of the vertices of the tree into subtrees formed by the edges that have been output. Since the tree is initially given, the static tree algorithm of [GT83]can be used. for sc The time is O(m). edges The dynamic-tree cycle problem is solved by the dynamic tree data structure of Let 1> [Sl T) and set merging. The given tree is represented as a dynamic tree. In addition, set merging is used to maintain the partition of the vertices into subtrees formed by the edges that have been output but not swapped out (in update operations), plus the edges that have been swapped in. The partition allows dynamic tree operations to be done only when at least one edge is output The set merging time is O(m a(m,n)) 1% The dynamic tree time is 0(n 1g n). This gives a total time of O(m + n Ig n) [TI. In addition to the cycle and cocycle algorithms, the phase algorithm constructs the matroids M, and bases Miam (see Step 2). For graphic matroids this is done in a depth-frat traversal of the spanning forest M The time to 0(m + n). These algorithms solve two intersection problems of interest. The first is to find k edge-disjoint spanning trees of an (undirected) graph G. This matroid partition problem can be reduced to the matroid intersection of a graphic matroid (k copies of GI and a partition matroid. If the algorithm starts all searches in the partition matroid, only cycle problems are solved in the graphic matroid. The time for a phase is 0(k(m + n lg n)), for k static-cycle problems and k dynamic ones. Note that the size of the maximum matching is at most kn. Choosing the parameter p of the algorithm to balance Steps 1 and 2 (see Section 2) gives the following.

Theorem 3.1. k edge-disjoint spanning trees can be found in the following time: (0 0(f12 nlD m) if m is 0(n lg n); (it) O(@D n mlD Ig112n) if m is O(n Ig n). d using algorithms a, but it changes. Variants of this problem can be solved by the, same techniques, and have applications The dynamic-base to the Shannon switching game [BW] and structural rigidity [H. above, and also The intersection problem on planar graphs can also be solved using only algorithms for cycle problems: The given graph G has a planar dual G. A fundamental cocycle in G corresponds to a fundamental cycle in G. So the algorithm need only solve cycle to find the next problems on the graph G and its dual G. aspnded and the or cocycle routine Theorem 3.2. The graphic matroid intersection problem on planar graphs can be solved in h is successful the time O(n'J2 19 n). . id to success. itic. In this case it This observation improves the results of [P] for maintaining a illowing outline for subject to changing edge costs. iy the efficiency of Corollary 3.1. The edge-update problem for minimum spanning trees on planar graphs can be solved in 0(lg n) time per update. sap sequence and

31 one. Use the Now we give the analysis of the intersection algorithm for general graphic matroids. Let the time for a phase, exclusive of augments (i.e., updates), be O(n mr If n), for some real values r

6. Dynamic-tree cocycle~. This section proves the following result. Theorem 6.1. Fix a value z 5 m/S. The dynamic-tree cocycle problem can be solved in 1 in the following O(m + n) time for initialization, O((m/z)lg n + c) time for a cocycle operation that 17 outputs c edges, and 0(z + (m/z)z) time for an update. The data structure has two levels and is involved. Space allows just an overview. We begin with some ideas due to Frederickson [F]. Without loss of generality assume that the graph G has maximum dew A53. Let T be a spanning tree. A cluster is a subtree S with z 5 18 <- 32. A topological partition is a partition of the vertices into clusters. The contracted graph G' is derived by shrinking each cluster of a topological partition to a vertex. G' has O(m/z) vertices and O((m/.)q edges. The tree I T corresponds to a spanning tree T' of G'. I The first level of the data structure is the static-tree data structure of Section 4. on tatic-tree cocycle the graph G*. G* uses its inherited preorder, defined as follows. The cluster containing the root of T is the root of T'. If a cluster C is joined to children clusters Cl by edges G with spanning q~,,q CC, the order of Cl in inherited preorder is given by the preorder of q in T. In ge is deleted, all inherited preorder, the descendants of a vertex v that are not in 9s cluster form a set of At my point in consecutive clusters. This allows the algorithm of Section 4 to be used. An update is . ;es, and any edge executed using the techniques of [F]. In addition, the adjacency lists of G' must be sorted on the new inherited preorder, using time O((m/z)q. y adjacency lists. The second level of the data structure is based on topology trees [Fl. Let T be a is doubly-linked tree with A53. A fopology free 2 for T is a binary tree of height 0(lg 171). The root 01" es y in preorder). S corresponds to an edge e that separates T into subtrees T; i=l,2; the subtrees of the ijacency list}. root are topology trees for T,. The leaves of  are the vertices of T. Order the vertices where vertex p is by their left-to-right order as leaves in 2. The vertices in a node a of  correspond to itermine which of a subtree of T, and form an interval in this order. el, stopping when If T is a spanning tree of a graph G, we add the edges of G to the data structure 1: for 2 as follows. Let 0.7 be nodes of 2 with T a sibling of a node in a's path to the remove the two root. The (directed) t-edge or consists of all edges of G with one end in a and the other id then from the in r. If a and T are siblings we store the t-edge w as a search tree 5. In S (directed) out zy and delete edges w in or are ordered on v (using leaf order in S). A t-edge pr (p a descendant of an when the first u) is an interval in S. The space for all search trees is 0(m), since an edge of G is in at most two search trees. every vertex 2 in The second level of the data structure uses topology trees as follows. Every cluster C has a topology tree. Every edge of G joining two vertices of C is represented in the endant of c to a topology tree's data structure. The edges in C that are part of a cocycle are found as ige O(1) when it If n intervals in search trees. is visited at most Similarly, each edge CD of G' has two search trees, each containing all edges of G joining clusters 0 and D. In (7s search tree edges are ordered by preorder of their C-vertex; similarly for D. If edge e is in C, the CD edges in e's cocycle are found as n lg n) time and O(m/z) intervals in (7s search trees. ~ 1 218

1 6. Graphic matroid parity. This section outlines an efficient implementation of the matmid parity algorithm on that gives First we review the linear matroid parity algorithm of [SG]. The algorithm searches querk for one augmenting path at a time. The search is breadth-first, i.e.. elements are ( seamed in the order they are labelled. The i"1 element e to be labelled (scanned) has and i serial number s(e) = i. An element is scanned by propagating its label to other elements. other This is done in a "grow" or "blossom" step. A grow step labels one previously unlabelled e is element, as is in the algorithms for network flow and matroid intersection. A blossom step appro labels several elements, as in general graph matching. It also combines the blossoms delete previously containing these elements into a new blossom. (Initially every element is in a t blossom by itself.) Further, the blossom step can create a transform element. This is an repre element that is not in the given ground set of the matroid, but gets added to it. In nondf: graphic parity a transform consists of two edges that are both matched or both unmatched. (The edges are not necessarily mates). A transform is considered matched or Ife unmatched depending on the status of its edges. Note that in the following discussion the C(e1) terms edge, transform, and element are used. To reiterate, an edge is in the given graph; from a transform consists of two edges; a (matroid) element is either an edge or a transform. The main criterion for doing a grow or blossom step for two elements x,y is that If e they are adjacent, i.e., if M is the current matching then x â M, y f. M and ances sp(M - z+ y) = 3p(Afl. It is convenient to define a set of edges G(e) for an element e as follows: If e is an unmatched edge, C(e) is e's fundamqtal cycle; if e is a matched If e edge, C(e) is e's fundamental cocycle. If e is a transform consisting of edges el,+, then tl,h) G(e) = C(e,) 8 C(+). Elements e and J are adjacent if either e is an edge and even e â GO) or e is a transform consisting of edges el,+ and I exactly one of el,% ? C{f). Each (Here either of e,f can be the matched element, and J can be an edge or a transform). or tr When the algorithm scans a labelled element e, a grow step is done for any its bl unlabelled edge f adjacent to e. A blossom step is done for a labelled element J that is I adjacent to e and in a different blossom. Blossom step must be done in the correct for s< order: the next blossom step is for the element f that satisfies the above criterion and has Step smallest possible serial number SO) < sic). numt Now we describe how to implement the algorithm by using range searching. The Step spanning tree of matched edges is numbered in preorder. Hereinafter identify each vertex with its preorder number. Matroid elements are represented as tuples, as follows. An every unmatched edge ij is represented as the ordered pair (13, where ii..b,] X l%..b2]. Thus P(S) can be found query by making O(1) range queries. For i â [l..n], 48) is the set of all intervals that include the 01 i, 4:) = [l..:] X [i..nj. For O(1) points 4, 844) is the union ot O(1) rectangles. Hence Ollf it can be found by making O(1) range queries. T The algorithm uses several multi-dimensional universes U to store the elements f that can cause grow or blos5om steps. An expression R(e) using the above set constructs gives the elements f that are adjacent to e. So to scan e the algorithm makes range queries to retrieve the sets R(e) fl V, and does grow or blossom steps as appropriate. k' i.e.. elements are Grow steps are done by maintaining two universes that contain all edges f, where f ,beued' (scanned) has and its mate T are both unlabelled. One universe contains matched edges f, and the d to other elements. other contains unmatched edges. The universes are two-dimensional. When an element previously unlabelled e is scanned, the grow steps for e are done as follows: All edges / that remain in the :tion. A blossom step appropriate universe and are adjacent to e are found and labelled, and both f and 7 are ~binea the blossoms deleted from the universe. very element is in a Now we give the expression R(e) for the edges adjacent to e. If e is a matched edge dement. This is an represented as (I,h), an unmatched edge in C(e) joins a descendant of I to a pts added to it. In nondescendant. Hence , matched or both R(e) = P([l..h]). ,widered matched or If e is a matched transform e,,% with c, represented as (l,,hJ, an unmatched edge in , !owing discussion the C(el) 0 C(%) joins a vertex descending from exactly one vertex I, to a vertex descending in the given graph; from zero or two vertices 4. Hence or a transform. We) = P([i,..hll 0 ll,..t-1). elements x,y is that If e is an unmatched edge represented as (ij), a matched edge (1,h) in C(e) has I an M and ancestor of exactly one of ij: Hence '(e) for an element e R(e) = I($) 0 10. ; if e is a matched If e is an unmatched transform of edges e,,% represented as (i,, ..., i,), a matched edge of edges el,%, then (1,h) in C(e,) @ C(&;) has I an ancestor of one or three of the vertices 6. (This holds 1 edge and even when two vertices 4 are identical.) Hence fi(e)= I(il) 0 ... 0 I(.,). Blossom steps are done by maintaining four universes of labelled, scanned elements. -Each universe contains either matched elements or unmatched elements. and either dares" or a transform). or transforms. A tuple in a universe consists of the representation of an element e, plus p is done for any its blossom and serial numbers b(e), s(e). Hence a universe has four or six dimensions. ed element f that is After an element is scanned it is inserted in the appropriate universe. The procedure done in the correct for scanning an element e for blossom steps is as follows: we criterion and has Step 1. Let L = {f \ f is an element that is adjacent to e and has smallest possible serial number in its blossom}. age searching. The Step 2. Let b(g) be the blossom in {b(/J 1 f EL} + b(e) that has the most elements. For identify each vertex les, as follows. An every element h in a blossom of {bo I f EL } t b(e) - b(g), set Mh) to b(g). j. A matched edge Step A Do a blossom step for each element f E L, in order of increasing serial number I,h), where h is the sul. B ordered four-tuple Step 1 constructs L by making range queries on the universes for blossom steps. The two edges of the edges f adjacent to e are found using the above formulas for R(e). The transforms f C\ U. I < i,. adjacent to e are retrieved by a query R '(e) f is adjacent to e if exactly one of its elled element e, Me) edges is in C(c). Hence R '(e) = P(R(e)). notes the interval of Each query finds the element f of smallest serial number in R(e) f\ V or R '[e) C\ V, S [l..n], and let and subject to the restriction that b(/J > bu), where f is the last element found in L. Cartesian product of The coordinates b(e) and a(e) in the blossom universes can be combined into one ion of O(1) intervals coordinate, w(c) = 2mb(e) t a(e). (Note that any serial number is less than 2m.) The us P(S) can be found query of Step 1 can still be done with a range search. Step 2 changes b(h) by deleting intervals that include the old tuple for h and inserting a new one. The data structure of [Lul uses time O(l@ n) for each query or update in the higher (five) dimensional universe. 1) rectangles. Hence The total time for the parity algorithm is dominated by the time for blossom steps. This is dominated by the updates in Step 2. An element is modified 0(lg m) times, since each modification doubles the size of its blossom and a blossom has at most 2m elements. So the total time for one element is O(1f n).

Theorem 6.1. The graphic matroid parity problem can be solved in time 0(nm If n) and space 0(m Iff4 n). 1. Inl Order partia an ale genera References genera M.Aigner, Combinatorid Theory, Springer-Verlag, New York, 1979. [A] sound [BWlJ.Bruno and L.Weinberg, "A constructive graph-theoretic solution of the Shannon constr switching game", IEEE Trans. on Circuit Theory CT-17, 1, 1970, pp.74-81. lifting (CI. . W.H.Cunningham, "Matroid partition and intersection algorithmsn, Carleton rewril University, preprint. Â [Dl E.A.Dinic, "Algorithm for solution of a problem of maximum flow in a network with power estimation", Sov. Math. DM. 11, 6, 1970, pp.1277-1280. [ET] S.Even and R.E.Tarjan, "Network flow and testing graph connectivity", SIAM 3. Comput.4, 1976, pp.607-618. Â [F] G.N.Frederickson, "Data structures for on-line updating of minimum spanning trees", Proc. IS* Annual Symp. on Theory of Computing, 1983, pp.262-267. [GT83] H.N.Gabow and R.E.Tarjan, "A linear-time algorithm for a special case of disjoint set union", Proc. 15th Annual ACM Symp, on Theory of Computing, 1983, pp.246-261. . [GT84[ H.N.Gabow and R.E.Tarjan, "Efficient algorithms for a family of matroid , intersection problems", J.Algorithms 5, 1984, pp. 80-131. [HK] J.Hopcroft and R.Karp, "An n512 algorithm for maximum matchings in bipartite I graphs", SUM J. Comput.2, 1973, pp.226-231. [I] H.Imai, "Network-flow algorithms for lower-truncated transversal polymatmids" J. . Operations Res. Sac. Japan 26, 3,1983, pp.186-210. [La1. . E.L.Lawler, Combinatorid Optimization: Networks and Matroids, Holt,Rinehart,and Winston, New York.1976. - [Lo] L.Lovasz, "The matroid matching problemn, in Algebraic Methods in , Collcauia Mathematica Smietatis Janos Bolyai, Szeged,Hungary, 1978, pp.496-517. [Lu] ~.~.~ieker,"A data structure for orthogonal range queriesn, Proc. Iff^ Annual Symp. on Foundations of Corny. Sci., 1978, pp.28-34. [LM] E.L.Lawler and C.U.Marte1, "Computing maximal 'polymatroidal' network flows',Math. of Operations Research 7, 1982, pp.334-347. [RT] J.Roskind and R,E.Tarjan, "A note on finding minimum-cost edge-disjoint spanning treesn, Math. of Operations Research, to appear. [SG] M.Stallmarm and H.N.Gabow, "An augmenting path algorithm for the parity problem on linear matruids", Proc. 25th Annud Symp. on Foundations of Comp. A maj Sci., 1984, pp.217-228. stack [Sl TI D.D.Sleator and R.E.Tarjan, W data structure for dynamic treesm, J. Comp. and seman System Sci. 26, 1983, pp.382-391. langu: ISu TI J.W.SuurbaBe and R.E.Tarian. "A auick method for finding. shortest pairs of paths", Networhs 14, 1984, ppr326-336. [TI R.E.Tarjan, Data Structures and Network Algorithms, SIAM Monograph, Philadelphia, 'sup Pa., 1983. Grant I [TT] C.A.Tovey and M.A.Trick, "An O(m4 d) algorithm for the maximum polymatroidal flow problem", Georgka Institute of Technology, preprint. 'CRI at SRI [W] D.J.A. Welsh, Mafroid Theory, Academic Press, New YoA,l976.