Parametric and Kinetic Minimum Spanning Trees

Pankaj K. Agarwal 1 David Eppstein 2 Leonidas J. Guibas 3 Monika R. Henzinger 4

Abstract , the itself changes. The two cen- tral questions related to this problem are: how many differ- We consider the parametric minimum spanning tree ent trees does have as varies from to , and how G ∞ +∞ problem, in which we are given a graph with edge weights can one compute this sequence of trees? that are linear functions of a parameter and wish to com- As Katoh [23, 24] has described, parametric minimum pute the sequence of minimum spanning trees generated as spanning trees can be used to solve many other problems in varies. We also consider the kinetic minimum spanning tree combinatorial optimization, in which one seeks to ®nd a tree problem, in which represents time and the graph is subject T minimizing a function of the form f (X, Y ) where f is in addition to changes such as edge insertions, deletions, quasiconcave and X e T xe and Y e T ye. For ex- and modi®cations of the weight functions as time progresses. ample, the problem of= computing∈ a spanning= tree∈ that mini- We solve both problems in time O(n2/3 log4/3 n) per com- mizes the ratio of cost toP reliability can beP expressed in the 2/3 binatorial change in the tree (or randomized O(n log n) above form by setting f (X, Y ) X exp(Y ), where xe is the 1/2 3/2 = per change). Our time bounds reduce to O(n log n) cost of edge e, ye ln(1 pe), with pe the failure prob- per change (O(n1/2 log n) randomized) for planar graphs or ability of edge e.= The stochastic programming problem of other minor-closed families of graphs, and O(n1/4 log3/2 n) ®nding a tree with high probability of having low weight can per change (O(n1/4 log n) randomized) for planar graphs be expressed with the choice f (X, Y ) X √Y , and the with weight changes but no insertions or deletions. problem of ®nding a tree with the minimum= variance+ in edge weight can be similarly expressed with f (X, Y ) X Y 2. For each of these problems, any spanning tree of =gives rise G 1. Introduction to a point (X, Y ) in the plane. The quasiconcave nature of f implies that the optimum tree is a vertex of the convex hull The parametric minimum spanning tree problem deals of the set of all such points, and the trees giving rise to the with minimum spanning trees of weighted graphs, vertices of the convex hull are exactly those which are enu- ( , ), in which the weight of each edge is a linear functionG = merated in the parametric minimum spanning tree problem ofV someE parameter , instead of a real number. That is, the for with edge weights xi yi . Thus, one can solve the originalG static optimization problem by ®nding the best of weight of each edge e , we(), is of the form xe ye, ∈ E the trees listed by a parametric minimum spanning tree algo- where xe, ye are real numbers. As varies, the weight of each edge varies and therefore the weight of the minimum rithm. Note especially that in this type of application, there spanning tree of also varies. At certain discrete values of is no need to output each tree explicitly; we can spend sub- G linear time per tree as long as we can determine fast the two 1Center for Geometric Computing, Department of Computer Science, numbers X and Y for each tree. Duke Univ., Durham, NC, 27708-0129; http://www.cs.duke.edu/ pankaj/; Parametric optimization problems such as this are a spe- [email protected]. Work supported in part by Army Research Of®ce cial case of a more general class of , kinetic algo- MURI grant DAAH04-96-1-0013, by a Sloan fellowship, by an NYI award, and by a grant from the U.S.-Israeli Binational Science Foundation. rithms, recently proposed by Guibas et al. [3, 19].Akinetic 2Dept. of Information and Computer Science, Univ. of California, problem focuses on exploiting the coherence implicit in the Irvine, CA 92697-3425; http://www.ics.uci.edu/ eppstein/; eppstein@ics. continuous evolution of a system whose elements move or uci.edu. Work supported in part by NSF grant CCR-9258355 and by match- change according to known laws, while allowing arbitrary ing funds from Xerox Corp. 3Dept. of Computer Science, Stanford Univ., Stanford, CA, 94305; changes in these motion laws in an on-line fashion. A gen- http://graphics.stanford.edu/ guibas/; [email protected]. Work eral kinetic problem combines dynamic data structures (in supported in part by Army Research Of®ce MURI grant DAAH04-96-1- which sets of objects undergo single-object insertions and 0007 and NSF grant CCR-9623851 deletions) with parametric optimization (in which static ob- 4Compaq Systems Research Center, 130 Lytton Ave., Palo Alto, CA, 94301-1044; http://www.research.digital.com/SRC/personal/Monika jects have continuously varying weights). In such a prob- Henzinger/home.html; [email protected]. lem, one starts with a parametric problem in which the pa-

rameter represents time; as time progresses, objects may favor of earlier-numbered edges, the MST () is well de- be deleted or inserted, or their weight functions changed, ®ned and piecewise constant. If the underlyingG graph is ob- and the task is to maintain the optimal solution at each vious from the context, we will simply use MST() to de- value of time. Kinetic algorithms model well real-world note MST (). Let ( ) be the set of all minimum phenomena where objects move along trajectories that are spanning treesG of Tas= theT valueG of varies from to predictable in the short term, but subject to unpredictable . Set k k( )G ( ) . ∞ +∞ = G =|T G | changes in the long term. The goal of a parametric minimum spanning tree algo- We distinguish two possible types of kinetic algorithms rithm is to compute the set . We denote by P(n, m) the for the minimum spanning tree problem: maximum value of k( ), whereT the maximum is taken over G A structurally kinetic can handle arbitrary all (parametric) graphs with n vertices and m edges. Dey [7] recently proved that P(n, m) O(mn1/3); the best lower insertions or deletions of parametrically weighted = bound known is P(n, m) (m(n)) [9]. edges. Edge weight function changes can be simulated = by deleting and re-inserting the edge. In a kinetic minimum spanning tree algorithm, the pa- rameter represents time, and the goal is to maintain A functionally kinetic algorithm can only handle up- MST() dynamically as the graph undergoes changes ei- dates that change the weight function of an existing ther to its structure or to its weight functions. We denote edge. Edge deletions and insertions can be simulated by K (n, m) the maximum number of distinct trees formed by changing weights to or from some very large value; by a kinetic problem on a graph with n vertices subject to however this simulation comes at the cost of increasing m edge insertions, edge deletions, or weight change opera- the number of edges (and perhaps violating restrictions tions starting from an empty graph. A third parameter for such as that the graph remain planar). the number of edge weight changes is super¯uous, since the In this paper, we provide ef®cient algorithms for both the number of distinct trees in a graph with x > m changes is functionally kinetic and structurally kinetic minimum span- easily seen to be 2((x/m)K (n, m)).) We do not use sep- ning tree problems. Since the parametric minimum span- arate notations for the number of trees in functionally and ning tree problem is a special case of either type of kinetic structurally kinetic problems, since the simulations between problem, our algorithms also apply a fortiori in the paramet- each kind of kinetic algorithm causes these numbers to be ric case. the same to within a constant factor. Parametric and kinetic minimum spanning trees form an If a sequence of structurally kinetic changes to a graph interesting combination of graph theory and computational were known in advance, then we could simulate the kinetic geometry: the minimum spanning tree part of the problem problem by a parametric problem: simply replace each edge is purely graph-theoretic, while the weight functions can be e by a three-edge path e1e2e3, with the weight of e1 equal viewed as lines in a weight-time plane, lending the prob- to that of the kinetic edge, with e2 having a highly nega- lem a geometric ¯avor. Our solution technique, too, com- tively sloped weight function, and with e3 having a highly bines graph algorithms and : we use positively sloped weight function, chosen so that the inter- sparsi®cation and clustering techniques common to many val in which e2 is the largest of the three weights is exactly dynamic graph algorithms, with convex hull data structures the lifetime of e. Then, in this modi®ed graph, the minimum representing sets of edges in each cluster. We also apply sev- spanning tree will consist of the two least weight edges in eral other techniques including parametric search (a tech- each three-edge path, together with a third edge in a subset of nique of Megiddo [26] for turning decision algorithms into paths corresponding exactly to the minimum spanning tree optimization algorithms, commonly used in both parametric of the original graph. (Essentially the same three-edge-path optimization and computational geometry; see, e.g., [1]) and construction was used in the lower bound of [9].) For this a data structure for maintaining convex hulls of a point set reason K (n, m) P(n 2m, 3m) O(m4/3). + = subject to insertions and undo operations. We will also consider the special cases of planar and 1.1. Notation minor-closed graph families, for which the number of dis- tinct trees may be smaller than in the case of general graphs. Throughout, we assume that we have a weighted, con- For any minor-closed family , we let P (n) denote the nected graph ( , ) with n vertices and m edges, in maximum number of distinct treesF in a parametricF problem G = V E which the weight of each edge e is a linear function we() on an n-vertex graph, and K (n) denote the maximum num- = F xe ye. (For structurally kinetic problems, n and m denote ber of distinct trees in a structurally kinetic problem. Since the number of vertices and edges at some particular point minor-closed graph families consist only of sparse graphs, in the course of the algorithm.) The graph may have mul- there is no need to include a second parameter m. The tiple adjacencies. Let MST () denote a minimum span- method above of simulating edges by paths shows that the G ning tree of for the weights we(); if we break ties in maximum number of distinct trees in a functionally kinetic G

problem is 2(P (n)) whenever is closed under replace- 2. Sparsi®cation ment of an edgeF by a series-parallelF graph (in particular, this is true for planar graphs); however it does not seem possible Sparsi®cation [11] is a divide-and-conquer technique to use this method to bound K (n) by PF (n). used in dynamic algorithms, whereby the edges of a graph F are split recursively into subsets, a certi®cate1 for each 1.2. History and New Results subset is maintained dynamically, and the overall property is maintained using a dynamic graph algorithm applied to Study of minimum spanning trees has a long rich history the union of these certi®cates. Fernandez-Baca et al. [14] [18]. Currently, it is known how to compute the minimum showed that a similar idea applies also to parametric prob- spanning tree in randomized linear expected time [22] or de- lems. We combine both of these applications of sparsi®- terministically in time O(m(m, n) log (m, n)) [5].Ef®- cation to obtain an ef®cient data structure for the kinetic cient algorithms have been developed for maintaining the problem, which is a common generalization of dynamic and minimum spanning tree of a graph as edges are inserted into parametric problems. or deleted from the graph [11,15,20,21]. The parametric min- 2.1. General Graph Sparsi®cation imum spanning tree problem has also been previously stud- ied, most recently by Fernandez-Baca et al. [14]. In that pa- The key result needed to apply sparsi®cation is the fol- per an algorithm was described that takes time O(mn log n) lowing lemma, which shows that graphs can be replaced by to list all trees. However this still remains far from Dey's sparse certi®cates without changing the solution to the min- 1/3 bound of O(mn ) on the number of such trees. Parametric imum spanning tree problem. This is a result about stati- optimization problems have been studied for several other cally weighted graphs, but it holds a fortiori for any partic- graph problems as well; see [13,28] for a sample of such re- ular value of occurring in a kinetic algorithm. sults. There are no known previous algorithms for the ki- netic minimum spanning tree problem. A related problem, Lemma 1 (Eppstein et. al [11]). The minimum spanning which has been studied, is the kinetic Euclidean MST prob- tree of a graph is equal to the minimum spanning G ∪ H lem [4], in which we want to list all different Euclidean mini- tree of the subgraph formed by the union of the minimum mum spanning trees of a set of points, each of which is mov- spanning trees of and . ing along a line or curve. G H Let p denote the number of edge insertions, edge dele- We then use a divide and conquer approach, applying this tions, or minimum spanning tree topology changes. Here lemma to combine solutions to subproblems. The paramet- we show the following results, substantially improving what ric case of the following lemma is implicit in [14]. was previously known. Lemma 2. Suppose that we have a data structure that can solve structurally kinetic minimum spanning tree problems We can maintain a structurally kinetic graph, and in time O( f (m, n)) per insertion, deletion, or topology keep track of the minimum spanning tree, in total change, and that f (m, n) (mc) for some constant time O(min pm2/3 log4/3 m, K (n, m)n2/3 log4/3 n ). = { } c > 0. Then we can solve structurally or functionally ki- If we allow randomization, the expected time is netic problems in time O(K (n, m) f (2n, n)), and paramet- O(min pm2/3 log m, K (n, m)n2/3 log n ). { } ric problems in time O(P(n, m) f (2n, n)). For any structurally kinetic graph belonging to a Proof: We outline the general method here; see [14] for minor-closed family, we can keep track of the min- details. We divide the edges of the graph arbitrarily into imum spanning tree in total time O(pn1/2 log3/2 n). two equal subsets, and solve recursively the kinetic prob- If we allow randomization, the expected total time is lems for each subset. The solutions to these subproblems O(pn1/2 log n). consist of a sequence of changes to the minimum spanning trees of the subproblems. We use our assumed data structure For any parametric or functionally kinetic graph be- to solve a kinetic problem on the union of these two trees, longing to a minor-closed family, we can keep track by merging these two sequences of updates. At any time of the minimum spanning tree in total time O(n3/2 there are at most 2n edges in the kinetic problem, and the P(n)n1/4 log3/2 n). If we allow randomization the ex-+ number of updates coming from each subset is K (n, m/2), pected total time is O(n3/2 P(n)n1/4 log n). For pla- hence we get a recurrence of T (m, n) 2T (m/2, n) = + nar graphs the O(n3/2) term+ in these bounds can be re- O(K (n, m) f (2n, n)) for the overall problem. As described moved. With Dey's bound P(n) O(n4/3), our to- here, this might lead to an additional logarithmic factor over = 19/12 3/2 tal time is worst-case bounded by O(n log n),or 1 19/12 The certi®cates are subgraphs of the original graph; they should not be randomized expected time O(n log n). confused with the distinct notion of certi®cate used in kinetic proofs [19].

the stated bounds; the ªimproved sparsi®cationº technique Lemma 4. Any edge e in that is not in MST ( )( ) N G +∞ [11] avoids this extra logarithm by reducing the number of is not in the minimum spanningG tree of . vertices as well as the number of edges in the recursive sub- G ∪ H problems. 2 We call an edge e of uncertain if e MST ( )( ) G ∈ N G +∞ but e MST ( )( ). We cannot be sure whether an un- certain6∈ edge isN inG the∞ minimum spanning tree of the entire 2.2. Separator-Based Sparsi®cation Certi®cates graph without knowing the weights of the edges in .Ifwe H delete from MST ( )( ) all the vertices and edges not We applied sparsi®cation to speed up our kinetic algo- in , this tree is splitN G into∞X connected components, each rithms for general graphs. We now similarly apply separa- containingG exactly one vertex| | of X. It can be checked that tor based sparsi®cation [12] to speed up our algorithms for the uncertain edges of connect these components to form planar graphs and for minor-closed graph families. The ba- MST( ). This immediatelyG implies the following. sic idea of this approach is to divide the graph into two sub- G graphs by a separator, a small set X of vertices shared by Lemma 5. Any uncertain edge is part of a path in both subgraphs, so that each subgraph has only a constant MST ( )( ) between two vertices of X. The number of fraction of the original graph's vertices. For planar graphs uncertainN G edges+∞ is X 1. and other minor closed families, there always exist separa- | | tors of size O(n1/2), and a recursive decomposition into sep- The certi®cate C( , ) for is constructed from 3/2 G H G arators can be found in time O(n ) [2]; the MST ( )( ) as follows: First, we assign all N G +∞ ∩ G of this step can be improved to O(n) for planar graphs [17]). uncertain edges their weights in , but the other edges As in the general graph sparsi®cation, we recursively are given a weight of . Then,G we repeatedly remove ∞ solve a problem in each subgraph, and construct a certi®cate from MST ( )( ) all degree-one vertices not in X. so that the overall MST can be found by combining the two Finally, asN longG as+∞ the remaining∩ G tree contains a degree-two subgraph certi®cates in a single kinetic problem. However, vertex that is not in X and that is adjacent to two edges with for this approach to work, the certi®cate must have size pro- weight , we remove that vertex by contracting one of portional to the number of vertices in the separator X, not to the adjacent∞ edges. the size of the whole subgraph. Suppose we are given two edge-disjoint subgraphs and Lemma 6. The edges in the minimum spanning tree of ; their union is the whole graph, and their (vertex) intersec-G are the disjoint union of three sets: the edges in H G ∪ H tion is a separator X. We describe how to ®nd a certi®cate MST ( )( ) , the edges in MST ( )( ) , N G ∞ ∩ G N H ∞ ∩ H C( , ) for . The certi®cate is a graph of size O( X ), ob- and the edges in the minimum spanning tree of C( , ) G H ∪ tainedG H by contractingG certain vertices and edges of| |. The C( , ). H G construction for is completely symmetric. Our construc-G H Lemma 7. If the weights of change as part of a para- tion works for static weights; we will describe later how to G make it kinetic. metric or functionally kinetic problem, C( , ) undergoes O(P ( )) structural changes. G H Without loss of generality (by inserting dummy edges of F |V| low weight, as described in more detail in a later section), Proof: This follows from the fact that the structure of we can assume that every vertex in has degree at most C( , ) is determined by the structure of the two minimum three. Let T be a forest formed by takingG a spanning forest spanningG H trees MST ( ) and MST ( ). Each of , removing all degree-one vertices not in X, and con- ( ) ( ) change to one of theseN G spanning+∞ trees causesN GO∞(1) changes tractingH all degree-two vertices not in X. Then T has at most to C( , ). 2 2 X 1 edges, and ( ) T is a minor of the over- G H all| graph.| We formN a parametricG = G ∪ problem by keeping the weights of edges in ®xed and assigning a weight function G 2.3. Separator-Based Sparsi®cation we() to the edges in T . Then in this parametric prob- = lem, MST ( )( ) is just the minimum spanning tree Lemma 8. Let be a minor-closed graph family. Suppose N G +∞ ∩ G of itself, as paths through T are too expensive to be useful that we have a dataF structure that can solve structurally ki- G for connecting nodes in G. Also, MST ( )( ) is a tree netic minimum spanning tree problems restricted to graphs N G ∞ formed by adding some of the the edges and vertices of T , in in time O( f (n)) per insertion, deletion, or topology F c while removing some edges from MST ( )( ) (we now change, where f (n) log n and P (n) f (n) (n ) N G +∞ F use all the cheap bypasses provided by T ). for some c > 1. Then we can solve functionally= kinetic or parametric problems on graphs in in time O(n3/2 F + Lemma 3. Any edge e in MST ( )( ) is an edge P (n) f (√n)).If contains only planar graphs, we can N G ∞ ∩ G in the minimum spanning tree of . solveF these problemsF in time O(P (n) f (√n)). G ∪ H F

Proof: We form a separator decomposition of the E graph. At each level of the decomposition, we have two subgraphs and the union of which is a sub- graph at the nextG higherH level. We maintain the four trees MST ( )( ), MST ( )( ), MST ( )( ), N G +∞ N H +∞ N G ∞ and MST ( )( ) described in the previous section, and the certi®cateN HC∞( , ) or C( , ) derived from those trees. Recall that the certi®catesG H areH obtainedG by contracting sub- trees of MSTN( )( ) and MSTN( )( ). In order to update the certi®catesG +∞ ef®ciently, weH maintain+∞ these con- F tracted subtrees using the dynamic-tree data structure by Sleator and Tarjan [27]. The two trees MST ( )( ) N G H Figure 1. Two sets of edges such that every pair of one edge from and MST ( ) can then be found from this∪ infor-+∞ ( ) each set forms a swap. mation togetherN G∪H with∞ the solution to two structurally kinetic problems on the graphs C( , ) C( , ) and C( , ) C( , ) T (where T isG a contractedH ∪ H treeG representingG H ∪ a subgraphH G ∪ at a higher level of the recursion, and has weights that do not vary). The resulting system of data structures contains two ki- netic problems at each level of the recursion, each of which undergoes a number of changes proportional to P (x) where x is the size of the subgraph. The overall time boundF therefore satis®es the recurrence

T (n) 2T (n/2) P (n) f (√n). = + F Figure 2. First non-positive swap: in line arrangement (left), right- 2 most point above lines from tree edges and below lines from non- tree edges; in dual point arrangement (right), line with highest slope above points from tree edges and below points from non-tree 3. Data Structures edges.

We have shown how to use sparsi®cation to speed up structurally kinetic minimum spanning tree data structures. form a swap, we set 1e, f () . That is, 1e, f () is the We now describe some techniques for constructing these amount by which the tree weight=+∞ would increase if the swap data structures. were performed. Given a value 0 and MST(0), our algo- As our kinetic or parametric algorithm progresses, the rithm will need to ®nd the ®rst value of 0 for which minimum spanning tree it maintains will change by swaps, 1e, f () 0, for some pair e, f . For a pair E, F , in which one edge is removed and another inserted. We ∈ E E where E MST(0) and F MST(0) , we de®ne begin by giving a geometric interpretation for these swaps. the next swap (or ®rst non-positive∩ swap) between=∅ E and F We then partition the vertices into clusters, and classify the to be the pair e E and f F so that 1e, f () 0 for swaps according to the inserted location of the endpoints ∈ ∈ some 0 and 1e , f () > 0 for all pairs e0 E, f F of the edge in the clusters, and show how to ®nd the next- 0 0 ∈ ∈ and for all 0 <. The pair of edges g E, h F occurring swap within each class. ∈ ∈ for which 1g,h(0) has the minimum value is called the best 3.1. Swaps, Duality, and Bitangents swap at 0. To help understand the problem of computing the next As our algorithm progresses, topology changes arising swap, we interpret swaps geometrically. Suppose we have from insertions and deletions of edges will be relatively easy a subset E of edges of a spanning tree of and a subset F to maintain. However, it will require work to locate topol- of edges not in the spanning tree, whereG every pair (e, f ) ogy changes arising from changes in relative ordering of of one edge from each set forms a swap (Figure 1). We can edge weights. For a given spanning tree T of and two form a line arrangement in the (, w) plane, where each line edges e, f , we say that e and f form a swapGif e T , is the graph of the weight function of a single edge. The ®rst f T , and∈ theE cycle induced by f in T contains the edge∈ e. non-positive swap can be found as the ®rst (leftmost) point For6∈ any ®xed value of , de®ne the weight of a swap (e, f ), in the arrangement where a line from F crosses below a line denoted 1e, f (),tobew f () we();ife and f do not from E; or, equivalently it is the last (rightmost) point that

lies on or below all lines from F and on or above all lines leading to the ®rst non-positive swap. Megiddo's para- from E (Figure 2). metric search [26] provides a general mechanism for turn- We apply a projective duality to this con®guration, in ing an algorithm for the former problem into an algorithm which each line w a b in the primal (, w) plane for the latter. is transformed into a= point (+ a, b) in the dual (x, y) plane, The parametric search method starts from two given al- and each point (, w) in the primal plane is transformed into gorithms: a decision oracle that determines if a given is a line y x w in the dual plane. This transforma- less or greater than , and a simulated algorithm that com- = + tion preserves point-line incidences and above-below rela- putes a function f () discontinuous at . The conditional tionships. The dual transform maps the graph of the weight branches of the simulated algorithm must depend only on of each edge e to a point. For a subset X , let SE de- low-degree in . Since the decision oracle is E note the set of such points corresponding to the edges in X. discontinuous at , it is common to use the same algo- In the dual plane, the ®rst non-positive swap corresponds to rithm in both roles. Parametric search then produces the se- the maximum-slope line that lies on or below all points in SF quences of steps the simulated algorithm would perform if and on or above all points in SE . Such a line is a bitangent it were given as its argument; each conditional branch to the lower convex hull of SF and the upper convex hull of is simulated by using the decision algorithm to compare SE (Figure 2(b)). with the roots of the tested at that branch. Be- Because of this connection between non-positive swaps cause of the simulated algorithm's discontinuity, we must and bitangents, we can apply computational geometry tech- eventually ®nd a root equal to . If the decision oracle niques in our solution of the parametric and kinetic mini- takes time TD, and the simulated algorithm is a parallel algo- mum spanning tree problems. If we are given a represen- rithm taking time TS with PS processors, we can test many tation of the two hulls above that supports binary searches, roots at once using binary search, giving an overall time of their bitangent can be found in O(log n) time. In the special O(TD TS log PS TS PS). Standard techniques for speeding case in which E or F consists of a single edge, we are sim- this up further include+ moving as much as possible out of the ply seeking a tangent through the corresponding dual point simulated algorithm, using partial results to speed up the de- to the convex hull of the points corresponding to the other cision oracle, and Cole's technique for avoiding the log PS set, and again this can be done in logarithmic time. factor by allowing a constant fraction of the simulated pro- cessors to fail to make progress at each step [6]. 3.2. Dynamic Convex Hull Data Structure 3.4. Restricted Partitions Because of the connection between swaps and hulls out- lined above, our algorithm will need to use some data struc- Our algorithms use a technique of partitioning trees and tures for maintaining convex hulls of point sets. The speci®c forests into smaller subtrees, or clusters of vertices, that was operations we need are point insertion and undo operations: introduced by Frederickson [15,16] and used by him and oth- an undo deletes the most recently inserted point remaining ers as part of various dynamic graph algorithms. We will in the data structure. combine this clustering technique with some geometric data Theorem 1. We can maintain the convex hull of a planar structures (primarily, planar convex hulls) in a manner sim- point set, subject to insertions and undo operations, in time ilar to techniques used in our previous paper on speedups in O(log n) per update or query. the network simplex method [10]. We ®rst transform our input graph into a new graph 0 G G Proof: We maintain a sorted list of the vertices on the hull with degree at most three, so any tree in 0 will be binary. using any of various balanced binary search tree data struc- Let v be any edge of degree 1>3; replaceG v by 1 2 tures. The time bound for queries then becomes immediate. vertices connected by a path. Path endpoints receive two To insert a point, we do two binary search queries to locate of the original edges of v, and each interior vertex receives its left and right tangents, split the sorted list of hull vertices one. Path edges are given a cost function that is a suf®ciently at those two points, and rejoin the left side of the left cut, small constant so that all path edges are always part of the the new vertex, and the right side of the right cut. We re- current minimum spanning tree. This transformed graph is tain pointers to the discarded subtrees so that undo opera- not hard to maintain as undergoes edge insertions or dele- tions can similarly be performed by O(1) split and join op- tions: each update in Gcauses a constant number of updates G erations. 2 to 0. Thus, for the remainder of the description of our ki- neticG algorithm, we assume our input graph has all vertex de- 3.3. Parametric Search grees at most three. The following de®nition is due to Frederickson [16]. In several cases of our algorithm it will prove easier to ®nd the best swap for a ®xed value of than to ®nd the value De®nition 1. A restricted partition of order z with respect

to a tree T in which all vertex degrees are at most three is a Proof: We need to detect whether the given value of partition of the vertices of V such that: is before or after the ®rst non-positive swap; equivalently, whether there exists a non-positive swap at itself. Since 1. Each set in the partition contains at most z vertices. a given spanning tree is the minimum only within a single 2. Each set in the partition induces a connected subtree of of values of , we perform this test by computing T . the values of all intra-cluster edges at the parameter value , and testing whether the given tree is still the minimum span- 3. For each set S in the partition, if S contains more than ning tree at that parameter using a minimum spanning tree one vertex, then there are at most two tree edges having veri®cation algorithm [8, 25]. 2 one endpoint in S.

4. No two sets can be combined and still satisfy the other Lemma 10. We can ®nd the ®rst non-positive intra-cluster conditions. swap in a cluster of O(z) vertices in O(z log z) time. We call each set in the partition a cluster. The endpoints Proof: We apply parametric search with the decision or- of an edge of T connecting two different clusters are called acle described above. For a simulated algorithm, we use terminal vertices. Each cluster has at most two terminal ver- sorting, since the sorted order is discontinuous at all swaps. tices. A cluster with k terminal vertices will be referred to Cole [6] shows how to apply parametric search to sorting as a k-terminal cluster. with O(log n) calls to the decision oracle and O(n log n) ad- Frederickson also showed that such a partition can easily ditive overhead. 2 be found in linear time. There are at most O(n/z) clusters in a restricted partition of an n-vertex tree. If we change the tree by performing a swap, we can update the restricted par- 3.6. Dual-Cluster Swaps tition in time O(z) by splitting and re-merging O(1) clus- ters [16]. To ®nd dual-cluster swaps, we combine the dynamic con- Given a restricted partition of the current minimum span- vex hull data structure described earlier with Frederickson's ning tree in a parametric or kinetic MST problem, we can idea of ambivalent data structures. Let C be a cluster in classify the potential swaps into three types according to a restricted partition. A non-tree edge whose one endpoint how many clusters are involved in the endpoints of the lies in C and the other does not lie in C is called an exter- swapped edges: nal edge of C. For each cluster C, we want to maintain the next dual swap that involves an external edge of C. Recall De®nition 2. Let edges e and f form a swap in a tree for that C has at most two terminal vertices. An external edge which we have a restricted partition, so that e is a tree edge of C incident upon a vertex u of C can swap only with an on the tree path between the endpoints of f . Then if both edge of C that lies on the path from u to a terminal vertex endpoints of f are in a single cluster, e must be in the same of C. For each such external edge and each terminal vertex cluster as f ; we call this an intra-cluster swap.Iff has end- v of C, we will therefore store the edge e on the path from points in different clusters, and e belongs to one of these two u to v for which w f () we() becomes zero ®rst. Let us clusters, we call this a dual-cluster swap. Finally, if the end- denote this edge by v( f ). Note that if v lies on the path points of f do not lie in the same cluster and e does not be- in the minimum spanning tree between the endpoints of f , long to one of these two clusters, we call this an inter-cluster then (v( f ), f ) forms a swap. swap. Lemma 11. Let 5 be a restricted partition of order z, and We next show how to maintain the next swap that can oc- let C be a newly formed cluster of 5. For all non-tree cur, for each of these three types of swap. edges f having exactly one endpoint in C and for each ter- 3.5. Intra-Cluster Swaps minal vertex v of C, we can compute v( f ) in total time O(z log z). To ®nd the ®rst non-positive intra-cluster swap in a given cluster, we apply parametric search. Recall that this requires Proof: Let v be a terminal vertex of C. We traverse the two subroutines: a decision oracle for comparing a given subtree contained in C, starting from v, and keep track of the edges on the path from the current vertex u to v. As out- parameter to the optimal value we are seeking, and a lined in Section 3.1 the weights of the edges in this path cor- simulated algorithm discontinuous at . respond to points in a plane, and we use the dynamic convex Lemma 9. A decision oracle for the ®rst non-positive hull data structure described in Theorem 1 to maintain the intra-cluster swap in a cluster of O(z) vertices can be im- convex hull of these points. When our traversal ®rst visits plemented in time O(z). an edge of the tree we insert the corresponding point into the

hull, and when we return from traversing an edge we per- C1, C2, respectively, that lie on the path connecting C1 to C2. form an undo operation to remove the point from the hull. We contract all non-tree edges between C1 and C2 to a sin- Then, as described in Section 3.1, for an external non-tree gle edge (v1,v2) whose weight is equal to the lightest weight edge f incident upon u, v( f ) can be found by computing among all the non-tree edges between C1 and C2. a tangent from the point corresponding to f 's weight func- tion to the current hull, in time O(log z). 2 Lemma 13. We can maintain a data structure in time O(z log z) per change to the restricted partition, so that for any , the graph 0() described above can be found in time G Lemma 12. As we dynamically maintain a restricted par- O(log n) per edge. tition of order z on a spanning tree of a dynamic m-vertex degree-three graph, we can maintain a data structure in time Proof: Suppose we maintain a restricted partition of order z of the minimum spanning tree of . We can maintain the O(z log z m/z) per update to the graph which will let us G query the+ ®rst non-positive dual-cluster swap in time O(1) convex hull of the points corresponding to the path connect- per pair of clusters. ing the two terminals of each two-terminal cluster, and of the points corresponding to the edges connecting each pair of clusters. The weight of each edge in 0 can be found in Proof: We store for each endpoint of each non-tree edge G the information described in Lemma 11. Since each update time O(log n) by binary search in the appropriate hull. 2 modi®es only O(1) clusters, we can recompute this infor- mation in O(z log z) per update, as described in that lemma. Lemma 14. The ®rst non-positive inter-cluster swap in For each cluster C, we partition the external edges in C into G is the ®rst non-positive swap in 0(). O(m/z) groups, so that all edges whose other endpoints lie G in the same cluster Ci C belong to the same group. For 6= Lemma 15. We can maintain a data structure in time each such group Fi and for each terminal vertex v of C,we O(z log z) per change to the restricted partition, such that store the pair v(Ci ) (v( f ), f ) for which w f w ( f ) = v if the graph 0() described above has m0 edges, the best becomes zero ®rst among all edges f Fi . This informa- G 2 inter-cluster swap can be found in time O(m0 log n). tion can be updated in time O(z) whenever∈ a cluster is modi- ®ed. We also store a lowest-common-ancestor data structure Proof: The structure we maintain is simply the set of hulls for the tree formed by contracting each cluster of the parti- described in Lemma 13. To ®nd the best swap, we apply tion; this takes time O(m/z) per update to maintain. a parametric search routine similar to the one described in Suppose we want to ®nd the next dual swap involving an Section 3.5. We modify the minimum spanning tree ver- external edge whose one endpoint lies in C1 and the other i®cation used as the decision oracle, to compute 0 and G in C2. We ®rst ®nd the terminal vertices v1,v2 of C1, C2, then verify that the contraction of the current spanning tree respectively, that connect the path from C1 to C2 in the min- is the true minimum spanning tree of 0; this takes time G imum spanning tree. This can be done in O(1) time using O(m0 log n) per oracle call. We also modify the simulated the lowest-common-ancestor data structure. It is easily seen algorithm, to compute G0 before sorting its edge weights; that v1 (C2) and v2 (C1) form swaps. Of these two, we re- the computation of 0 is just a collection of parallel bi- turn the one whose weight becomes zero ®rst. 2 nary searches and doesG not increase the overall complex- ity beyond its previous bound of O(log m0) oracle calls and O(m0 log m0) additive overhead. 2 3.7. Inter-Cluster Swaps With the use of randomization, we can reduce this bound We now need to show how to ®nd the ®rst non-positive slightly: inter-cluster swap. We ®rst describe a deterministic tech- nique based on the intra-cluster swap technique described in Lemma 16. We can maintain a data structure in time Section 3.5. O(z log z) per change to the restricted partition, such Recall that we will be maintaining a restricted partition of that if the graph 0() described above has m0 edges, order z of the minimum spanning tree of the graph. For any the best inter-clusterG swap can be found in expected time value of , consider forming the following contracted graph O(m0 log n). 0() from , with only O(m/z) vertices: Contract each 1- Gterminal cluster,G with the terminal vertex v, to a single node Proof: We perform two different cases, depending on v. Contract each 2-terminal cluster, with terminal vertices whether the contracted graph 0 is sparse or not. If it has at u,v, to an edge (u,v)whose weight is equal the weight of least as many non-tree edges asG tree edges, we choose ran- the heaviest edge on the path connecting u and v. Let C1, C2 domly a non-tree edge e of 0, ®nd the best swap involv- G be two clusters, and let v1 and v2 be the terminal vertices of ing that edge and one of the tree edges, and use this swap

to eliminate (in expectation) half the non-tree edges. Alter- 4.2. Planar and Minor-Closed Graph Families nately, if 0 has few non-tree edges, we choose a tree edge e randomly,G and use the best swap involving that edge to Our time bound becomes better for planar graphs or other eliminate in expectation half the tree edges. Repeating this minor-closed families of graphs, because the contracted graph 0 is sparse. process eventually leads to an empty graph, at which point G we return the best swap found in the process. We omit the Theorem 4. We can maintain a graph, having at most n details in this extended abstract. 2 vertices at any one time, belonging to some minor-closed family , and keep track of the structurally kinetic minimum F 1/2 3/2 4. Parametric and Kinetic MST Algorithms spanning tree, in total time O(pn log n). If we allow randomization the expected total time is O(pn1/2 log n). The data structures described in the preceeding sections Proof: Because the number of non-tree edges in let us ®nd the next non-positive swap of each type. We are 0 is O(n/z), the tradeoff above reduces to O(z log z G ready to put them together into our overall kinetic minimum (n/z) log2 z), or randomized O(z log z (n/z) log z). Set-+ spanning tree algorithm. ting z to n1/2 log1/2 n or n1/2 produces the+ stated bounds. 2 4.1. General Graphs Again, applying sparsi®cation leads to further improve- Theorem 2. We can maintain a graph, having at most ments. m linearly weighted edges at any one time, and keep track of the minimum spanning tree kinetically, in time Theorem 5. We can maintain a graph, having at most n O(pm2/3 log4/3 m), where p denotes the number of edge in- vertices at any one time, belonging to some minor-closed sertions, edge deletions, or minimum spanning tree topol- family F, and keep track of the parametric or function- 3/2 ogy changes. If we allow randomization the expected time ally kinetic minimum spanning tree, in total time O(n 1/4 3/2 + is O(pm2/3 log m). P(n)n log n). If we allow randomization the expected total time is O(n3/2 P(n)n1/4 log n). For planar graphs 3/2 + Proof: We apply the transformation described above to the O(n ) term can be removed from these bounds. make have degree at most three, which increases the num- 4/3 ber ofG nodes to O(m). Then we use the data structures de- With Dey's bound P(n) O(n ), our total time is worst-case bounded by O(n19=/12 log3/2 n), or randomized scribed above to keep track of the next non-positive swap, 19/12 in time O(z log z m/z (m/z)2 log2 z) per update. When expected time O(n log n). we encounter an edge+ insertion,+ we update these structures, and use them to test whether a non-positive swap exists at 5. Conclusions the time of insertion; if so we perform the swap. When we We have given deterministic and randomized algorithms encounter a deletion of a minimum spanning tree edge, we for solving the parametric and kinetic minimum spanning use our convex hull data structures to ®nd the best replace- tree problems for general graphs, and improvements for spe- ment edge in each group of edges connecting a pair of clus- cial families, such as minor-closed and planar graphs. The ters; there are O((m/z)2) such groups, so this step takes time mixture of graph-theoretic and geometric attributes is an es- O((m/z)2 log n). When we encounter a deletion of a non- pecially appealing aspect of this problem. tree edge we update our structures and continue. And, when It would be desirable to ®nd kinetic data structures for the next non-positive swap found after one update occurs be- maintaining the MST of a graph that do not require the heavy fore the next insertion or deletion operation, we again up- arsenal of tools we have used: sparsi®cation, both general date our structures and continue. Setting z m2/3 log1/3 n and separator-based, dynamic convex hulls, restricted parti- or m2/3 produces the bound above. 2 = tions, ambivalent data structures, and parametric search. We plan to work both on simplifying our methods and on im- We now apply sparsi®cation to further improve these proving our bounds. bounds.

Theorem 3. We can solve the kinetic minimum spanning tree problem in time O(K (n, m)n2/3 log4/3 n) or in random- ized expected time O(K (n, m)n2/3 log n). We can solve the parametric minimum spanning tree problem in time O(P(n, m)n2/3 log4/3 n) or in randomized expected time O(P(n, m)n2/3 log n).

References [15] G. N. Frederickson. Data structures for on-line updat- ing of minimum spanning trees. SIAM J. Computing, [1] P. K. Agarwal and M. Sharir. Algorithmic techniques 14 (1985), 781±798. for geometric optimization. In Computer Science To- [16] G. N. Frederickson. Ambivalent data structures for day: Recent Trends and Developments, Lecture Notes dynamic 2-edge-connectivity and k smallest spanning in Computer Science, vol. 100 (J. van Leeuwen, ed.), trees. SIAM J. Computing, 26 (1997), 484±538. Springer-Verlag, 1995. [17] M. T. Goodrich. Planar separators and parallel [2] N. Alon, P. Seymour, and R. Thomas. A separator the- triangulation. J. Computing & Systems Sciences,51 orem for graphs with an excluded minor and its appli- (1995), 374±389. cations. In Proc. 22nd ACM Symp. Theory of Comput- ing, 1990, 293±299. [18] R. L. Graham and P. Hell. On the history of the min- imum spanning tree problem. Ann. Hist. Comput., [3] J. Basch, L. J. Guibas, and J. Hershberger., pp. 293± 7 (1985), 43±57. 299 Data structures for mobile data. In Proc. 8th ACM- SIAM Symp. Discrete Algorithms, 1997, 747±756. [19] L. J. Guibas. Kinetic data structures Ð a state of the art report. To appear in Proc. 3rd Worksh. Algorithmic [4] J. Basch, L. J. Guibas, and L. Zhang. Proximity prob- Foundations of Robotics, 1998. lems on moving points. In Proc. 13th ACM Symp. Computational Geometry, 1997, 344±351. [20] M. R. Henzinger and V. King. Maintaining minimum spanning trees in dynamic graphs. In Proc. 24th Int. [5] B. Chazelle. A faster deterministic algorithm for mini- Coll. Automata, Languages and Programming, Lec- mum spanning trees. In Proc. 38th Symp. Foundations ture Notes in Computer Science, vol. 1256, Springer- of Computer Science, 1997, 22±31. Verlag, 1997, 594±604. [6] R. Cole. Slowing down sorting networks to obtain [21] J. Holm, K. de Lichtenberg, and M. Thorup. Poly- faster sorting algorithms. J. ACM, 34 (1987), 200±208. logarithmic deterministic fully-dynamic algorithms [7] T. K. Dey. Improved bounds on planar k-sets for connectivity and minimum spanning tree. In Proc. and k-levels. Discrete & Computational Geometry. 30th ACM Symp. Theory of Computing, 1998, 79±89. 19 (1998), 373±382. [22] D. Karger, P. N. Klein, and R. E. Tarjan. A random- [8] B. Dixon, M. Rauch, and R. E. Tarjan. Veri®cation and ized linear-time algorithm for ®nding minimum span- sensitivity analysis of minimum spanning trees in lin- ning trees. J. ACM, 42 (1995), 321±329. ear time. SIAM J. Computing, 21 (1992), 1184±1192. [23] N. Katoh. Parametric combinatorial optimization [9] D. Eppstein. Geometric lower bounds for parametric problems and applications. J. Inst. Electronics, In- matroid optimization. To appear in Discrete & Com- formation and Communication Engineers, 74 (1991), putational Geometry. 949±956. [10] D. Eppstein. Clustering for faster network simplex [24] N. Katoh. Bicriteria network optimization problems. pivots. In Proc. 5th ACM-SIAM Symp. Discrete Algo- IEICE Trans. Fundamentals of Electronics, Communi- rithms, 1994, 160±166. cations and Computer Sciences, E75-A (1992), 321± 329. [11] D. Eppstein, Z. Galil, G. F. Italiano, and A. Nis- senzweig. Sparsi®cation Ð A technique for speed- [25] V. King. A simpler minimum spanning tree veri®ca- ing up dynamic graph algorithms. J. ACM, 44 (1997), tion algorithm. In Proc. 4th Worksh. Algorithms and 669±696. Data Structures, Lecture Notes in Computer Science, vol. 955, Springer-Verlag, 1995, 440±448. [12] D. Eppstein, Z. Galil, G. F. Italiano, and T. H. Spencer. Separator based sparsi®cation I: planarity testing and [26] N. Megiddo. Applying parallel computation algo- minimum spanning trees. J. Computing & Systems Sci- rithms in the design of sequential algorithms. J. ACM, ences, 52 (1996), 3±27. 30 (1983), 852±865. [13] D. Fernandez-Baca and G. Slutzki. Parametric prob- [27] D. D. Sleator and R. E. Tarjan. A data structure for lems on graphs of bounded tree-width. J. Algorithms, dynamic trees. J. Computer and System Sciences, 16 (1994), 408±430. 26 (1983), 362±391. [14] D. Fernandez-Baca, G. Slutzki, and D. Eppstein. Us- [28] N. E. Young, R. E. Tarjan, and J. B. Orlin. Faster para- ing sparsi®cation for parametric minimum spanning metric shortest path and minimum-balance algorithms. tree problems. Nordic J. Computing, 3 (1996), 352± Networks, 21 (1991), 205±221. 366.