Minimum Cycle Basis and All-Pairs Min Cut of a Planar Graph in Subquadratic Time

A minimum cycle basis of a weighted undirected graph $G$ is a basis of the cycle space of $G$ such that the total weight of the cycles in this basis is minimized. If $G$ is a planar graph with non-negative edge weights, such a basis can be found in $…

Authors: Christian Wulff-Nilsen

Minim um Cycle Basis and All-P airs Min Cut of a Planar Graph in Sub quadratic Time Christ i an W ulff-Nilsen ∗ Octob er 31, 2 018 Abstract A minim u m cycle basis of a w eigh ted und irected graph G is a b a- sis of th e cycle space of G suc h th at th e total w eight of the cycles in this basis is minimized. If G is a planar graph with non-negativ e edge w eigh ts, s uc h a basis can b e foun d in O ( n 2 ) time and sp ace, where n is the size of G . W e show that this is optimal if an explicit repr esen- tation of the b asis is required. W e then present an O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space algorithm that computes a minimum cycle b asis implicitly . F rom th is resu lt, we obtain an output-sensitiv e algorithm that explicitly compu tes a minimum cycle basis in O ( n 3 / 2 log n + C ) time and O ( n 3 / 2 + C ) space, where C is the total size (n umb er of edges and vertice s) of the cycles in the b asis. These b ounds reduce to O ( n 3 / 2 log n ) and O ( n 3 / 2 ), resp ectiv ely , when G is u n weig hted. W e get similar resu lts for the all-pairs min cut problem since it is du al equiv alen t to the minimum cycle basis problem for planar graph s . W e also obtain O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space algorithms for finding, resp ectiv ely , the weig ht vec tor and a Gomory-Hu tree of G . The p revious b est time and space b ound for these t wo problems was quadratic. F r om our Gomory-Hu tree algorithm, we obtain the fol- lo wing result: with O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space for prepr o- cessing, the w eigh t of a min cut b et wee n any t w o given vertice s of G can b e rep orted in constant time. Previously , s u c h an oracle required quadratic time and space for prepro cessing. The oracle can also b e extended to rep ort th e actual cut in time prop ortional to its size. ∗ Department of Computer Science, University of Cop enhagen, k oolooz @diku.d k , http:/ /www.d iku.dk/hjemmesider/ansatte/koolooz/ 1 1 In tro duction A cycle ba sis of a gra ph is a set of cycles that gives a compact represen tatio n of the set of all the cycles in the graph. Suc h a represen tation is not only of theoretical in terest but has also found practical use in a num b er of fields. One of the earliest applications is in electrical circuit theory and dates bac k to the w ork of Kirc hhoff [17] in 1847. Kn uth [18] used them in the analysis of algorithms. Cycle bases also play an imp o rtan t ro le in c hemical a nd biological path w ays, p erio dic sc heduling, a nd graph dr awing [15]. See also [4, 5, 6, 8 , 20, 23, 25]. In many of the ab ov e applications, it is desirable to ha ve a cycle basis of minim um total length or, more generally , of minimum t otal w eigh t if edges of the graph are assigned we ights. The minim um cycle basis problem, formally defined b elow, is the problem of finding suc h a cycle basis. F or a surv ey of applications and the history o f this problem, see [1 4 ]. Let us define cycle bases a nd minim um cycle bases. Let G ( V , E ) b e an undirected g raph. T o eac h simple cycle C in G , w e asso ciate a v ector x indexed o n E , where x e = 1 if e b elongs to C and x e = 0 otherwise. A set of simple cycles of G is said to b e indep endent if their asso ciated v ectors are indep enden t ov er GF (2). The ve ctor space o v er this field generated by these v ectors is the cycle sp ac e of G and a maximal indep enden t set of simple cycles of G is called a c ycle b asis of G . An y cycle ba sis of G consists of m − n + c cycles, where m is the n umber of edges, n the n umber of v ertices, and c is the n um b er of connected comp onents of G [26]. Assume that the edges of G ha v e real w eigh ts. Then a min i m um c ycle b asis (MCB) of G is a cycle basis suc h tha t the sum of w eigh ts of edges of the cycles in this basis is minimized. The MCB problem (MCBP) is the pro blem of finding an MCB of G . The MCBP is NP-hard if negativ e w eigh ts are allo w ed [1 2]. The first p olynomial time algorithm for graphs with non-negativ e edge w eights w as due to Hort o n [14]. His idea w as to first compute a p olynomial size set of cycles guaran teed to con tain an MCB. In a subsequen t step, suc h a basis is then extracted fro m this set using a greedy alg o rithm. R unning time is O ( m 3 n ). This was impro ve d in a sequenc e of pap ers [7, 9, 2, 16, 21, 1] to O ( m ω ), where ω is the exp onen t of matrix m ultiplication. F or pla na r graphs with non-negative edge weigh ts, an O ( n 2 log n ) algo - rithm w as presen ted in [1 2]. This was recen tly improv ed to O ( n 2 ) [1]. The quadratic time b ound also holds for the following problem for pla- 2 nar graphs since it w as sho wn to b e dual equiv alen t to the MCBP fo r suc h graphs [12] (meaning that one problem can be transformed in to the other in linear time): find a minimal collection o f cuts suc h that for an y pair of v ertices s and t , this collection con ta ins a minimum s - t cut. W e refer to this problem as the al l-p airs min cut pr oblem (APMCP). W e pro v e that quadratic running time for the tw o problems is optimal b y presen ting a f amily of graphs of arbitrarily larg e size for whic h the total length (n umber of edges) of all cycles in an y MCB is Θ( n 2 ). W e then presen t an algo rithm with O ( n 3 / 2 log n ) running time and O ( n 3 / 2 ) space requiremen t that computes an MCB of a planar graph imp licitly . F rom this result, w e get an output-sensitiv e algorithm with O ( n 3 / 2 log n + C ) time and O ( n 3 / 2 + C ) space requireme nt, where C is the to t al size of cycles in the MCB that the algorithm returns. F or un w eigh ted planar graphs, these b ounds simplify to O ( n 3 / 2 log n ) and O ( n 3 / 2 ), resp ectiv ely . Since the MCBP and the APMCP are dual equiv alent for planar g r a phs, w e get similar b o unds for the latter problem. The weight ve ctor of a w eigh ted gra ph G is a v ector con taining the weigh ts of cycles of an MCB in o r der of non-decreasing w eight. Finding suc h a v ector has applications in c hemistry and biology [3]. F rom our implicit represen ta- tion of an MCB, we obtain an O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space algorithm for finding the weigh t v ector of a planar graph. The b est previous b o und was O ( n 2 ), obtained b y applying the algor ithm in [1]. A Gomo ry-Hu tr e e , intro duced b y Gomory and Hu in 1961 [10], is a compact represen tation of minim um w eight cuts b etw ee n all pairs of v ertices of a graph. F o r ma lly , a Go mory-Hu tree of a w eigh ted connected graph G is a tree T with we ighted edges spanning the ve rtices of G suc h that: 1. for any pair of v ertices s and t , the weigh t of the minimum s - t cut is the same in G and in T , and 2. for each edge e in T , the w eigh t of e equals the w eigh t o f the cut in G , defined by the sets of v ertices corresp onding to the t wo connected comp onen ts in T \ { e } . Suc h a tree T is very useful for finding a minim um s - t cut in G since w e only need to consider the cuts of G enco ded b y the edges on the simple path b et w een s and t in T . G omory-Hu trees ha v e also b een applied to solv e the minim um k -cut problem [24]. 3 F or planar g raphs, quadratic time a nd space is the b est kno wn b ound for finding suc h a tree. The b ound can easily b e obtained with the a lg orithm in [1]. F r o m our MCB algorithm, w e o bt a in an algorithm that constructs a Gomory-Hu tree in only O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space. An imp ort a n t corollary o f the latter result is that with O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space for prepro cessing, a query for the w eigh t of a min cut (or max flo w) b et w een t w o giv en v ertices of a planar undirected graph with non-negativ e edge w eigh ts can b e answ ered in constant time. Previously , quadratic prepro cessing time a nd space was required t o obtain suc h a n oracle. The actual cut can b e rep orted in time prop ortio nal to its size. The organization of the pap er is as follows . In Section 2, w e give some definitions and notation and state some basic results. W e giv e the quadratic lo w er b o und fo r an explicit represen tation of an MCB of a planar graph in Section 3. In Section 4, w e men tion the g reedy a lgorithm whic h has been applied in previous pap ers to find a n MCB. Based on it, w e presen t our algorithm in Section 5 and b ound its time and space requiremen ts. The corollaries of our result are presen ted in Section 6. In order for our ideas to w ork, w e need shortest paths to b e unique. W e sho w ho w to ensure this in Section 7. Finally , w e g iv e some concluding remarks in Section 8. 2 Definiti o ns, Notation, and Basic Results In the following, G = ( V , E ) denotes an n -v ertex plane, straigh t- line em b ed- ded, undirected graph. This em b edding partitio ns the plane in to maximal op en connected sets whic h w e refer to a s the elementary fac es (of G ). Ex- actly o ne of the elemen tary faces is un b ounded and we call it the external elementary fac e (o f G ) . All ot her elemen tary faces are called internal . A Jo rdan curv e J pa r titions the plane in to a n op en b ounded set and an op en un b ounded set. W e denote them b y int ( J ) and ext ( J ) , resp ectiv ely . W e refer to the closure o f t hese sets as int ( J ) and ext ( J ) , resp ectiv ely . W e sa y that a pair of elemen tary faces of G are sep ar ate d by a simple cycle C in G if one face is con tained in int ( C ) and the other face is con tained in ext ( C ). A set of simple cycles o f G is called ne s te d if, for an y t w o distinct cycles C and C ′ in that set, either int ( C ) ⊂ int ( C ′ ), int ( C ′ ) ⊂ int ( C ), or int ( C ) ⊆ ext ( C ′ ). A simple cycle C is said to cr oss another simple cycle C ′ if { C , C ′ } is not nested. 4 C 2 ( a ) R ( C 4 , B ) R ( C 5 , B ) R ( C 1 , B ) R ( C 2 , B ) ( b ) R ( C 3 , B ) R ∞ ( B ) R ∞ ( B ) R ( C 1 , B ) R ( C 2 , B ) R ( C 5 , B ) R ( C 4 , B ) R ( C 3 , B ) C 3 C 1 C 5 C 4 Figure 1: (a): A nested set B of five cycles C 1 , C 2 , C 3 , C 4 , C 5 defining fiv e in ternal regions and an external region R ∞ ( B ) (white). (b): The region tree T ( B ) of B . F or cycles C and C ′ in a nested set B , w e sa y that C is a child of C ′ and C ′ is the p ar ent of C (w.r.t. B ) if int ( C ) ⊂ i n t ( C ′ ). W e also define a ncestors and descendan ts in the o bvious wa y . W e can represen t these relationships in a forest where eac h tree v ertex corresp onds to a cycle of B . F or an y cycle C ∈ B , we define interna l r e gio n R ( C , B ) as the subset int ( C ) \ ( ∪ i =1 ,...,k int ( C i )) o f the plane, where C 1 , . . . , C k are the children (if an y) of C , see Figure 1 (a). The e x ternal r e gion R ∞ ( B ) is defined as the set R 2 \ ( ∪ i =1 ,...,k int ( C i )), where C 1 , . . . , C k are the cycles asso ciated with ro ots of trees in the forest defined ab o v e. Collectiv ely , w e refer to the internal regions and the external region as r e gions . With C 1 , . . . , C k defined as a b o v e for a region R (in ternal or external), w e refer to the in ternal regions R ( C i , B ) as the childr en of R and w e call R the p ar ent o f these regions. Again, w e can define a ncestors and descendan ts in the obv ious w ay . Note that the external region is the ancestor of all other regions. W e can th us represen t the relationships in a tr ee where each ve rtex corresp onds to a regio n. W e call it the r e gion tr e e o f B and de note it b y T ( B ), see Fig ure 1(b). Note that fo r tw o cycles C and C ′ in B , C is a c hild of C ′ if and only if R ( C , B ) is a c hild of R ( C ′ , B ). Hence, the region tree T ( B ) also describ es the paren t/child relationships b et we en cycles of B . The elemen tary faces of G b elonging to a region R are the elemen tary fac es of R . F or eac h c hild C i of R , int ( C i ) is called a non-ele m entary fac e of R . If R is an in ternal region R ( C , B ), the e x ternal fac e of R is the subset 5 ext ( C ) of the plane and we classify it as a non-elemen tary face of R . Col- lectiv ely , w e refer to the elemen tary and non-elemen tary faces of R as its fac es . A cycle C in G is said to b e isometric if for an y tw o v ertices u, v ∈ C , there is a shortest pa th b etw ee n u and v con tained in C . A set of cycles is said to b e isometric if all cycles in the set are isometric. The dual G ∗ of G is the m ultigraph ha ving a ve rtex for each elemen tary face of G and ha ving an edge e ∗ b et w een t wo dual v ertices for ev ery edge e of G shared by the elemen tary faces corresp onding t o the tw o dua l v ertices. The w eigh t of e ∗ in G ∗ is equal to the w eigh t of e in G . W e iden tify elemen tary faces of G with v ertices of G ∗ and since there is a one-to-one corresp ondence b et w een edges of G and edges of G ∗ , w e iden tify an edge of G with the corresp onding edge in G ∗ . Assume in the following that G is connected. Giv en a v ertex u ∈ V , w e let T ( u ) denote a shortest path tree in G with source u . The dual of T ( u ) is the subgraph o f G ∗ defined b y the edges not in T ( u ). It is w ell-kno wn that this subgraph is a spanning tree in G ∗ and w e denote it b y ˜ T ( u ). The follo wing lemma will pro ve useful. Lemma 1. Assume that for any two vertic es in G , ther e is a uniq ue shortest p ath b etwe en them in G . L et C b e an isometric cycle in G and let u ∈ V . If u ∈ ext ( C ) r esp. u ∈ int ( C ) then the elemen tary fac es of G in i n t ( C ) r esp. in ext ( C ) ar e sp anne d by a subtr e e of ˜ T ( u ) . If u ∈ ext ( C ) ∩ int ( C ) , i.e., u ∈ C , then these two subtr e es ar e obtaine d by r emoving the single e dge of ˜ T ( u ) havin g one end vertex in int ( C ) and one end v ertex in e x t ( C ) . Pr o of. Supp ose that u ∈ ext ( C ), see Fig ure 2. The subgraph of shortest path tree T ( u ) con tained in int ( C ) is a f o rest. Since C is isometric and since shortest paths a re unique, each tree in this forest con tains exactly one v ertex of C . This implies that the edges of G b elonging to int ( C ) and not to this forest define a connected comp onen t in the dual o f G . Since all these edges b elong to ˜ T ( u ), it follows that the elemen tary faces of G in int ( C ) are spanned b y a subtree of ˜ T ( u ), as desired. A similar argumen t shows tha t if u ∈ int ( C ) then the elemen tary faces of G in ext ( C ) are spanned by a subtree of ˜ T ( u ). Finally , assume that u ∈ C . There is at least one edge in ˜ T ( u ) with one end verte x in int ( C ) and one end v ertex in ext ( C ) since otherwise, ˜ T ( u ) w ould b e disconnected. There cannot b e more than one suc h edge since that w ould contradict the first part of the lemma. This sho ws the second pa r t . 6 u C T ( u ) ˜ T ( u ) Figure 2: If u ∈ ext ( C ) then t he subgraph of ˜ T ( u ) in int ( C ) is a tree. A Horton cycle of G is a cycle obtained by adding a single edge e to a shortest path tree in G ro oted at some v ertex r . W e den ot e this cycle b y C ( r, e ). F or a subset V ′ of V , w e let H ( V ′ ) denote the set o f Horto n cycles of G obtained from shortest pa t h trees ro o ted at ve rtices of V ′ . F or an y g raph H , w e let V H and E H denote its v ertex and edge set, resp ectiv ely . If w : E → R is a w eigh t function o n the edges of G , w e say that a subgraph H of G has weight W ∈ R if P e ∈ E H w ( e ) = W . 3 A Tig h t Lo w er Bou n d In this section, w e sho w that there are planar g raphs of arbitra r ily large size for which the tota l length of cycles in an y MCB is quadratic. T his implies that the algorithm in [1] is optimal since it runs in O ( n 2 ) time. The instance G n con taining n v ertices is defined as f o llo ws. Let v 1 , . . . , v n b e the v ertices of G n . F or i = 1 , . . . , n − 1, there is a n edge e i = ( v i , v i +1 ) of w eigh t 0. F or i = 1 , . . . , n − 2, there is an edge e ′ i = ( v 1 , v i +2 ) of w eight 1. Since G n has m = 2 n − 3 edges, any MC B o f G n consists of m − n + 1 = n − 2 cycles. In suc h a basis, ev ery cycle m ust con tain at least one of the edges e ′ i , i = 1 , . . . , n − 2. Hence, the cycles in any MCB of G n ha v e tot a l w eigh t at least n − 2. 7 1. initialize B = ∅ 2. for eac h simple cycle C of G in order of non-decreasing w eigh t, 3. if there is a pair of elemen tary faces of G separated by C and not by an y cycle in B , 4. add C to B 5. output B Figure 3: The generic greedy algor it hm to compute the G MCB of G . F or i = 1 , . . . , n − 2, let C i b e the cycle containing edges e 1 , . . . , e i +1 , e ′ i in that order. It is easy to see that the set of these cycles is a cycle basis of G . F urthermore, their to tal w eight is n − 2 so b y the ab ov e, they m ust constitute an MCB of G n . In fact, it is the unique MCB of G n since in any other cycle basis, some cycle m ust contain at least t w o weigh t 1 edges, implying that the total w eigh t is at least n − 1. The cycles in the unique MCB of G n clearly ha v e quadratic total length. This giv es the follow ing result. Theorem 1. Ther e ar e instanc es of p lanar gr aphs of arbitr arily lar ge size n for which the cycles in any MCB for such an instanc e have total len g th Ω( n 2 ) . In Section 5 , w e sho w ho w t o break the quadratic time b ound b y com- puting an implicit ra ther than an explicit represen tation of an MCB. 4 The Gree dy Algor i thm In the following, G = ( V , E ) denotes an n -v ertex plane, straigh t- line em b ed- ded, undirected graph with non- negativ e edge w eigh ts. W e may assume that G is connected since otherwise, w e can consider eac h connected comp onen t separately . W e require that there is a unique shortest path in G b etw een any t w o v ertices. In Section 7 , w e sho w ho w to av oid this restriction. The a lg orithm in Figure 3 will find an MCB o f G (see [12 , 19]). W e call this algorithm the generic gr e e dy alg orithm and w e call the MCB obtained this w ay a gr e e dy MCB (G MCB) (of G ). W e assume tha t ties in the ordering in line 2 are resolv ed in some deterministic w ay so that w e ma y refer to the cycle basis output in line 5 as the GMCB o f G . The f o llo wing t w o results are from [12]. 8 Lemma 2. The GMCB is isometric an d neste d and c onsists of Horton cycles. Lemma 3. F or every p air o f elementary fac es of a plane undir e cte d gr aph H with non-ne gative e dge weights, the GMCB o f H c ontains a minimum-w e i g ht cycle C in H that sep ar a tes those two fac es. Cycle C is the first such cycle c onsider e d when applying the generic gr e e d y a lgorithm to H . Our algorithm is essen tially the generic greedy alg o rithm except that w e consider a smaller family of cycles in line 2. The main difficult y in giving an efficien t implemen tation of the greedy algorithm is t esting t he conditio n in line 3. Describing how to do this constitutes the main part of the pap er. 5 Divide-and- Conquer A lgorithm The family of cycles that we pic k in line 2 o f the g eneric greedy algorithm is obtained with the divide-and-conquer paradigm. T o separate our problem, w e apply the cycle separator theorem of M iller [2 2] to G . This gives in linear time a Jordan curv e J in tersecting O ( √ n ) ve r- tices and no edges of G suc h that t he subgraph G 1 of G in int ( J ) and the subgraph G 2 of G in ext ( J ) eac h con tain at most 2 n/ 3 v ertices. W e let V J denote the set of ve rtices on J and refer to them a s b oundary vertic es of G . As in G , w e assume tha t shortest paths in G 1 and G 2 are unique. In Section 7, w e show ho w to av oid this assumption. F or i = 1 , 2 , let B i b e the GMCB o f G i . Let B ′ i b e the subset o f cycles of B i con taining no v ertices of V J . Lemma 4. With the ab ove definitions, B ′ 1 ∪ B ′ 2 ∪ H ( V J ) c ontains the GMCB of G . Pr o of. Let B b e the GMCB of G and let C b e a cycle of G not b elonging to B ′ 1 ∪ B ′ 2 ∪ H ( V J ). W e need to sho w t ha t C / ∈ B . By Lemma 2, we may a ssume that C is isometric. F urthermore, w e ma y assume t ha t it do es no t b elong to B 1 ∪ B 2 (since otherwise, it would b elong to B 1 ∪ B 2 \ ( B ′ 1 ∪ B ′ 2 ) and hence to H ( V J ) since it is isometric and since shortest paths are unique). Since C / ∈ H ( V J ), C do es not contain an y ve rtices of V J so it b elongs to G i , where i ∈ { 1 , 2 } . In pa rticular, it is considered b y the generic greedy algorithm in t he construction of B i . Since C / ∈ B i , Lemma 3 implies that ev ery pair of elemen tary faces ( f 1 , f 2 ) of G i , where f 1 ⊆ int ( C ) and f 2 ⊆ ext ( C ), m ust b e separated b y some cycle 9 of B i ha ving smaller we ight than C (or a cycle hav ing the same weigh t as C but considered earlier in the generic greedy algorit hm). W e claim that this statemen t also ho lds when replacing B i b y B and G i b y G . If w e can sho w this, it will imply that C is not added to B b y the generic greedy algor it hm. So let ( f 1 , f 2 ) b e a pair of elemen tary faces o f G with f 1 ⊆ int ( C ) and f 2 ⊆ ext ( C ). Either f 1 or f 2 is an elemen tary f ace of G i since either J ⊂ ext ( C ) or J ⊂ int ( C ). Assume w.l.o.g. that f 1 is an elemen tary face of G i . If f 2 is also an elemen tary face of G i b elonging to the same connected comp onen t K of G i as f 1 , the ab ov e implies that f 1 and f 2 are separated by some cycle C ′ ∈ B i ha ving smaller w eigh t than C . Since C ′ is also considered b y the generic greedy algorithm when constructing B , it fo llows that f 1 and f 2 are separated by a cycle in B ha ving w eigh t smaller than that o f C , as desired. Con v ersely , if f 2 is not an elemen tary face of G i b elonging to K , f 2 m ust b e con tained in t he external elemen tary fa ce f K of K . By Lemma 3, there is a cycle of B i whic h is shorter than C and whic h separates f 1 and f K . This cycle also separates f 1 and f 2 and it follo ws that f 1 and f 2 are separated b y a cycle in B having weigh t smaller that that of C . The ab ov e shows t ha t C / ∈ B , completing the pro of o f t he lemma. Lemma 4 suggests t he following divide-and-conquer algorithm for our problem: recu rsive ly compute GMCB’s B 1 and B 2 of G 1 and G 2 , compute H ( V J ), and extract f r om B ′ 1 ∪ B ′ 2 ∪ H ( V J ) the GMCB of G by applying the generic greedy algorithm to this smaller set of cycles. Pseudo co de of this algorithm is shown in Figure 4 (it is a ssumed that a brute-force algor it hm is applied to find the GMCB of G when G has constan t size). W e call it the r e cursive gr e e dy algorithm . W e will show ho w to implemen t the top-lev el of the recursion in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space. Since eac h step of the recursion par t it ions the g raph in to t w o subgraphs of (almost) the same size [22], it will follo w that these b ounds hold for the entire algorithm. Since the algo rithm constructs the GMCB, B is isometric and nested at all times. Thus, B represen ts a set of regions t hat change during the course of the algorithm. More sp ecifically , when t he algorithm starts, B = ∅ and there is only one region, namely the external region R ∞ ( B ). Whenev er a cycle C is added to B in line 5, the region R con taining C is replaced by tw o new regions, one, R 1 , con tained in int ( C ) and one, R 2 , con tained in ext ( C ). W e sa y that C splits R in to R 1 and R 2 . W e call R 1 the internal r e gion and 10 1. recursiv ely compute GMCB’s B 1 and B 2 of G 1 and G 2 , respective ly 2. initialize B = ∅ 3. for eac h cycle C ∈ B ′ 1 ∪ B ′ 2 ∪ H ( V J ) in order of non-decreasing w eigh t, 4. if there is a pair of elemen tary faces of G separated by C and not by an y cycle in B , 5. add C to B 6. output B Figure 4 : The recursiv e greedy algorit hm to compute the GMCB of G . F or i = 1 , 2, B ′ i is the set of cycles of B i not con taining a n y ve rtices of H ( V J ). R 2 the external r e g ion (w.r.t. R and C ). Figure 5 give s an illustration. The follow ing lemma relates the test in line 4 to the tw o regions generated b y the split. Lemma 5. The c ondition in line 4 in the r e cursive g r e e dy algo ri thm is sat- isfie d if and only if C splits a r e gion into two e ach of wh ich c ontains at le ast one elementary fac e. Pr o of. Let R b e the region con taining C and supp ose tha t C splits R into R 1 and R 2 . Consider t wo elemen tary faces of G separated by C . No cycle of B sepa- rates them if and only if the tw o faces b elong to the same regio n. Henc e, the condition in line 4 is satisfied if and only if C separates a pa ir o f elemen tary faces both b elonging to R . The latter is equiv alen t to the condition that there is an elemen tary face in R 1 and an elemen tary face in R 2 . 5.1 Con tracted and Pruned Dual T rees Lemma 5 sho ws that if w e can k eep track of the nu mber o f elemen tary faces of G in regions during the course of the a lgorithm, then testing the condition in line 4 is easy : it holds if and only if the n umber o f elemen tary faces of G in each of the tw o regions obta ined by inserting C is at least one. In the follo wing, we intro duce so called contracted dual trees and pruned dual trees that will help us kee p t rac k of the necessary information. First, we need the follo wing lemma. 11 C R R C R 1 C R 2 Figure 5: Adding a cycle C to B splits a region R in to internal region R 1 and external region R 2 . Lemma 6. L et H b e a pla n e gr aph with non - ne gative e dge weights and as- sume that sh ortest p aths in H ar e unique. L et C b e an isom e tric cycle in H and let P b e a s h ortest p ath in H b etwe en ve rtic es u and v . If b oth u an d v b elong to int ( C ) then P is c ontaine d in int ( C ) . If b oth u and v b el o ng to ext ( C ) then P is c ontaine d i n ext ( C ) . Pr o of. Supp ose that u , v ∈ i n t ( C ) and assume for the sak e of contradiction that P is not con tained in int ( C ). Then there is a subpath P ′ of P b etw een a v ertex u ′ ∈ C and a v ertex v ′ ∈ C with all in terior v ertices b elonging to ext ( C ). Since C is isometric, there is a shortest path P ′′ con tained in C b et w een u ′ and v ′ . But P ′ is a lso a shortest path b et w een u ′ and v ′ . Since P ′ 6 = P ′′ , this con tradicts the uniqueness of shortest paths in H . A similar pro of ho lds when u, v ∈ ext ( C ). F or a region R and a b oundary v ertex v b elonging to R , the c ontr acte d dual tr e e ˜ T R ( v ) is the tree obta ined from dual tree ˜ T ( v ) by con tracting eac h edge ( u , u ′ ), where u and u ′ are elemen tary faces in G b oth contained in the same non-elemen tary f ace of R , see Figure 6. An import a n t observ atio n is that there is a one-to-one corresp ondence b et w een the ve rtices o f ˜ T R ( v ) and the faces of R . W e assign the colour white 12 v R v R ˜ T ( v ) ˜ T R ( v ) x Figure 6: Con tracted dual t r ee ˜ T R ( v ) is obta ined from ˜ T ( v ) by con tracting edges b et w een elemen tary faces b elonging to the same non-elemen tary face (b old edges and white interior) of R . F or this instance, applying the pruning pro cedure to obtain ˜ T ′ R ( v ) remov es x and its adjacen t edge in ˜ T R ( v ). resp. blac k to those v ertices of ˜ T R ( v ) corresp onding to elemen tary resp. non- elemen tary f a ces of R , see F igure 6. W e iden tify each edge in ˜ T R ( v ) with the corresp onding edge in ˜ T ( v ). T o ease the presen tation of our ideas, w e assume for no w that only cycles from H ( V J ) are encoun tered in line 3 of the recursiv e greedy algorithm. In Section 5.4, w e sho w how to handle cycles from B ′ 1 ∪ B ′ 2 as well. So consider some iteration of the algo rithm where a cycle C = C ( v , e ) ∈ H ( V J ) has just b een pic ke d in line 3 and a ssume that all cycles added to B so far a ll b elong to H ( V J ). Cycle C should b e added to B only if B ∪ { C } is nested. W e will now sho w ho w to detect whether this is t he case using the con tracted dual trees. If there is a region R con taining v suc h that ˜ T R ( v ) contains e then e ( in G ) b elongs to R (since otherwise, e w ould hav e b een con tracted in ˜ T R ( v )). Since eac h cycle in B is isometric and since shortest paths are unique, Lemma 6 implies that B ∪ { C } is nested. And the conv erse is a lso true: if B ∪ { C } is nested then there is a regio n R containing C . In particular, R contains e so this edge m ust b elong to ˜ T R ( v ). It follo ws that detecting whether B ∪ { C } is nested amo unts to chec king whether e is presen t in ˜ T R ( v ) for some region R . No w, assume t ha t B ∪ { C } is nested (otherwise, we can discard C ) and let us see ho w the con tracted dual trees can help us chec k the condition in 13 line 4 of the recursiv e greedy algor ithm. Define R to b e the region con taining C . Since e b elongs to R , t his edge b elongs to the contracted dual tree ˜ T R ( v ). Let v 1 and v 2 b e the end v ertices of e in ˜ T R ( v ). Remo ving e f r om ˜ T R ( v ) splits this tree in to t w o subtrees, one, ˜ T 1 , atta ched to v 1 and one, ˜ T 2 , atta ched to v 2 . By Lemma 5, the conditio n in line 4 is satisfied if and only if ˜ T 1 and ˜ T 2 eac h contain at least one white v ertex. Unfortunately , b oth of these t w o subtrees ma y con tain ma ny black ve r- tices so for p erformance reasons, a simple search in these trees to determine whether they con tain white v ertices is infeasible. W e therefore in tro duce prune d (c ontr acte d) dual tr e e ˜ T ′ R ( v ), defined as the subtree of ˜ T R ( v ) obtained by remo ving a blac k degree one vertex and rep eating this pro cedure on the resulting tree un til all degree one v ertices are white, see Figure 6. W e refer to this as the pruning pr o c e dur e . Lemma 7. With the ab ove definitions , e ∈ ˜ T ′ R ( v ) if and only if ˜ T 1 and ˜ T 2 b oth c ontain white vertic es. Pr o of. If ˜ T 1 con tains only black v ertices then the pruning pro cedure will remo v e all v ertices in ˜ T 1 . In particular, the pro cedure remo ve s v 1 . Similarly , if ˜ T 2 con tains only black v ertices then v 2 is remo v ed. In b oth cases, e is remo v ed so e / ∈ ˜ T ′ R ( v ). Con v ersely , if b oth ˜ T 1 and ˜ T 2 con tain white ve rtices then the pruning pro cedure do es not remov e all v ertices fro m ˜ T 1 and do es not remo ve all v ertices f r om ˜ T 2 . Hence , neither v 1 nor v 2 is remo v ed so e ∈ ˜ T ′ R ( v ). Lemma 7 show s that once ˜ T ′ R ( v ) is given , it is easy to determine whether b oth ˜ T 1 and ˜ T 2 con tain white v ertices and hence whether the condition in line 4 is satisfied: simply chec k whether e ∈ ˜ T ′ R ( v ). Note that if line 4 is satisfied, e ∈ ˜ T ′ R ( v ) a nd hence e ∈ ˜ T R ( v ). By the ab o ve, this implies that B ∪ { C } is nested. This sho ws that w e only need ˜ T ′ R ( v ) to test the conditio n in line 4. 5.2 Inserting a Cycle In the previous section, w e intro duced con tracted and pruned dual trees and sho w ed ho w the latter can b e used to test the condition in line 4 of the recursiv e greedy algor it hm fo r cycles in H ( V J ). In the following, w e show 14 v e e R 1 R 2 C = C ( v , e ) ˜ T R ( v ) R Figure 7: F aces of R b elong ing to R 1 resp. R 2 are iden tified b y visiting the subtree of con tracted dual tree ˜ T R ( v ) consisting of gray resp. white v ertices. ho w to main tain r egio ns and con tra cted and pruned dual trees when suc h cycles are added to B in line 5. Initially , B = ∅ so the con tracted a nd pruned dual trees are simply the dual t r ees ˜ T ( v ) for eac h b o undar y vertex v ∈ V J . And there is only one region, namely the external region R ∞ ( B ). No w, supp o se C = C ( v , e ) ∈ H ( V J ) has just b een inserted in to B in line 5, see F igure 7. Let R b e the region suc h that C splits R in to internal region R 1 and external region R 2 . W e need to iden tify the faces of R b elong ing to R 1 and t o R 2 . This can b e done with t w o searc hes in con tracted dual tree ˜ T R ( v ). One searc h starts in the end v ertex of e b elonging to int ( C ) and a v oids e (visiting the g ra y v ertices in Figure 7). The other searc h starts in the end v ertex of e b elonging to ext ( C ) and also a v oids e (visiting the white v ertices in Figure 7) . It follows from Lemm a 1 and from the defi nition of con tracted dual trees that the first searc h iden tifies the f a ces of R that should b elong to R 1 and the second searc h iden tifies those that should b elong to R 2 . W e also need to for m one new face for R 1 , namely t he face defined by ext ( C ). W e denote this face b y f R 1 . Similarly , we need to form a new face for R 2 , defined b y int ( C ), and w e denote this face by f R 2 . Next, w e up date contracted dual trees. The only ones aff ected are t ho se of the form ˜ T R ( u ), where u ∈ R . There are three cases t o consider: u ∈ int ( C ), u ∈ ext ( C ), and u ∈ C . Case 1 : Consider first a contracted dual t r ee ˜ T R ( u ) with u ∈ int ( C ). Then u ∈ R 1 so w e need to discard ˜ T R ( u ) and construct ˜ T R 1 ( u ). W e obtain the 15 latter from the former b y con tracting all edges of ˜ T R ( u ) ha ving b o th end v ertices in ext ( C ) to a single v ertex (this is p ossible b y Lemma 1). W e iden tify t his new v ertex with the new face f R 1 of R 1 . Case 2 : Now , assume that u ∈ ext ( C ). Then u ∈ R 2 so ˜ T R ( u ) should b e replaced b y ˜ T R 2 ( u ). W e do this b y con tra cting all edges of ˜ T R ( u ) ha ving b oth end v ertices in int ( C ) to a single v ertex (a g ain, w e make use o f Lemma 1) and w e identify this v ertex with the new face f R 2 of R 2 . Case 3 : Finally , assume that u ∈ C . No w, u b elongs to b oth R 1 and R 2 so w e need to discard ˜ T R ( u ) and construct ˜ T R 1 ( u ) and ˜ T R 2 ( u ). T o do this, w e first iden tify the edge e ′ in ˜ T R ( u ) hav ing one end v ertex u 1 in int ( C ) and one end v ertex u 2 in ext ( C ). Then w e construct the tw o trees T 1 and T 2 formed b y remo ving e ′ from ˜ T R ( u ) with u 1 ∈ T 1 and u 2 ∈ T 2 . W e let T ′ 1 b e T 1 augmen ted with the edge from u 1 to f R 1 and let T ′ 2 b e T 2 augmen ted with the edge from u 2 to f R 2 . It follows from Lemma 1 that T ′ 1 is the con tracted dual tree ˜ T R 1 ( u ) for R 1 and that T ′ 2 is the con tracted dual tree ˜ T R 2 ( u ) for R 2 . W e ha ve describ ed ho w to up date con tracted dual trees when C is added to B . W e apply the same metho d to up date pruned dual trees. The only difference is that the pruning pro cedure needs to be applied whene ve r a c hange is made to a pruned dual tree. 5.3 Implemen tation Ab o v e, w e ga v e an ov erall description o f the algorithm when only cycles of H ( V J ) are considered. W e now go in to more details a nd show ho w to g iv e an efficien t implemen tation of this algorithm. W e start b y describing the data structures that our algorithm mak es use of. The main ob jects in v olve d are regions, con tracted dua l trees, and pruned dual trees and w e consider them in the following. 5.3.1 Regions Asso ciated with a region R is a fac e list F ( R ) whic h is a link ed list con ta ining the faces of R . An en try of F ( R ) corresp onding to a face f is assigned the colour white resp. blac k if f is elemen tary resp. non-elemen tar y . If it is blac k, it has a bidirected p ointer to the c hild of R con tained in f . This gives 16 f A R ( f ) f u u ′ ˜ T ( v ) u u ′ Data struct u r e for edge ( u, u ′ ) v E u ′ ( ˜ T R ( v )) u u ′ Data struct u r e for regi on R V ( ˜ T R ( v )) E u ( ˜ T R ( v )) Data struct u r e for ˜ T R ( v ) F ( R ) Figure 8: Illustration of dat a structures a nd some of their asso ciated p ointers . a represen tation of the region tree T ( B ). If the en try is white, it p oin ts to the corresp onding elemen tary fa ce of G . The en try also p oints to the en tire data structure for R . Asso ciated with the f - en try of F ( R ) is also an arra y A R ( f ) with an en try for eac h b oundary v ertex in V J . The en try of A R ( f ) for a b oundary vertex v b elonging to R has a bidirected p ointer to v ertex f in con tracted dual t r ee ˜ T R ( v ), see Figure 8. It also has a bidirected p ointer to v ertex f in pruned dual tree ˜ T ′ R ( v ) if that v ertex has not b een deleted by the pruning pro cedure. All other en tries o f A R ( f ) p oin t to n ull. 5.3.2 Con tracted and pruned dual trees Asso ciated with a contracted dual tree ˜ T R ( v ) is a vertex list V ( ˜ T R ( v )) which is a link ed list with an entry fo r each ve rtex of ˜ T R ( v ). The entry fo r a vertex u p oin ts to the entry o f F ( R ) for the face of R corresp o nding to u . Associated with the u -entry of V ( ˜ T R ( v )) is a lso an e dge adjac ency list E u ( ˜ T R ( v )), a link ed list represen ting the edges a djacen t to u in ˜ T R ( v ). Eac h list entry con tains a p oin ter to the u -en try of vertex list V ( ˜ T R ( v )) (allo wing us to find the head of E u ( ˜ T R ( v )) in constan t time) as w ell as a bidirected p oin ter to an e dge data structur e . The edge data structure thu s con tains tw o p ointe rs, one for eac h of its end vertice s. F urthermore, it con tains a bidirected p ointer to the corresp onding edge in dual tree ˜ T ( v ), see Figure 8. W e keep a similar data structure for pruned dual tree ˜ T ′ R ( v ). Both da t a 17 structures need to supp o rt edge con tra ctio ns, edge insertions, and edge dele- tions and the data structure fo r ˜ T ′ R ( v ) also needs to supp ort the pruning pro cedure. W e describ e ho w to do this in the following. Edge con t r action: W e only describ e edge contractions for con tracted dual trees since pruned dual trees can b e dealt with in a similar w a y . Assume we ha v e a set E c of edges (or edge data structures) in ˜ T R ( v ) to b e con tracted to a single new v ertex v c and that these edges span a subtree of ˜ T R ( v ). W e assume that w e ha v e a p oin ter to the en try of F ( R ) corresp onding to v c . T o con tra ct an edge e ∈ E c , w e first remov e the p oin ter to the edge of dual tree ˜ T ( v ) correspo nding to e . T rav ersing the tw o p ointe rs associat ed with e , we find an en try in E u 1 ( ˜ T R ( v )) and an en try in E u 2 ( ˜ T R ( v )), where u 1 and u 2 are the end ve rtices of e in ˜ T R ( v ). W e r emov e those tw o entries in lists L 1 = E u 1 ( ˜ T R ( v )) and L 2 = E u 2 ( ˜ T R ( v )) and then merge L 1 and L 2 to one list L since the new ve rtex is adjacen t to edges adja cent to u 1 and u 2 except e . If L 1 is a pp ended to the tail o f L 2 , w e mak e ev ery entry in L 1 p oin t to the u 2 -en try in ve rtex list V ( ˜ T R ( v )). Otherwise, w e make ev ery entry in L 2 p oin t to the u 1 -en try in that list. F or p erformance reasons, w e app end the shorter of the t w o lists to the tail of the other. W e rep eat the ab o v e for each edge of E c and we end up with a single en try in V ( ˜ T R ( v )) represen ting the new v ertex v c . W e mak e this entry p oint to the entry o f F ( R ) corresp onding to v c and w e up date the p ointer to the v -entry in t he asso ciated array . Ho w long do es it take to con tract edges? W e will need the follow ing lemma in our analysis (the pro of can b e f o und in the app endix). Lemma 8. Consid e r a set of obje cts, e ach ass igne d a p ositive inte ger weight. L et m e r ge ( o, o ′ ) b e a n op er ation that r eplac es two obje cts o and o ′ by a new obje ct whose weight is the sum of the weights of o and o ′ . Assume that the time to exe cute mer ge ( o, o ′ ) is b ounde d by the s m al ler we i g ht of obje cts o and o ′ . Then r ep e ating the mer ge -op er ation on p airs of obj e cts in any or der until at most one obje ct r emains takes O ( W log W ) time wher e W is the total weight of the original obje cts. Fix a v ∈ V J and consider the set of contracted dual trees of the form ˜ T R ( v ) generated during the course of the algorithm. Eac h time a cycle from H ( V J ) is added to B , at most t wo new edges are inserted in to trees of t his 18 form (case 3 in Section 5.2). Henc e, there are O ( n ) edges in total. It then fol- lo ws easily from Lemma 8 and from the w ay we concatenate lists during edge con tractions that the tot a l time sp en t on edge contractions in all con tracted dual trees of the form ˜ T R ( v ) is O ( n log n ). Since the num ber of choice s of v is O ( √ n ), w e get a b ound of O ( n 3 / 2 log n ) time for all edge con tra ctio ns p erformed b y the algorithm. Edge deletion: W e also describe this only fo r con tracted dual trees. So supp ose we ar e to delete an edge e = ( u 1 , u 2 ) fr om ˜ T R ( v ). W e need to for m t w o new trees, T 1 and T 2 . Let T 1 b e the tree con taining u 1 and let T 2 b e the tree con taining u 2 . F or i = 1 , 2, a simple searc h (say , depth-first) in ˜ T R ( v ) starting in u i and a voiding e finds the vertice s of T i in time prop ortiona l to the size of this tree. By alternating b et w een these t wo searc hes (i.e., essen tially p erforming them in parallel), we can find the vertice s of the smaller of the t w o trees in time prop ortional to the size of that tree. Supp ose that, sa y , T 1 is the smaller tree. Then w e can form the tw o data structures for T 1 and T 2 in time prop ortional to t he size of T 1 : extract the en tries of vertex list V ( ˜ T R ( v )) that should b elong to T 1 and form a new v ertex list containing these en tries. The old data structure for ˜ T R ( v ) now b ecomes the new dat a structure for T 2 after the en tries hav e b een remov ed. W e also need to remo v e the p ointer b et we en e and the corresp onding edge in dua l tree ˜ T ( v ) and remo v e e from the edge adjacency lists but this can b e do ne in constan t t ime. The fo llo wing lemma, whic h is similar to Lemma 8, immediately implies that the total time for edge deletions is O ( n 3 / 2 log n ) (the pro of of the lemma is in the app endix). Lemma 9. Consider an obje ct o w i th a p ositive in te ger weight W . L et split b e an op er ation that splits an obje ct of weight at le ast two into two new obje cts of p ositive inte ger weights such that the sum of weights of the two e quals the weight of the orig i n al obje ct. Assume that split runs in time pr op ortional to the smal ler weight of the two ne w o bje cts. Th en r ep e ating the split -op er ation in a ny or der, starting with obj e ct o , takes O ( W log W ) time. Edge insertion: The only situation where edge insertions are needed is in case 3 of Section 5.2. With our data structure, this can clearly b e done in constan t time p er insertion. 19 Pruning pro cedure: Finally , let us describ e how to implemen t t he prun- ing pro cedure for pruned dual tr ees. Recall that this pro cedure rep eatedly remo v es blac k degree one v ertices until no suc h vertice s exist. W e only need to apply the pruning pro cedure after an edge contraction and after an edge dele tion (edge insertions are not needed in pruned dual trees since these edges will b e remov ed b y the pruning pro cedure). Let us only consider edge deletions since edge con tractions are similar. Consider a pruned dual tree ˜ T ′ R ( v ) and sup p o se the algorithm remo ves an edge e = ( u 1 , u 2 ) from this tree. This forms t w o new trees T 1 and T 2 , con taining u 1 and u 2 , resp ectiv ely . In T 1 , o nly u 1 can b e a black degree one v ertex since in ˜ T ′ R ( v ), no v ertices ha d this prop ert y . Chec king whether u 1 should b e remo v ed tak es constan t time. If it is remov ed, w e rep eat the pro cedure o n the vertex that w as adjacen t to u 1 . W e apply the same strategy in T 2 , starting in u 2 . The t o tal time spent in the pruning pro cedure is pro p ortional to the n um b er of v ertices remo v ed. Since the num ber of vertice s only decreases a nd since the initial n um b er of v ertices in a ll pruned dual trees is O ( n 3 / 2 ), the total time sp en t b y the pruning pro cedure is O ( n 3 / 2 ). 5.3.3 The algorithm Ha ving described the data structures inv olv ed and ho w they can supp ort the basic op eratio ns that w e need, let us sho w how to give an effi cien t imple- men tation of our algorithm. Still, we o nly consider cycles from H ( V J ) in the for-lo o p. Initialization: First, w e consider the initia lizat io n step. Applying t he sep- arator theorem of Miller g iv es us J and V J in linear time. F o r each b oundar y v ertex v , w e need to compute shortest path t r ee T ( v ) a nd shortest path dis- tances from v in G . This can b e done in O ( n log n ) time with Dijkstra’s algorithm for a to t a l of O ( n 3 / 2 log n ) time (in fact, a shortest path tree can b e computed in linear time [13] but this will not impro ve the ov erall r unning time of our algorithm). W e also need to compute dual t r ees ˜ T ( v ) a nd this can easily b e done in O ( n 3 / 2 ) additional time. These dual trees are also t he initial contracted and pruned dual trees. Since w e need all three types of trees during the course of the alg orithm, three copies of eac h dual tree are initialized. 20 The algorithm then recursiv ely computes B 1 and B 2 . It is assumed that the recursiv e calls also return the weigh ts of cycles in these sets. Our algorithm needs to extract B ′ 1 and B ′ 2 from these sets. This is done as follo ws. F o r ev ery shortest path tree T ( v ) that has b een computed in recursiv e calls (w e assume that these trees are k ept in memory), w e mark v ertices of T ( v ) b elong ing to V J . Then w e mark all descendan ts of thes e v ertices in T ( v ) as w ell. Now , a Horton cycle C ( v , e ) obtained b y adding e to T ( v ) contains a v ertex of V J if and only if at least one o f the end v ertices of e is mark ed. Since the total size of all recursiv ely computed shortest path trees is b ounded b y the tot a l space requiremen t whic h is O ( n 3 / 2 ), it follows that B ′ 1 and B ′ 2 can b e extracted from B 1 and B 2 in O ( n 3 / 2 ) time. The cycles in B ′ 1 ∪ B ′ 2 ∪ H ( V J ) need to b e sorted in o r der of non-decreasing w eigh t. W e are given the w eigh ts of cycles in B ′ 1 ∪ B ′ 2 from the recursiv e calls and w e can compute the w eights of cycles in H ( V J ) in a total of O ( n 3 / 2 ) time using the shortest path distances computed ab ov e. Hen ce, sorting the cycles in B ′ 1 ∪ B ′ 2 ∪ H ( V J ) can b e done in O ( n 3 / 2 log n ) time. T esting condition in line 4 : Next, w e consider the fo r-lo op of the a lgo- rithm for some cycle C = C ( v , e ) ∈ H ( V J ). As w e sa w in Section 5.1, testing the condition in line 4 amoun ts to testing whether dual edge e in ˜ T ( v ) is presen t in some pruned dual tree. Recall tha t we k eep p o in ters b et we en edges of dual trees a nd pruned dual trees. Since w e remo v e a bidirected p oin ter b et w een an edge data structure and the corresp onding edge in a dual tree whenev er it is con tracted or deleted in a pruned dual tr ee, we can th us execute line 4 in constant time. Inserting a cycle: Line 5 requires more w ork and w e deal with it in the follo wing. Supp ose w e are ab out to add the a b o v e cycle C to B in line 5. With the p ointer asso ciated with e , w e find t he corresp onding edge data structure in a contracted dual tree ˜ T R ( v ). T rav ersing p oin ters from this data structure, w e find the data structure for R in constan t time. This region should b e split in to t wo new regio ns R 1 and R 2 , where R 1 is the inte rnal and R 2 the external region w.r.t. R and C . W e need to identify the b oundary v ertices a nd the o f f aces in R that b elong to R 1 and R 2 , respective ly . Iden tifying b oundary vertices in R 1 and R 2 : W e first iden tify t he set δ ( R ) of b oundary v ertices of V J b elonging to R b y tra vers ing an y one of 21 the array s A R ( f ) asso ciated with an entry of F ( R ) and pic king the v ertices not ha ving null-pointers. This ta kes O ( √ n ) time. Since the t o tal num ber of times w e add a cycle to B is O ( n ), total time for this during the course o f the algorithm is O ( n 3 / 2 ). W e will extract three subsets fro m δ ( R ): t he subset δ int ( R, C ) of v ertices b elonging to int ( C ), the subset δ ext ( R, C ) b elonging to ex t ( C ), a nd the subset δ ( R , C ) b elonging to C . If we can find these three subsets, we also obta in sets δ ( R 1 ) and δ ( R 2 ) of b oundary ve rtices for R 1 and R 2 , respectiv ely , since δ ( R 1 ) = δ ( R, C ) ∪ δ int ( R, C ) and δ ( R 2 ) = δ ( R, C ) ∪ δ ext ( R, C ). The following lemma b ounds the time to find the three subsets. The pro of is somewhat long and can b e found in the app endix. Lemma 10. With the ab ove definitions, we c an find in O ( √ n ) time the sets δ int ( R, C ) , δ ext ( R, C ) , and δ ( R, C ) with O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) sp ac e for p r epr o c e s sing. Lemma 10 implies that the tota l time sp en t on computing sets of b ound- ary v ertices ov er all regions generated b y the algorithm is O ( n 3 / 2 ) (plus O ( n 3 / 2 log n ) time for prepro cessing). Iden tifying faces of R 1 and R 2 : Ha ving found the b oundary v ertices b elonging to R 1 and R 2 , w e next fo cus on the problem of iden tifying the faces of R b elong ing to eac h of the t w o new regions. As prev iously o bserv ed (see F ig ure 7), w e can identify t he f aces of R 1 resp. R 2 with, say , a depth-first searc h in ˜ T R ( v ) starting in the end vertex of e b elonging to int ( C ) resp. ext ( C ) and av oiding e . W e use t he edge adj a cency lists t o do this. By alternating b et w een the t w o searc hes, w e can iden tify the smaller set of faces in t ime prop ortional to the size of this set. Let us assume that in ternal region R 1 con tains this smaller set (the case where external region R 2 con tains the set is similar). The searc h in ˜ T R ( v ) visited the en tries of V ( ˜ T R ( v )) corresp onding to faces in R 1 . Since each suc h en try p oints to the corresp onding en try in F ( R ) , w e can th us iden tify the faces in this face list tha t should b elong to F ( R 1 ). W e can extract these f a ces in time prop ortio na l to their num b er and thus form the face lists F ( R 1 ) and F ( R 2 ) in this amount of time. By reusing the arra ys asso ciated with entries of F ( R ), w e do not need to fo r m new arrays for F ( R 1 ) and F ( R 2 ). How ev er, w e need to set the p o in ters of some en tries o f 22 these arrays to n ull. F o r R 1 , the new null-po inters are those corresp o nding t o b oundary ve rtices of δ ext ( R, C ) since these are the b oundary v ertices of R not b elonging to R 1 . And for R 2 , the new null-pointers are tho se corresp onding to b oundary v ertices of δ int ( R, C ). Since w e index the ar r a ys by b o undary v ertices, we can iden tify p ointe rs to b e set to n ull in constant time p er p ointer. Poin ters tha t are set to n ull remain in this state so w e can c harge this part of the algorithm’s time to the total n umber of p oin ters whic h is O ( n 3 / 2 ). W e also need to asso ciate a new face with the data structure for R 1 and for R 2 (i.e., faces f R 1 and f R 2 in Section 5.2). And w e need to initialize an arra y for each of these tw o faces. This tak es O ( √ n ) time whic h is O ( n 3 / 2 ) o v er a ll regions. Con tracted and pruned dual t r ees for R 1 and R 2 : What remains is to construct contracted and pruned dual trees for R 1 and R 2 . Due to symmetry , w e shall only consider contracted dual trees. W e hav e already giv en an o v erall description of how to do t his in Section 5.2. As w e sho w ed, 1. for eac h u ∈ δ int ( R, C ), w e obtain ˜ T R 1 ( u ) fro m ˜ T R ( u ) by con tracting all edges b elonging to ext ( C ), 2. for eac h u ∈ δ ext ( R, C ), w e obtain ˜ T R 2 ( u ) fro m ˜ T R ( u ) b y con tracting all edges b elonging to int ( C ), and 3. for eac h u ∈ δ ( C ), we obtain ˜ T R 1 ( u ) and ˜ T R 2 ( u ) from ˜ T R ( u ) b y remov ing the unique edge in ˜ T R ( u ) hav ing one end v ertex in int ( C ) and one end v ertex in ext ( C ). In Section 5.3.2, w e described ho w to supp ort edge con traction, edge deletion, and edge insertion suc h that the total time is O ( n 3 / 2 log n ). The only detail missing is how to efficien tly find the edges to b e con tracted or remo v ed in the three cases ab ov e. W e consider these cases separately in the follow ing. Case 1: Assume tha t δ int ( R, C ) 6 = ∅ and let u ∈ δ int ( R, C ). With a depth-fir st search in ˜ T R ( v ) as describ ed ab ov e, w e can iden tify all faces of R b elonging to ext ( C ) in time prop ortio nal to the n um b er of suc h faces. W e can c harge t his time to the num ber of edges in ˜ T R ( u ) that are to b e con tracted. 23 F or eac h suc h face f , w e can mark the corresp onding ve rtex in ˜ T R ( u ) b y tra ve rsing the p oin ter a ssociat ed with en try u of arr ay A R ( f ). Again, w e can c harge the time for this to the num b er of edges to b e contracted. No w, w e need to con tract all edges of ˜ T R ( u ) whose end v ertices are b oth mark ed. In or der t o do this efficien tly , w e need to make a small mo dification to the con tracted dual tree data structure in Section 5.3.2. More precisely , w e make the con tracted dual trees ro oted at some v ertex. The c hoice of roo t is not imp o rtan t and ma y c hange during the course of the algorithm. What is imp ortant is that eac h non-ro ot vertex now ha s a paren t. By chec king, fo r each marked non- ro ot v ertex whether its paren t is also mark ed, we can identify the edges t o b e contracted in time pro p ortional to the n um b er of suc h edges. Of course this only w orks if the parent of a v ertex can b e obtained in constan t time. Let us show how the con tra cted dual tree data structure can b e adapted to supp ort this. Recall that eac h v ertex of a con tracted dua l tree ˜ T R ( v ) is asso ciated with an edge-adjacency list E u ( ˜ T R ( v )) con taining the edges adja cen t to u in ˜ T R ( v ). W e no w r equire the edge from v to its paren t (if defined) to b e the lo cated at the first en try of this list. This allows us to find paren ts in constan t time. Ho w do we ensure that the parent edge is alwa ys lo cated at the head of the list? This is not difficult aft er an edge insertion or deletion so let us fo cus on edge con tractions. When a n edge e = ( u 1 , u 2 ) is con tracted, either u 1 is the parent of u 2 or u 2 is the parent of u 1 . Assume, say , the former. Th en the paren t of u 1 b ecomes the paren t of the new v ertex obtained b y contracting e . When the tw o edge adjacency lists are merged, one of the tw o heads of the t wo old lists should thus b e the head of t he new list. This can easily b e done in constan t time. Case 2: This case is similar to case 1. Case 3: W e need an efficien t w a y o f finding the unique edge e in ˜ T R ( u ) ha ving one end v ertex in int ( C ) and o ne end v ertex in ext ( C ). W e do as follo ws: first w e mark the en tries in F ( R ) correspo nding to the set of faces of R b elonging to int ( C ) or the set of faces of R b elonging to ext ( C ). The set we c ho o se to mark is the smaller of the tw o. W e do this with “parallel” searc hes in ˜ T R ( v ) as describ ed ab ov e, using time prop ortional to the num b er of mark ed faces. W e mark the corres p o nding v ertices of ˜ T R ( u ) (using p ointers from the 24 arra ys asso ciated with en tries of F ( R )). By Lemma 1, these fo rm a subtree of ˜ T R ( u ) so w e can find e b y starting a searc h in an y marked ve rtex of ˜ T R ( u ) and stopping once w e encoun ter a v ertex whic h is not mark ed. Then e is the last edge encountere d in the searc h. This searc h also ta kes time prop ort io nal to the n umber of mark ed faces. Hence, constructing the contracted and pruned dual trees for R 1 and R 2 tak es time prop ortional to the n um b er of mark ed faces. Lemma 9 then implies t ha t the total time fo r this during the course of the a lgorithm is O ( n 3 / 2 log n ). Ha ving constructed the contracted a nd pruned dual trees fo r R 1 and R 2 , what remains befo re adding C to B is to add bidirected pointers b etw een en tries of the arra y asso ciated with the new face in F ( R 1 ) resp. F ( R 2 ) and the new ve rtex in the con tracted/pruned dual tree for R 1 resp. R 2 . Since the size of the arra y is O ( √ n ), this can clearly b e done in a total of O ( n 3 / 2 ) time. This concludes the description of the implemen tation of our algorithm. W e hav e sho wn that it runs in O ( n 3 / 2 log n ) time and requires O ( n 3 / 2 ) space. 5.4 Recursiv ely Computed Cycles So far, w e ha v e assumed that only cycles from H ( V J ) are encounte red in line 3 of the recursiv e g reedy algorithm. No w, w e sho w how to deal with cycles from B ′ 1 ∪ B ′ 2 . In the follo wing, w e only consider B ′ 1 since dealing with B ′ 2 is symmetric. The ov erall idea is the following. When a cycle C ∈ H ( V J ) is added to B , all cycles of B ′ 1 that cross C are marke d. If in the for-lo op, a cycle C ∈ B ′ 1 is pic k ed, it is skipped if it is ma r k ed since the GMCB is nested b y Lemma 2. Otherwise, C m ust b e fully con tained in some region of the form R ( C ′ , B ), C ′ ∈ B . Th en C is added to B if and only if C separates a pair of elemen tary faces of R ( C ′ , B ). W e will assume t hat the recursiv e in v o cation of the algorithm in G 1 re- turns region tree T ( B 1 ) in addition to B 1 . By applying Lemma 3, w e see t hat ev ery pair of elemen tary faces o f G 1 is separated b y some cycle of B 1 . Hence, each region asso ciated with a v ertex u of T ( B 1 ) contains exactly one elemen tary face of G 1 and we assume that the recursiv e call has asso ciated this f a ce with u . W e let R ( f , B 1 ) denote the region con taining elemen tary f a ce f . 25 f 2 e C ′ C ′′ ( b ) v J f J C = C ( v , e ) e f 1 f 2 C ′ C ′′ C ′′′ v f J J C = C ( v , e ) f 1 ( a ) Figure 9 : (a ) : Neither R ( C ′ , B 1 ), R ( C ′′ , B 1 ), nor R ( C ′′′ , B 1 ) a r e ancestors of R ( f J , B 1 ) and only R ( C ′ , B 1 ) and R ( C ′′ , B 1 ) are ancestors of b o th R ( f 1 , B 1 ) and R ( f 2 , B 1 ). Th us, C crosses C ′ and C ′′ and not C ′′′ . (b): Both R ( C ′ , B 1 ) and R ( C ′′ , B 1 ) are a ncestors of R ( f J , B 1 ) and o nly R ( C ′ , B 1 ) is an ancestor of neither R ( f 1 , B 1 ) nor R ( f 2 , B 1 ). Th us, C crosses C ′ and not C ′′ . W e use the conditions in t he fo llo wing lemma to identify those cycles o f B ′ 1 that should b e ma r ked whenev er a cycle of H ( V J ) is added to B . Lemma 11. L et C = C ( v , e ) ∈ H ( V J ) . If e do es not b elong to G 1 then C do es not cr oss any cycle of B ′ 1 . Otherwise, let f 1 and f 2 b e the elementary fac es of G 1 adjac ent to e a nd let f J b e the elementary fac e of G 1 c ontaining J . Then the set of cycles C ′ ∈ B ′ 1 that C cr osses ar e pr e cisely those which satisfy one of the fol lowing two c onditions: 1. R ( C ′ , B 1 ) is not an anc estor o f R ( f J , B 1 ) a nd is an anc estor of b oth R ( f 1 , B 1 ) and R ( f 2 , B 1 ) in T ( B 1 ) (Figur e 9(a )), 2. R ( C ′ , B 1 ) is an anc estor of R ( f J , B 1 ) and is an anc estor o f neither R ( f 1 , B 1 ) nor R ( f 2 , B 1 ) in T ( B 1 ) (Figur e 9(b )). The pro of can b e fo und in the app endix. The next lemma will simplify the test in line 4 of t he recurs ive greedy algorithm for C ∈ B ′ 1 . Again, the pro of is in the app endix. 26 Lemma 12. Supp ose that in the r e cursive gr e e dy algorithm, C ∈ B ′ 1 is the cycle curr ently c onside r e d and assume that it do es not cr oss any cycle of the p artial ly c onstructe d GMCB B of G . I f J ⊂ ext ( C ) then al l desc endants of C in r e g ion tr e e T ( B 1 ) b elong to the GMCB of G . If J ⊂ i n t ( C ) then a l l cycles of non-desc endants o f C in T ( B 1 ) b elong to the GMCB of G . No w, w e are r eady to describ e how the algorithm deals with cycles from B ′ 1 . Each cycle in this set is in one of three states: active , p assive , or cr oss state. Initially , all cycles in B ′ 1 are active . When a cycle from H ( V J ) is added to B , Lemma 11 is applied to iden tify all cycles from B ′ 1 that cross this cycle. These cycles hav e their state set to the cross state. When the algorithm encoun ters a cycle C ∈ B ′ 1 in t he for-lo op, C is skipped if it is in the cross state. If C is activ e, it is completely contained in some region R . There are tw o cases to consider: J ⊂ ext ( C ) and J ⊂ int ( C ). W e a ssume that J ⊂ ext ( C ) since the case J ⊂ int ( C ) is similar. W e need to determine whether C should b e added to B . By Lemma 5 , this amoun ts to chec king whether there are tw o elemen tary faces of R whic h are separated b y C . By L emma 12, we kno w that t he elemen tary faces of R b elonging t o int ( C ) ar e exactly the elemen tary faces of the region R ′ in int ( C ) that was generated when C w as added t o B 1 during the recursiv e call for G 1 . Hence, we a dd C to B if and only if the num ber of elemen tary faces in R is strictly larger than the n um b er of elemen tary faces in R ′ . If C is added to B , region R is split in to t w o smaller regions. Let R 1 b e the internal region and let R 2 b e the external regio n. Since J ⊂ ext ( C ), Lemma 12 implies that the cycles b elonging to int ( C ) that are added to B during the course of the algor it hm are exactly C and its descendan ts in T ( B 1 ). W e therefore do not need to main tain R 1 or an y regions con tained in int ( C ). Instead, w e mak e all descendan ts of C in T ( B 1 ) passiv e. When a passiv e cycle is encoun tered b y the alg o rithm, there is no need to up date regions or con tracted or pruned dual trees and the cycle is simply added t o B . No w, let us consider R 2 . In order to obtain this region, w e replace all faces of R b elong ing to int ( C ) with a single new face defined b y int ( C ). And w e con tract all edges in int ( C ) to a single blac k v ertex in all contracted and pruned dual trees fo r R . This completes the description o f the extension of our algorithm that 27 deals with cycles from B ′ 1 ∪ B ′ 2 . 5.4.1 Implemen tation Let us sho w how to give an efficien t implemen tation of the ab ov e algor it hm for cycles from B ′ 1 ∪ B ′ 2 . Due to symmetry , w e ma y restrict our atten tion to B ′ 1 in the following. Iden tifying cross st ate cycles: The first problem is to iden tify the cycles of B ′ 1 that should b e in the cross state when a cycle C = C ( v , e ) ∈ H ( V J ) is added to B . T o solve this problem, w e apply Lemma 11. Chec king whether e b elongs to G 1 tak es constan t time. If e is not an edge of G 1 then no new cycles will b e in the cross state. Otherw ise, we obtain elemen tary faces f 1 and f 2 in constan t time since these are the end vertice s of e in the dual of G 1 . W e assume that w e can compute low es t common a ncestors in T ( B 1 ) effi- cien tly . W e can use the data structure of Harel and T arjan [11 ] fo r this. Let a 1 b e the low es t common ancestor of R ( f 1 , B 1 ) and R ( f 2 , B 1 ) in T ( B 1 ), see Figure 10. Let a 2 b e the low est common ancestor o f R ( f 1 , B 1 ) and R ( f J , B 1 ). Let a 3 b e the lo w est common ancestor of R ( f 2 , B 1 ) and R ( f J , B 1 ). Finally , let P b e the path in T ( B 1 ) con taining R ( f J , B 1 ) and its ancestors. A cycle C ′ ∈ B ′ 1 satisfies the first condition in Lemma 11 if and only if it is not asso ciated with a ve rtex on P and if it is asso ciated with a 1 or an ancestor of a 1 (Figure 10(a)). And it satisfies the second condition if and only if it is asso ciated with a v ertex o n P and not with a 2 , a 3 , or an ancestor of either of these tw o v ertices (F ig ure 10(b)). T o iden tify cycles that satisfy the first conditio n, we start at a 1 and w alk up w ards in T ( B 1 ), marking cycles a s w e go along. The pro cess stops when a v ertex on P is reac hed. T o iden tify cy cles satisfying the second condition, w e instead mov e up- w ards in T ( B 1 ) along P , start ing in R ( f J , B 1 ). W e stop when the ro o t of T ( B 1 ) or when a 2 or a 3 is reac hed. Although this strat egy w orks, it is slo w since the same cycles may b e con- sidered sev eral t imes during the algorithm. T o remedy this, w e first o bserv e that when iden tifying cycles asso ciat ed with vertice s fro m a 1 to P , w e ma y stop if we encoun ter a cycle that is already in the cross state since then all its ancestors whic h are not on P mu st also b e in this stat e. 28 a 1 = a 2 R ( f J , B 1 ) R ( f 2 , B 1 ) ( b ) R ( f 1 , B 1 ) a 2 = a 3 R ( f J , B 1 ) a 1 R ( f 2 , B 1 ) ( a ) R ( f 1 , B 1 ) a 3 P P P P P Figure 1 0: ( a ): Cycles asso ciated with a 1 or an ancestor of a 1 and not with a vertex on P are exactly those that satisfy the first condition in Lemma 11. (b): Cycles asso ciated with a v ertex on P and not with a 2 , a 3 , or an an- cestor of either a 2 or a 3 are exactly t ho se satisfying the second condition in Lemma 11. Next, w e observ e that when iden tifying cycles asso ciated with vertices on P , w e alw ay s consider them fr om b otto m to top. Hence, by k eeping trac k of the b o ttommost b v ertex on P whose asso ciated cycle is not in the cro ss state, w e can start the next trav ers al of P from b . If the cycle asso ciated with a 2 or with a 3 is already in the cross state, we need not consider an y vertice s. Otherwise, we w alk up w ards in P from b , c hanging the state of cycles to the cross state and stop if a 2 or a 3 is reac hed. It follo ws that we can iden tify cycles satisfying one o f the tw o conditions and c hange their state in time prop ort io nal to the n um b er of cycles whose state c hanges as a result of this. Hence , the to t a l t ime f o r this is b ounded b y the size o f T ( B 1 ) whic h is linear. T esting condition in line 4 : In the following, let C b e an activ e or passiv e cycle in B ′ 1 just encoun tered b y our algorithm. W e will assume tha t J ⊂ ext ( C ). The case J ⊂ int ( C ) is similar. W e first need t o determine whether C should b e added to B . This is trivial if C is passiv e since passiv e cycles should alw ays b e a dded. And a s noted in Section 5.4, no pruned dual trees need to b e up dated after the insertion of a passiv e cycle. So assume that C is active . Let R b e the regio n containing C and let R ′ b e the region in int ( C ) that was generated when C w as added to B 1 during 29 the construction of the GMCB of G 1 . As w e show ed ab o v e, determining whether C should b e added to B amounts to che ck ing whether the n umber of elemen tary faces in R is strictly larger tha n the n um b er of elemen tary faces in R ′ . W e can easily extend our region data structure to ke ep trac k of the num - b er of elemen tary fa ces in eac h region without increasing the time and space b ounds of our algorithm. By recording t his info r ma t io n for R ′ during the re- cursiv e call for G 1 , it fo llows that we can determine in constant time whether R con tains more elemen tary faces than R ′ . Of course, this only w orks if w e can quic kly iden tify R and R ′ . Iden tifying R ′ is simple since this region is asso ciated with the vertex v C of region tree T ( B 1 ) asso ciated with C . T o iden tify R , let R v C b e the region asso ciated with v C in T ( B 1 ). Since B 1 is the G MCB of G 1 , eac h pair of elemen tary faces of G 1 is separated b y some cycle of B 1 . It follow s that R v C con tains exactly one elemen tary face f v C of G 1 . W e may assume that this face w as asso ciated with v C during the construction of B 1 so that w e can obtain this face in constan t t ime from v C . F ace f v C is also an elemen tary face in G and it b elongs to R . Recall from Section 5.3.1 t ha t there is a bidirected p oin ter b et w een R and eac h elemen tary face of G b elonging to R . Hence, we can obtain R from f v C in constan t time It follows fr o m the ab o v e that we can c hec k if C should b e added to B in constan t time. Inserting a cycle: No w, supp ose C should b e inserted in to B . W e first mak e cycles of B ′ 1 passiv e according to Lemma 1 2. This can b e done with, sa y , a depth-first searc h in T ( B 1 ) starting in vertex v C of T ( B 1 ) and visiting descendan ts of this verte x. The searc h stops when a vertex asso ciated with a passiv e cycle is encoun tered. Eac h searc h iden tifies the v ertices of T ( B 1 ) that are asso ciated with cycles whose stat e c hanges from non-passiv e to passiv e. And since w e stop a searc h when a passiv e cycle is encoun tered, all searc hes tak e total time pr o p ortional to the size o f T ( B 1 ) whic h is O ( n ). Next, w e need to up date regions and con tracted and pruned dual trees. Let R 1 b e the in ternal region and let R 2 b e the external region w.r.t. R and C . As w e sho w ed in the ov erall description of the algorithm, the only problem that w e need to consider is ho w to construct R 2 and its con tracted and pruned dual trees. W e sho we d that this amounts to r eplacing all faces 30 R R 2 C R 1 C 1 C 2 Figure 11: So lid cycles b elong to the partially constructed G MCB B of G . All descendan ts o f ve rtices of T ( B 1 ) asso ciated with solid cycles are passiv e and th us do not define fa ces of R . F o r this instance, C 1 and C 2 define the non-elemen tary f aces o f R . of R b elonging t o int ( C ) with a single new face defined by int ( C ) and to con tract all edges in int ( C ) to a single blac k v ertex in all con tracted and pruned dual trees fo r R . W e will sho w ho w to find the f a ces of R b elonging to int ( C ) in t ime prop ortional to their num ber. Applying the charging sc hemes in tro duced in Section 5.3.3, this will suffice to pro v e the desired time and space b ounds for the en tire algo rithm. Consider an activ e cycle C ′ asso ciated with a descendan t u of v C in T ( B 1 ). If C ′ w as previously considered in the for-lo o p of o ur algorithm, it mus t hav e b een added to B (by Lemma 12). This implies that int ( C ′ ) must b e a non- elemen tary f ace of R since otherwise, C ′ w ould b e passiv e, see Fig ure 1 1. The con v erse holds as well: an y non-elemen tary face of R b elonging to int ( C ) is realized b y i n t ( C ′ ) for suc h a cycle C ′ previously considered in the for-lo op. It follo ws that w e can find all non-elemen tary faces of R b elonging to int ( C ) b y identifying the activ e descendan ts of C in T ( B 1 ) that hav e already b een considered in the for-lo o p. Since a ll activ e cycles asso ciated with de- scendan ts o f C ar e to b ecome passiv e, we can c harg e the time for finding these faces to the n umber of cycles whose state c hanges fro m active t o pa ssiv e. What remains is t o find the elemen tary faces of R b elonging to int ( C ). Recall that w e ha ve asso ciated with eac h v ertex u of T ( B 1 ) the unique el- emen tary face of G 1 con tained in the regio n a sso ciated with u . V ertex v C and its descendan ts in T ( B 1 ) are thus asso ciated with exactly the elemen tary 31 faces of G 1 b elonging to int ( C ). Thes e faces are also elemen tary faces in G . It follo ws that the elemen tary faces o f R b elonging to int ( C ) a re a sso- ciated with exactly the descendan ts of C corresp onding t o activ e cycle s not already considered b y the algorithm. Using the same c harging sc heme as ab o ve, w e can also iden tify these faces within t he required time and space b ounds. W e hav e shown how to implemen t the entire recursiv e greedy algorithm to run in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space and w e can conclude this section with the main result of our pap er. Theorem 2. Given an n -vertex planar, undir e cte d gr a p h G = ( V , E ) with non-ne gative e dge weights, the fol lowin g implici t r epr esentation of the GMCB B of G c an b e c ompute d in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) sp ac e: 1. a set of tr e es T 1 , . . . , T k in G r o ote d at vertic es v 1 , . . . , v k , r esp e ctively, 2. a set of triples ( i, e, w ) r epr esenting the cycles in B , wher e i ∈ { 1 , . . . , k } , e = ( u, v ) ∈ E \ E T i , and w ∈ R , wher e u and v ar e vertic es in T i . The p air ( i, e ) r epr e s ents the cycle in B forme d by c onc atena ting e and the two p aths in T i fr om v i to u and fr om v i to v , r esp e c tively. T h e value of w is the weight of this cycle, 3. the r e gio n tr e e T ( B ) wher e e ach vertex p oints to the asso ciate d r e gion, 4. a set of r e g i o ns. Each r e gion is ass o ciate d with the unique e l e m entary fac e of G c ontaine d in that r e gion. Each internal r e gi o n R ( C , B ) i s asso ciate d w ith the triple r epr esenting C . 6 Corollarie s In this section, w e presen t results all of whic h follo w from Theorem 2. The first is an output-sensitiv e sensitiv e algorithm for computing an MCB. Corollary 1. A m i n imum cycle b asis of an n -ve rtex planar, undir e cte d gr aph with non-ne gative e dge weigh ts c an b e c ompute d in O ( n 3 / 2 log n + C ) time and O ( n 3 / 2 + C ) sp ac e, wher e C is the total length of al l cycles in the b asis. Pr o of. F ollow s immediately from Theorem 2 . A stronger result holds when the graph is unw eigh ted: 32 Corollary 2. A minimum cycle b asis o f an n -vertex planar undir e cte d, un- weighte d gr aph c an b e c ompute d in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) sp ac e. Pr o of. Let G b e an n -v ertex planar, undirected, unw eigh ted g raph. The in ternal elemen tary faces o f G define a cycle basis of of G of total length O ( n ). Hence, sinc e G is un w eigh ted, an MCB of G has total length O ( n ). The result now follows from Coro llary 1. Since the all-pairs min cut problem is dual equiv alen t to the MCB problem for planar graphs, w e also get the fo llowing t w o results. Corollary 3. A l l-p airs m in cuts of an n -vertex planar, undir e cte d gr aph with non-ne gative e dge weights c an b e c ompute d in O ( n 3 / 2 log n + C ) time and O ( n 3 / 2 + C ) sp ac e, wher e C is the total len g th of the c uts. Pr o of. Let G b e an n -ve rtex planar, undirected g r a ph with non-negative edge w eigh ts. As sho wn in [12], if G is connected, w e can solv e the APMCP for G b y solving the MCBP for the dual G ∗ of G . W e ma y assume that G is connected since otherwise, w e can consider eac h connected comp onen t separately . W e cannot immediately solv e the MCBP for G ∗ since this is a m ultig r a ph. But w e can av oid a n edge o f t he form ( u, u ) b y splitting it in to tw o edges ( u, v ) and ( v , u ) whose sum of w eights equal the we ight o f ( u, u ). And w e can a void m ulti-edges in a similar w ay . Let G ′ b e the res ulting planar graph. It is easy to see that G ′ has size O ( n ). F urthermore, an MCB B of G ′ can b e transfor med in to a n MCB of G ∗ in time propo r tional to the total size of cycles in B . The result no w fo llo ws from Corollary 1. Corollary 4. Al l-p airs mi n cuts of an n -vertex planar, undir e c te d, unweighte d gr aph c an b e c ompute d in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) sp ac e. Pr o of. This result is easily obtained b y comb ining the pro ofs o f Corolla r y 2 and Corollary 3. Next, we presen t our sub quadratic time and space algorithm for finding the w eigh t v ector o f a planar graph. Corollary 5. The weight ve ctor of an n -vertex pla nar, undir e cte d gr aph with non-ne gative e dge we ights c an b e c ompute d in O ( n 3 / 2 log n ) time a nd O ( n 3 / 2 ) sp ac e. 33 Pr o of. F rom Theorem 2, w e obtain an implicit represen tation of the G MCB B for the input graph. W e t hen compute the w eigh ts of a ll cycles in B using linear time and space. Sorting them takes O ( n lo g n ) time. This giv es t he w eigh t v ector of the input graph in a total of O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space. F rom Theorem 2, we also obtain a faster alg orithm for computing a Gomory-Hu tree of a planar graph. Corollary 6. A Gomory-Hu tr e e of an n -vertex c onne cte d, planar, undir e cte d gr aph w i th non-n e gative e dge we i g hts c an b e c ompute d in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) sp ac e. Pr o of. The f ollo wing algor it hm constructs a Gomory-Hu tree for G [26]: a tree T spanning a collection o f v ertex sets S 1 , . . . , S t is maintained, starting with S 1 = V . A t each step, a set S i is pick ed such that | S i | > 1 and an y t w o distinct v ertices u, v ∈ S i are c hosen. Set S i is then regarded as the ro ot of T and eac h subtree of T , i.e., each tree in T \ { S i } , is collapsed into a single superno de. A min u - v cut in the resulting graph is found, par titioning V into t w o subs ets, V 1 and V 2 , where u ∈ V 1 and v ∈ V 2 . T ree T is then mo dified by splitting S i in to t w o v ertices, S i 1 and S i 2 , where S i 1 = S i ∩ V 1 and S i 2 = S i ∩ V 2 . The t w o v ertices are connected b y a new edge whose we ight equals the size of the min cut found. Finally , each subtree of the old T is connected to S i 1 if the corresp o nding sup erno de w as in the same partition as u in the cut. Otherwise, the subtree is connected to S i 2 . Let us sho w ho w to implemen t this algorithm to obtain the desired t ime and space b ounds. W e first apply Theorem 2 to the dual G ∗ of G , giving an implicit represen tation o f the GMCB o f G ∗ . By Lemma 3, eac h cycle C in this basis is a minim um-w eigh t cycle that separates some pair of faces f 1 and f 2 in G ∗ . Let u 1 and u 2 b e the vertice s of G corr esp onding to f 1 and f 2 , resp ectiv ely . By dualit y o f the GMCBP and the APMCP [1 2 ], the edges of C are the edges of a min u 1 - v 1 cut in G of w eight equal to the weigh t of C . No w, pic k an y C cycle in t he GMCB of G ∗ . As the initia l min cut in the Gomor y- Hu tree algorithm, w e pic k the one corresp onding to C . This separates the initial set S i = S 1 = V into tw o sets S i 1 and S i 2 , where S i 1 is the set of v ertices o f G corresp onding to faces of G ∗ in int ( C ) and S i 2 is the set of v ertices of G corresp onding to fa ces of G ∗ in ext ( C ). Now, T consists of v ertices S i 1 and S i 2 and an edge ( S i 1 , S i 2 ). The w eigh t of t his edge is equal 34 to the we ight of C . Since w e are giv en the we ight of C from Theorem 2, w e can this obtain the we ight of edge ( S i 1 , S i 2 ) in constan t time. Note that for eac h pair of v ertices u and v in S i 1 , there is a min u - v cut defined b y a cycle of B whic h is a descendan t of C in T ( B ). And for eac h pair of v ertices u and v in S i 2 , there is a min u - v cut defined b y a cycle of B whic h is a non- descendan t o f C in T ( B ). Hence, w e hav e separated o ur pro blem in tw o a nd we can recursiv ely compute the G o mory-Hu tree for G b y splitting region tree T ( B ) in t wo at eac h recursiv e step. The recursion stops when we obtain a set S i of size one. A t this p oin t, we obtain the elemen tary face f of G ∗ correp onding to the v ertex in S i using part four of Theorem 2 . The ve rtex of G corresp onding t o f in G ∗ is then the unique ve rtex in S i . Let us analyze t he running time of this algorithm. Applying Theorem 2 tak es O ( n 3 / 2 log n ) time a nd O ( n 3 / 2 ) space. Note that in the algorithm ab ov e, w e do not need to compute the v ertices in the S i -sets un til they hav e size one. So each step of the algorithm, where the curren t S i -set has size greater than one, can b e implemen ted to run in constan t time. And we can also execute a step where | S i | = 1 in constant time using the fourth part of Theorem 2 to find the v ertex in S i . Since the G MCB of G ∗ con tains O ( n ) cycles, it follo ws that the algorithm runs in linear time and space, in addition to the time and space in Theorem 2 . Finally , w e presen t our ora cle f or answ ering min cut queries. Corollary 7. L et G b e an n -vertex plan ar, undir e cte d gr aph with non-n e gative e dge w e ights. With O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) sp ac e for pr epr o c essing , the weigh t o f a m in cut b etwe en an y two g i v en vertic es of G c an b e r ep orte d in c onstant time. The cut itself c an b e r ep o rte d in time p r op ortional to its size. Pr o of. W e may assume that G is connected since otherwise, we can consider eac h connected comp onen t separately . W e first construct a Gomory-Hu tree T o f G . By Corollary 6, this can b e done in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space. By definition o f Gomory-Hu trees, answ ering the query for the w eigh t of a min cut b et wee n tw o v ertices u and v of G reduc es to answ ering the query for the minim um weigh t of an edge on the simple path b et w een u and v in T . 35 It is w ell-kno wn that any tree with m v ertices ha s a v ertex v suc h that the tree can b e split into t w o subtrees, eac h ro oted at v and eac h containing b et w een m/ 4 and 3 m/ 4 v ertices. F urthermore, this separator can b e found in linear time. W e find suc h a separator in T and recurse on the t w o subtrees. W e stop the recursion at lev el log ( √ n ). The total time for this is O ( n lo g n ). Let S b e the subtrees a t lev el log( √ n ). W e observ e that these trees are edge-disjoin t and their union is T . F urthermore, |S | = O ( √ n ) and eac h subtree has size O ( √ n ). The b oundary vertic es of a subtree S ∈ S are the v ertices that S shares with other subtrees in S . V ertices of S that are no t b oundary v ertices are called interior vertic es of S . W e let B be t he set of b oundary ve rtices ov er all subtrees in S . It is easy t o see that | B | = O ( √ n ). F or each b oundary v ertex b ∈ B , we asso ciate an ar r ay with an entry for eac h v ertex of T . The en try corresp onding to a vertex v 6 = b contains the edge of minim um w eigh t on the simple path in T b et w een b and v . Since | B | = O ( √ n ), it follo ws easily that we can construct all these arra ys and fill in their en tries in a total of O ( n 3 / 2 ) time and space. This allows us to answ er queries in T in constan t time when one of the t w o ve rtices b elongs to B . W e associate eac h v ertex v of T not b elonging to B with the unique subtree S v in S con taining v a s an in terior ve rtex. Asso ciated with v is also an arra y with an en try for eac h S ∈ S \ { S v } . This en try contains the v ertex b o f B b elonging to S v suc h that a n y pa t h from v to S contains b . No t e that for a n y other v ertex v ′ of S v , any path from v ′ to S also contains b . F rom this observ atio n and from the fact that |S | = O ( √ n ), it follows that w e can compute the arrays associated with in terior vertice s in a ll subtrees using a total of O ( n 3 / 2 ) time and space. Finally , w e asso ciate with v an array with an en try for each ve rtex v ′ of S v . This en try con tains the edge of minim um weigh t on t he simple path in S v from v to v ′ . Since S v has size O ( √ n ), the en tries in t his array can b e computed in O ( √ n ) time. Ov er all in terior v ertices of all subtrees of S , this is O ( n 3 / 2 ) time. No w, let us describ e how to answ er a query for v ertices u a nd v in T . In constan t time, w e find the subtrees S u , S v ∈ S suc h that u ∈ S u and v ∈ S v . If S u = S v or if u or v b elongs to B , we can answ er the query in constan t time with the ab ov e precomputations. No w, assume that S u 6 = S v and that u and v are interior ve rtices. W e find the b oundary v ertex b of S u suc h that an y pa t h from u to R v con tains 36 b . Let P 1 b e the simple path in S u from u to b and let P 2 b e the simple path in T from b to v . F or i = 1 , 2, the ab o ve precomputations a llo w us to find the least-weigh t edge e i on P i in constan t time. Let e b e the edge o f smaller w eigh t among e 1 and e 2 . Returning the weigh t of e then answ ers the query in constan t t ime. T o sho w the last part of the corollary , observ e that when the w eigh t of edge e is o utput b y the ab ov e algorithm, the set of edges in t he corresp onding cut is defined b y a cycle C e in the GMCB B of G ∗ . During the construction of G o mory-Hu t r ee T (see Corollary 6), w e can a ssociat e e with the implicit represen tation of C e from Theorem 2. Hence, giv en e , w e can out put C e in time prop ortional to its size. This completes the pro o f . 7 Obtaining Lex- S hortest P ath T rees Let w : E → R b e the w eight function on the edges of G . In Section 4, w e assumed uniqueness of shortest path in G betw een an y tw o v ertices w.r.t. w . W e now sho w how to a v oid this assumption. W e assume in the follow ing that the v ertices of G are giv en indices from 1 t o n . By results in [12], there is another w eigh t function w ′ on the edges of G suc h that for any pair of v ertices in G , there is a unique shortest path b etw ee n them w.r.t. w ′ and this path is also a shortest path w.r.t. w . F urthermore, for t w o pa ths P and P ′ b et w een the same pair of v ertices in G , w ′ ( P ) < w ′ ( P ) exactly when one of the following three conditions is satisfied: 1. P is strictly shorter than P ′ w.r.t. w , 2. P and P ′ ha v e the same w eigh t w.r.t. w and P con tains few er edges than P ′ , 3. P and P ′ ha v e the same weigh t w.r.t. w a nd the same num ber of edges and the smallest index of v ertices in V P \ V P ′ is smaller tha n the smallest index of v ertices in V P ′ \ V P . A shortest path w.r.t. w ′ is called a lex-s hortest p ath and a shortest path tree w.r.t. w ′ is called a lex-s h ortest p ath tr e e . As sho wn in [12], lex-shortest paths b et we en all pairs of vertice s in G can b e computed in O ( n 2 log n ) t ime. W e need something faster. In the follo wing, w e sho w a stronger result, namely how to compute a lex-shortest path tree in 37 O ( n lo g n ) time. Since we o nly need to compute shortest paths from O ( √ n ) b oundary v ertices, this will give a to tal time b ound of O ( n 3 / 2 log n ). W e also nee d to find lex-shortest path trees in subgraphs of G when recursing and w e need to compute them w.r.t. the same w eight function w ′ . By the ab o ve, this can b e a chiev ed simply b y k eeping the same indices for v ertices in all recursiv e calls. No w, let s ∈ V b e giv en and let us show how to compute the lex-shortest path tree in G with source s in O ( n log n ) time. W e first use a small trick from [12]: for function w , a sufficien tly small ǫ > 0 is added to the w eigh t of eve ry edge. This allow s us to disregard the second condition ab o v e. When comparing w eigh ts of paths, we may tr eat ǫ sym b olically so w e do not need to w orry ab out precision issues. W e will a pply Dijkstra’s algorithm with a few additions whic h w e describ e in the follo wing. W e k eep a queue of distance estimates w.r.t. w as in t he standard implemen tat io n. Now , consider an y p oint in the algorithm. Let d be the distance estimate f unction. Consider an un visited v ertex v with curren t distance estimate d [ v ] < ∞ and predecessor ve rtex p . Supp ose that at this po in t, the algorithm extracts a v ertex p ′ from Q whic h is adjacen t to v in G and supp ose t ha t d [ p ′ ] + w ( p ′ , v ) = d [ v ]. The cen tral problem is to decide whether v should k eep p or get p ′ as its new predecess or. In the follow ing, w e sho w how to decide this in O (lo g n ) time. This will suffice to giv e an O ( n log n ) time alg orithm that computes the lex- shortest path tree in G with source s . Let P b e the path in the partially constructed lex-shortest pat h tree T from s to p follow ed by edge ( p , v ). Let P ′ b e the path in T from s to p ′ follo we d b y edge ( p ′ , v ). Note that P and P ′ b oth ha ve weigh t d [ v ] w.r.t. w . Hence, P is shorter than P ′ w.r.t. w ′ if and only if the third condition ab ov e is satisfied. In o ther w or ds, v should k eep p as its predecessor if and only if this condition is satisfied. Let q b e the lo w est common ancestor of p and p ′ in T . P aths P and P ′ share v ertices from s to q . Then they split up and do not meet b efore v . Let Q b e the subpath of P from the successor of q to p . Let Q ′ b e the subpath o f P ′ from the succes sor of q to p ′ . T esting the third condition ab ov e is equiv alen t to deciding whether the smallest v ertex index in V Q is smaller than the smallest v ertex index in V Q ′ . W e assume that for eac h ve rtex u in T , w e ha v e p ointers p 0 [ u ] , . . . , p k u [ u ] and v alues m 0 [ u ] , . . . , m k u [ u ] ∈ { 1 , . . . , n } . F or i = 0 , . . . , k u , p i [ u ] p o in ts to the ancestor a of u in T for whic h the num b er of edges fro m a to u is 2 i . 38 And m i [ u ] is the smallest v ertex index on the path in T from a to u . The v alue of k u is defined as the largest i suc h that p i [ u ] is defined. Note tha t k u = O (lo g n ). Since P and P ′ ha v e the same n umber of edges, the same holds for Q and Q ′ . F rom t his observ ation, it follows that we can apply binary search on the p ointers defined ab ov e to find lo w est common ancestor q in O (log n ) time. And with these p oin ters and the m i -v alues, w e can partition Q and Q ′ in to O (log n ) in terv als in O (lo g n ) time and find the smallest index in eac h in terv al in constan t time p er in terv al. Hence, w e can decide whether the smallest v ertex index in V Q is smaller t ha n the smallest v ertex index in V Q ′ in logarithmic time, whic h give s the desired. The only pro blem that remains is how to compute p oin ters and m i -v alues during the course of the algorithm. Whenev er the partially constructed lex- shortest path tree is extended with a new v ertex u , w e need to compute p 0 [ u ] , . . . , p k u [ u ] a nd m 0 [ u ] , . . . , m k u [ u ] ∈ { 1 , . . . , n } . But this can easily b e done in O (log n ) time using the p i -p ointe rs and m i -v alues for the ancestors of u in T . W e can now conclude this section with the follo wing theorem. Since w e did not mak e use of planar it y in this section, w e get a more general result, whic h we b eliev e to b e of indep enden t interes t. Theorem 3. A lex-shortest p ath tr e e in an undir e cte d gr aph with m e dges and n vertic es c an b e c ompute d in O (( m + n ) log n ) time. Pr o of. F ollow s b y combining the a b o v e with a standard implemen tation of Dijkstra’s algorithm. 8 Conclud ing Remarks W e sho we d tha t finding a minimum cycle basis of an n - v ertex planar, undi- rected, connected graph with non-negativ e edge w eights requires Ω( n 2 ) time, implying that a recen t algorithm b y Amaldi et al. is optimal. W e then pre- sen ted a n algorithm with O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space requiremen t that computes suc h a basis implicitly . F rom this result, we obtained an o utput-sensitiv e algorithm requiring O ( n 3 / 2 log n + C ) time and O ( n 3 / 2 + C ) space, where C is the total length of cycles in the basis t ha t the algo r it hm outputs. F or un w eigh ted graphs, we obtained O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space b o unds. 39 Similar results w ere obta ined fo r the all-pairs min cut problem for planar graphs since for planar g raphs, this problem is know n to b e dual equiv alen t to the minim um cycle basis problem. As corollaries, w e obtained algorithms that compute the w eigh t v ector and a Gomory-Hu t r ee of a planar n -v ertex graph in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space. The previous b est b o und w as quadratic. F rom the Gomory-Hu tree algorithm, w e deriv ed an oracle for answ ering queries for t he w eigh t of a min cut b et we en any t wo giv en v ertices. Pre- pro cessing time is O ( n 3 / 2 log n ) and space is O ( n 3 / 2 ). Quadra t ic time a nd space w as previously the b est b ound for constructing suc h an ora cle. Our algorithm can output t he actual cut in time prop or t io nal t o its size. Ac kno wled gmen ts I thank Sergio Cab ello for s ome in teresting commen ts and for in tro ducing me to Gomory-Hu trees. References [1] E. Amaldi, C. Iuliano, T. Jurkiewicz, K. Mehlhorn, and R. R izzi. Break- ing the O ( m 2 n ) Barrier fo r Minim um Cycle Bases. A. Fiat a nd P . Sanders (Eds.): ESA 20 0 9, LNCS 5757, pp. 301–312 , 2009. [2] F. Berger, P . Gritzmann, and S. de V ries. Minim um cycle bases fo r net w ork graphs. Alg orithmica, 40 (1): 51–62, 2004. [3] F. Berger, P . Gritzmann, and S. de V ries. Minim um Cyc le Bases and Their Applications. Algorithmics, LNCS 551 5 , pp. 34–49, 2009. [4] D. W. Cribb, R. D . Ringeisen, and D. R. Shier. On cycle bases of a graph. Congr. Numer., 32 (1981), pp. 22 1–229. [5] D. Cv etk o vic, I. Gutman, a nd N. T rina jstic. Graph theory and molecular orbitals VI I: The role of resonance structures. J. Chemical Phy sics, 61 (1974), pp. 27 0 0–2706. [6] N. Deo, G. M. Prabh u, and M. S. K r ishnamo orth y . Algorithms for gen- erating fundamental cycles in a graph. A CM T rans. Math. So f t w are, 8 (1982), pp. 26 – 42. 40 [7] J. C. De Pina. Applications of shortest path metho ds. PhD thesis, Uni- v ersit y of Amsterdam, The Netherlands, 1995. [8] E. T. Dixon and S. E. G o o dman. An alg o rithm for the longest cycle problem. Netw orks, 6 (1976) , pp. 139– 149. [9] A. Golynski and J. D. Ho r t o n. A p olynomial time algorithm to find the minim um cycle ba sis of a regular matroid. In SW A T 2002: Proceedings of the 8th Scandinav ian W orkshop on Algorithm Theory , pages 200–209 , 2002. [10] R. Gomory and T. C. Hu. Multi-terminal net w ork flo ws. J. SIAM, 9 (1961), pp. 55 1 –570. [11] D. Harel and R. E. T arjan. F ast Alg o rithms for Finding Nearest Com- mon Ancestors. SIAM J. Comput. V olume 13 , Issue 2, pp. 338–355 (1984). [12] D. Hartvigsen and R. Mardon. The All- Pairs Min Cut Problem and the Minim um Cycle Basis Problem on Planar Graphs. SIAM J. Discrete Math. V olume 7, Issue 3, pp. 403–418 (Ma y 1994). [13] M. R. Henzinger, P . Klein, S. Rao, a nd S. Subramanian. F aster Short est- P ath Algorithms for Planar Graphs. Journa l of Computer and System Sciences v olume 55, issue 1, August 1 997, pages 3–23. [14] J. D. Horton. A p olynomial time algorithm to find the shortest cycle basis of a graph. SIAM J. Comput., 16 (1987 ), pp. 358–366. [15] T. Kav itha , C. Lieb chen , K. Mehlhorn, D. Mic hail, R. Rizzi, T. Uec k- erdt, and K. Z weig. Cycle bases in graphs: Characterization, algorit hms, complexit y , and applications. 78 pag es, submitted for publication, March 2009. [16] T. Ka vitha, K. Mehlhorn, D. Mic hail, and K. E. P aluc h. An ˜ O ( m 2 n ) algorithm for minimum cycle ba sis of gra phs. Algorithmica, 52 (3): 333– 349, 20 0 8. A preliminary ve rsion of this pap er app eared in ICALP 2 0 04, v olume 31 42, pages 846–857 . [17] G. Kir chhofff. Ueb er die Aufl¨ osung der Gleic hungen, auf w elc he man b ei der Un tersuc h ung der linearen V ertheilung galv anisc her Str¨ ome g ef ¨ uhrt 41 wird. Poggendorf Ann. Phys ik 7 2 (1847), pp. 49 7–508 (English transl. in T rans. Inst. Ra dio Engrs., CT-5 (1958), pp. 4 –7). [18] D. E. Kn uth. The Art of Computer Programming, V ol. 1. Addison- W esley , Reading, MA, 19 68. [19] E. Lawler. Com binato r ial Optimizatio n. Holt, Rinehart and Winston, New Y ork, 1976 . [20] P . Matei and N. Deo. On algorithms for en umerating all circuits of a graph. SIAM J. Comput., 5 (1976), pp. 90–9 9. [21] K. Mehlhorn and D. Mic hail. Minim um cycle bases: F aster and simpler. Accepted for publication in A CM T ransactions on Algorithms, 2007. [22] G. L. Miller. Finding small simple cycle separators f o r 2-connected pla- nar graphs. J. Comput. Syst. Sci., 32:2 65–279, 1986. [23] M. Randic. Resonance energy of ve ry large b enzenoid h ydro carb ons. In ternat. J. Quan tum Chemistry , XVI I (1980), pp. 5 49–586. [24] H. Saran and V. V. V azirani. Finding k -cuts within t wice the optimal. SIAM Journal on Computing, 24:101–10 8, 1995 . [25] N. T rina jstic. Chemical Graph Theory . CRC Press, Bo ca Raton, F L , V ol. 2, 1983. [26] V. V. V azirani. Approx imation Algorithms. Springer- V erlag , 20 03. 42 App endix Pro of of Lemmas 8 and 9 Let us first pro v e Lemma 8. W e only need to consider the hard case where in b eginning, all ob jects hav e w eight 1 and at termination, exactly one ob ject of w eigh t W remains. Consider running the algo rithm bac kw ards: starting with one ob ject of w eigh t W , rep eatedly apply an op eration split that splits a n ob ject of w eigh t at least t w o in to tw o new ob jects of p ositiv e in teger w eigh ts suc h tha t the sum of we ights of the t w o equals the weigh t of the original ob ject. Assume that split runs in time prop ort ional to the smaller w eigh t of the t w o new ob jects. If w e can give a b ound of O ( W log W ) for this a lg orithm, w e also get a b ound on the a lgorithm stated in the theorem. The running time fo r t he new algorithm satisfies: T ( w ) ≤ max 1 ≤ w ′ ≤⌊ w / 2 ⌋ { T ( w ′ ) + T ( w − w ′ ) + cw ′ } for integer w > 1 a nd constan t c > 0. It is easy to see that the r igh t-hand side is maximized whe n w ′ = ⌊ w / 2 ⌋ . This gives T ( W ) = O ( W log W ), as desired. The ab ov e pro of also holds for Lemma 9. Pro of of Lemma 10 W e need to sho w that for a cycle C = C ( v , e ) ∈ H ( V J ) b elonging to a region R , sets δ int ( R, C ), δ ext ( R, C ), and δ ( R, C ) can b e computed in O ( √ n ) time with O ( n 3 / 2 log n ) prepro cessing time and O ( n 3 / 2 ) space. First, observ e that since C is completely con tained in R , δ ( R , C ) is the subset of all b o undary v ertices b elonging t o C . Hence, this subset do es not dep end on R . W e will thus refer t o it as δ ( C ) in the f ollo wing. Let v 0 , . . . , v r − 1 b e the b oundary vertice s encoun tered in that order in a simple, sa y clo c kwise, w alk of J and let J = J 0 J 1 · · · J r − 1 b e a decomp o- sition of J into smaller curv es where J i starts in v i and ends in v ( i +1) m od r , i = 0 , . . . , r − 1 . Eac h curv e J i is completely con tained in an elemen tary face of G and w e let f ( J i ) denote this face. In our pro of, w e need the following lemma and its corollary . 43 Lemma 13. L et P b e a shortest p ath in G f r om a vertex u to a vertex v . Then a vertex w b elongs to P if and onl y if d G ( u, w ) + d G ( w , v ) = d G ( u, v ) . Pr o of. If w b elongs to P then clearly d G ( u, w ) + d G ( w , v ) = d G ( u, v ). And the con v erse is also tr ue since shortest paths in G are unique. Corollary 8. L et C = C ( v , e ) b e define d as ab ove. L et w ∈ V a n d assume that single-sour c e shortest p ath distanc es in G with sour c e s v and w have b e e n pr e c omp ute d. Then determini n g w h ether w b elongs to C c an b e done in c onstant time. Pr o of. Let u 1 and u 2 b e the end v ertices of e and let P 1 resp. P 2 b e the shortest paths in G from v to u 1 resp. u 2 . Since C is isometric, b oth P 1 and P 2 b elong to C and the union of their ve rtices is exactly the v ertices of C . Hence, determining whether w b elongs to C is equiv alen t to determining whether w b elongs to P 1 or to P 2 . The result now follo ws from L emma 13. W e will assume that single-source shortest path distances in G with eac h b oundary v ertex as source hav e b een precomputed. As observ ed earlier, this can b e done in O ( n 3 / 2 log n ) time and O ( n 3 / 2 ) space. Corollary 8 t hen allow s us to find the set δ ( C ) of b oundar y v ertices b elonging to C in O ( r ) = O ( √ n ) time. W e ma y assume that w e ha v e the b oundary ve rtices on C cyclically ordered according to how they o ccur o n J in a clo c kwise walk of tha t curv e. In t he follow ing, let v i = v (so C = C ( v i , e )). Consider t w o consecutiv e v ertices v i 1 and v i 2 of δ ( C ) in this cyclic ordering. W e assume that i 2 6 = i since the case i 2 = i can b e handled in a similar wa y . There are tw o p ossible cases: 1. the b oundary ve rtices ( excluding v i 1 and v i 2 ) encounte red when walking from v i 1 to v i 2 along J all b elong to int ( C ), o r 2. they all b elong to ext ( C ). Let v i 3 b e the predecessor b oundary v ertex of v i 2 on J (i.e., i 3 = ( i 2 − 1) mo d r ), see Figure 12. Then elemen tary face f ( J i 3 ) b elongs to int ( C ) if and o nly if the first case ab ov e holds. This fo llo ws from the fact that J do es not cross any edges of G . Lemma 14 b elo w shows ho w w e can chec k whethe r f ( J i 3 ) b elongs to int ( C ). First, let u a nd v b e the end v ertices of e and let P u and P v b e the shortest paths from v i to u a nd v , resp ectiv ely . Supp o se w.l.o.g. that v i 2 44 v = v i ( a ) u v e f uv ( b ) v u e f uv u ′ u ′′ v i 1 v i 3 f ( J i 3 ) v i 2 v ′′ v ′ v i 1 v i 2 u ′′ P v P v P u P u v i 3 v = v i u ′ v ′′ f ( J i 3 ) v ′ J J Figure 12: (a ) The first condition and (b): the second condition in Lemma 14. b elongs to P u , see Figure 12. Let u ′ b e the predecessor of v i 2 on P u . This is well-define d since i 2 6 = i . If v i 2 6 = u , let u ′′ b e the successor of v i 2 on P u . Otherwise, let u ′′ = v (so u ′′ is the v ertex 6 = u ′ adjacen t to v i 2 on C ). Let v ′ resp. v ′′ b e the prede cessor resp. successor of v i 2 in a clo c kwise walk of f ( J i 3 ). F or three p oin ts p, q , r in the plane, let W ( p, q , r ) b e the w edge-shap ed region with legs emanating from p and with right resp. left leg containing q resp. r . Lemma 14. With the ab ove defin itions, f ( J I 3 ) b elongs to int ( C ) if an d only if o n e of the fol lowing c onditions hold: 1. P u is p art of a c l o ckwise walk of C (when dir e cte d fr om v i to u ) and W ( v i 2 , u ′ , u ′′ ) c ontains W ( v i 2 , v ′ , v ′′ ) (Figur e 12( a)), 2. P u is p art of a c ounter-clo ckwise wa l k of C (whe n dir e cte d fr om v i to u ) and W ( v i 2 , u ′′ , u ′ ) c ontains W ( v i 2 , v ′ , v ′′ ) (Figur e 12( b)). Pr o of. Assume first that P u is part of a clo c kwise walk of C , see Figure 12(a) . Then int ( C ) is to the right o f the directed path u ′ → v i 2 → u ′′ . Since G is straigh t-line em b edded, f ( J I 3 ) b elongs to int ( C ) if and only if W ( v i 2 , u ′ , u ′′ ) con tains W ( v i 2 , v ′ , v ′′ ). No w, assume that P u is part of a coun ter-clo ckw ise walk of C , see Fig- ure 12(b). Then int ( C ) is to the righ t of the directed pat h u ′′ → v i 2 → u ′ . Th us, f ( J I 3 ) b elongs t o int ( C ) if and only if W ( v i 2 , u ′′ , u ′ ) con tains W ( v i 2 , v ′ , v ′′ ). 45 Lemma 14 and the ab o v e discuss ion sho w that to efficie ntly determine whether the boundary v ertices b etw een v i 1 and v i 2 b elong to int ( C ) or to ext ( C ), w e need to quic kly find u ′ , u ′′ , v ′ , and v ′′ and determine whether P u is part of a clo ckw ise or counte r- clo c kwise walk of C . By kee ping a clo c kwise o r dering of v ertices o f all elemen tary faces, w e can find v ′ and v ′′ in constan t time. F or eac h shortest path tr ee in G ro oted at a b oundary ve rtex, we assume that eac h non-r o ot vertex is asso ciated with its paren t in the tree. This allow s us to find also u ′ in constan t t ime. As for u ′′ , suppo se w e ha v e precomputed, for each b oundar y v ertex v j and eac h w ∈ V \ { v j } , the successor of v j on the path from v j to w in shortest path tree T ( v j ). D epth-first searc hes in eac h shortest path tree a llow us t o mak e these precomputations in O ( n 3 / 2 ) time and space. No w, since shortest paths are unique, the subpath o f P u from v i 2 to u is a path in shortest path tree T ( v i 2 ) and u ′′ is the successor of v i 2 on this path. With the ab ov e precomputatio ns, w e can th us find u ′′ in constan t t ime. Finally , to determine whether P u is part of a clo ckw ise w alk of C , w e do as follo ws. W e first find the elemen tary fa ces adjacent to e in G . They can b e obta ined fr o m dual tree ˜ T ( v i ) in constant time. W e can also determine in constan t time whic h of the tw o elemen tary faces b elongs to int ( C ) since that elemen tary face is a c hild of the other in ˜ T ( v i ). Let f uv b e the elemen tary face in the interior of C . W e c hec k if the edge directed fro m u to v is part of a clo ckw ise or coun ter-clo ckw ise w alk of f uv . Again, this tak es constan t time. If it is part of a clo c kwise w alk of f uv then P u is part of a clo c kwise w alk of C (Figure 12(a)) and otherwise, P u is part of a counte r- clo c kwise w alk of C (Figure 12(b)). This concludes the pro o f o f Lemma 10. Pro of of Lemma 11 Assume first that e is not an edge of G 1 . Let P 1 and P 2 b e the tw o shortest paths in G from v to the end v ertices of e , res p ective ly . Since e is not in G 1 , it must b elong to G 2 . Hence, the intersec tion b etw een C and G 1 is the union of paths Q , where Q is a subpath of either P 1 or P 2 with b oth it s end v ertices in V J . Each such path Q is a shortest path in G 1 . It then follows from Lemma 6 that C do es not cross an y cycle of B ′ 1 . No w, assume that e b elongs to G 1 and let f 1 , f 2 , and f J b e defined as in the lemma. Let C ′ ∈ B ′ 1 b e giv en. W e consider t wo cases: J ⊂ int ( C ′ ) and J ⊂ ext ( C ′ ). 46 Assume first that J ⊂ int ( C ′ ). Then R ( C ′ , B 1 ) is an ances tor of R ( f J , B 1 ). Since v ertex v of C b elongs to V J , part of C is contained in in t ( C ′ ). It follo ws that if C do es not cross C ′ then e is con tained in int ( C ′ ). The con v erse is also tr ue. F or if e is con ta ined in int ( C ′ ) then b y Lemma 6 , b oth P 1 and P 2 are con tained in int ( C ′ ), implying that C do es not cross C ′ . Th us, C crosses C ′ if and only if e is not in int ( C ′ ), i.e., if and only if f 1 and f 2 are b oth contained in ext ( C ′ ). The latter is equiv alent t o the condition tha t R ( C ′ , B 1 ) is an ancestor of neither R ( f 1 , B 1 ) nor R ( f 2 , B 1 ) in T ( B 1 ). Hence, C crosses C ′ if and only if the second condition of t he lemma is satisfied. No w, assume that J ⊂ e xt ( C ′ ). Then R ( C ′ , B 1 ) is not an a ncestor of R ( f J , B 1 ). Aga in, Lemma 6 show s that C crosse s C ′ if and only if e is not in ext ( C ′ ), i.e., if and only if f 1 and f 2 are b oth contained in int ( C ′ ). This holds if and only if R ( C ′ , B 1 ) is a n ancestor of b oth R ( f 1 , B 1 ) and R ( f 2 , B 1 ) in T ( B 1 ). It follows that C crosses C ′ if and only if the first condition of the lemma is satisfied. Pro of of Lemma 12 Assume first that J ⊂ e x t ( C ) and let C ′ b e a descendan t of C in T ( B 1 ). W e need to sho w that C ′ is added to B . Since C ′ ∈ B 1 , there is a pair of elemen tary faces f 1 and f 2 in G 1 whic h are separated b y C ′ and not b y an y other cycle in B 1 . Let f 1 b e con tained in int ( C ′ ) a nd let f 2 b e con tained in ext ( C ′ ). Note that f 2 is con tained in int ( C ) since otherwise, C w ould separate f 1 and f 2 . Since J ⊂ ext ( C ) and since no cycle of B crosses C , all cycles of B \ B ′ 1 b elong to ext ( C ). Hence, no cycle of H ( V J ) ∪ B ′ 1 ∪ B ′ 2 \ { C ′ } separates f 1 and f 2 . Since the set of cycles in the GMCB of G is a subset of H ( V J ) ∪ B ′ 1 ∪ B ′ 2 b y Lemma 4 and since C ′ ∈ B ′ 1 , it follow s that C ′ is added to B . No w assume that J ⊂ int ( C ). Since no cycle of B crosses C , all cycles of B \ B ′ 1 b elong to int ( C ). A similar argument a s the ab ov e then sho ws that all cycles of B 1 b elonging to ext ( C ) m ust b e par t o f the GMCB of G . These cycles are exactly the those tha t are not descendan ts of C in T ( B 1 ). 47

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment