Kinetic Data Structures for the Semi-Yao Graph and All Nearest Neighbors in R^d
Zahed Rahmati, Mohammad Ali Abam, Valerie King, Sue Whitesides
aa r X i v : . [ c s . C G ] N ov Kinetic Data Structures for the Semi-Yao Graphand All Nearest Neighbors in R d Zahed Rahmati , Mohammad Ali Abam , Valerie King , and Sue Whitesides Dept. of Computer Science, University of Victoria, Canada. { rahmati,val,sue } @uvic.ca Dept. of Computer Engineering, Sharif University of Technology, Iran. [email protected]
Abstract.
This paper presents a simple kinetic data structure for maintaining all the nearest neighborsof a set of n moving points in R d , where the trajectory of each point is an algebraic function of at mostconstant degree s . The approach is based on maintaining the edges of the Semi-Yao graph, a sparsegraph whose edge set includes the pairs of nearest neighbors as a subset.Our kinetic data structure (KDS) for maintaining all the nearest neighbors is deterministic. It processes O ( n β s +2 ( n ) log n ) events with a total cost of O ( n β s +2 ( n ) log d +1 n ). Here, β s ( n ) is an extremely slow-growing function. The best previous KDS for all the nearest neighbors in R d is by Agarwal, Kaplan,and Sharir (TALG 2008). It is a randomized result. Our structure and analysis are simpler than theirs.Also, we improve their result by a factor of log d n in the number of events and by a log n factor in thetotal cost.This paper generalizes and improves the 2013 work of Rahmati, King and Whitesides (SoCG 2013)on maintaining the Semi-Yao graph in R ; its new technique provides the first KDS for the Semi-Yaograph in R d . Our KDS is local in the worst case, meaning that only a constant number of events isassociated with any one point at any time.For maintaining all the nearest neighbors, neither our KDS nor the KDS by Agarwal et al. is local,and furthermore, each event in our KDS and in their KDS is handled in polylogarithmic time in anamortized sense.Finally, in this paper, we also give a KDS for maintenance of all the (1 + ǫ )-nearest neighbors which islocal and each event can be handled in a polylogarithmic worst-case time. Keywords: kinetic data structure, all nearest neighbors, Semi-Yao graph (theta graph), range tree,closest pair, R d Introduction
Let P be a set of n points in R d . Finding the nearest neighbor to a query point, which was called the post office problem by Donald Knuth in 1973 [18], is fundamental in computational geometry. The all nearest neighbors problem, a variant of the post office problem, is to find the nearest neighbor toeach point p ∈ P . Given any ǫ >
0, the all (1 + ǫ ) -nearest neighbors problem is to find some ˆ q ∈ P for each point p ∈ P , such that the Euclidean distance | p ˆ q | between p and ˆ q is within a factor of(1 + ǫ ) of the Euclidean distance between p and its nearest neighbor. The nearest neighbor graph isconstructed by connecting each point p ∈ P to its nearest neighbor. The closest pair problem is tofind the endpoints of the edge in the nearest neighbor graph with minimum length. The Semi-Yaograph (or theta-graph ) is a too long-well-studied sparse proximity graph [14,17]. This graph can beconstructed by partitioning the space around each point p ∈ P into c cones C l ( p ), 1 ≤ l ≤ c , with p the shared apex of the cones, and then connecting the point p to a point q inside each of thesecones, such that the point q ∈ P ∩ C l ( p ) has the minimum length projection on the vector in thedirection of the symmetry C l ( p ); see Figure 1(b). By treating the number c of cones at each pointas a parameter of the Semi-Yao graph, one obtains an important class of sparse graphs, t-spanners ,with different stretch factors t [7,11,12,13].The maintenance of attributes (e.g., the closest pair) of sets of moving points has been studiedextensively over the past 15 years [3,4,6,8,16,21,22,23]. A basic framework for this study is that ofa kinetic data structure (KDS), which is in fact a set of data structures and algorithms to track theattributes of moving points. The problem of maintaining all the nearest neighbors, the closest pair,and the Semi-Yao graph on moving points are called the kinetic all nearest neighbors problem, the kinetic closest pair problem, and the kinetic Semi-Yao graph , respectively.The kinetic maintenance of attributes is generally considered in two models: the standard KDSmodel and the black-box KDS model [15,10]. In the black-box model, the locations of the objectsare received at regular time steps. In the standard model, each object has a flight plan known inadvance, and during the motion the object can change its flight plan at some times which are notknown in advance. This paper considers the all nearest neighbors problem and the Semi-Yao graphin R d for the standard KDS model and improves previous results; see Table 1 in Appendix A. Inaddition, it offers results on all (1 + ǫ )-nearest neighbors in R d . Standard KDS framework.
Basch, Guibas, and Hershberger [8] introduced a kinetic data struc-ture framework to maintain the attributes of moving points in the standard KDS model. In thisframework we assume each point p ∈ P is moving with a trajectory in R d , where the d coordinatesof the trajectory of the point p , which determine the position of p as a function of time, are d algebraic functions of at most constant degree s .The correctness of an attribute over time is determined based on correctness of a set of cer-tificates . A certificate is a boolean function of time, and its failure time is the next time after thecurrent time at which the certificate will become invalid. When a certificate fails, we say that an event occurs. Using a priority queue of the failure times of the certificates, we can know the nexttime after the current time that an event occurs. When the failure time of the certificate withhighest priority in the priority queue is equal to the current time we invoke the update mechanismto reorganize the data structures and replace the invalid certificates with new valid ones.To analyse the performance of a KDS there are four standard criteria. A KDS distinguishesbetween two types of events: external events and internal events . An event that changes the desiredattribute itself is called an external event and those events that cause only some internal changesin the data structures are called internal events. If the ratio between the total number of eventsand the number of external events is O (polylog( n )), the KDS is efficient . The efficiency of the KDSgives an intuition of how many more events the KDS processes. If response time of the update1echanism to an event is O (polylog( n )), the KDS is responsive . The compactness of a KDS refersto space complexity: if the KDS uses O ( n. polylog( n )) space, it is compact . The KDS is local if thenumber of events associated with any point in the KDS is O (polylog( n )). The locality of the KDSis an important criterion; if a KDS satisfies locality, the KDS can be updated quickly and efficientlywhen an object changes its flight plan (trajectory) at times. Related work.
Basch, Guibas, and Hershberger (SODA’97) [8] provided a KDS for maintenanceof the closest pair in R . Their KDS uses linear space and processes O ( n β s +2 ( n ) log n ) events,each in time O (log n ). Here, β s ( n ) = λ s ( n ) n is an extremely slow-growing function and λ s ( n ) is themaximum length of Davenport-Schinzel sequences of order s on n symbols.A common way to maintain attributes of moving points in R d is to use kinetic multidimensionalrange trees [9,5,2]. Basch et al. [9] and Agarwal et al. [5] use dynamic balanced trees to implementa kinetic range tree. Using rebalancing operations, they handle events to maintain a range tree. Inparticular, in their approaches, when an event between two points p and q occurs, we must delete p and q and reinsert them into the range tree. The range tree can be maintained over time usinga dynamic range tree. One of the approaches to update the range trees is to carry out local andglobal rebuilding after a few operations, which gives O (log d n ) amortized time per operation [19].Another approach, which uses merge and split operations, gives worst-case time O (log d n ) peroperation [25]. To avoid rebalancing the range tree after each operation, Abam and de Berg [1]introduced a variant of the range trees, a rank-based range tree (RBRT), which gives worst-casetime O (log d n ) per operation.Basch, Guibas, and Zhang (SoCG’97) [9] used multidimensional range trees to maintain the clos-est pair. For a fixed dimension d , their KDS uses O ( n log d − n ) space and processes O ( n β s +2 ( n ) log n )events, each in worst-case time O (log d n ). Their KDS is responsive, efficient, compact, and local.Agarwal, Kaplan, and Sharir (TALG’08) [5] gave KDS’s for both maintenance of the closestpair and all the nearest neighbors in R d . Agarwal et al. claimed that their closest pair KDS sim-plifies the certificates used by Basch, Guibas, and Hershberger [8]; perhaps Agarwal et al. werenot aware of the paper by Basch, Guibas, and Zhang [9], which independently presented a KDSfor maintenance of the closest pair with the same approach to [9]. The closest pair KDS by Agar-wal et al. , which supports insertions and deletions of points, uses O ( n log d − n ) space and processes O ( n β s +2 ( n ) log n ) events, each in amortized time O (log d n ); this KDS is efficient, responsive (inan amortized sense), local, and compact. Agarwal et al. gave the first efficient KDS to maintainall the nearest neighbors in R d . For the efficiency of their KDS, they implemented multidimen-sional range trees by using randomized search trees (treaps). Their randomized kinetic approachuses O ( n log d n ) space and processes O ( n β s +2 ( n ) log d +1 n ) events; the expected time to process allevents is O ( n β s +2 ( n ) log d +2 n ). On average, each point in their KDS participates in O (log d n ) cer-tificates. Their all nearest neighbors KDS is efficient, responsive (in an amortized sense), compact,but in general is not local.Rahmati, King, and Whitesides (SoCG’13) [20] gave the first KDS for maintenance of the Semi-Yao graph in R . Their Semi-Yao graph KDS uses linear space and processes O ( n β s +2 ( n )) eventswith total processing time O ( n β s +2 ( n ) log n ). Using the kinetic Semi-Yao graph, they improvedthe previous KDS by Agarwal et al. to maintain all the nearest neighbors in R . In particular,their deterministic kinetic algorithm, which is also arguably simpler than the randomized kineticalgorithm by Agarwal et al. , uses O ( n ) space and processes O ( n β s +2 ( n ) log n ) events with totalprocessing time O ( n β s +2 ( n ) log n ). With the same complexity as their KDS for maintenanceof all the nearest neighbors, they maintain the closest pair over time. On average, each point intheir KDS’s participates in a constant number of certificates. Their kinetic data structures formaintenance of the Semi-Yao graph, all the nearest neighbors, and the closest pair are efficient,2esponsive (in an amortized sense), compact, but in general are not local. Our technique and improvements.
We provide a simple, deterministic KDS for maintenance ofboth the Semi-Yao graph and all the nearest neighbors in R d . Assuming d is fixed, we maintain theSemi-Yao graph in R d using a constant number of range trees. Our KDS generalizes the previousKDS for the Semi-Yao graph by Rahmati et al. [20] that only works in R . Also, our kinetic approachyields improvements of the KDS for maintenance of the Semi-Yao graph by Rahmati et al. [20] (seeTable 1 in Appendix A): Our KDS is local, but their KDS is not. In particular, each point in ourKDS participates in O (1) certificates, but in their KDS each point participates in O ( n ) events.For any fixed dimension d , our KDS handles O ( n ) events, but their KDS handles O ( n β s +2 ( n ))events in R .Our KDS for maintenance of all the nearest neighbors is based on the fact that the Semi-Yaograph is a supergraph of the nearest neighbor graph. For each point p in the Semi-Yao graph weconstruct a tournament tree to maintain the edge with minimum length among the edges incidentto the point p . Summing over elements of all the tournament trees in our KDS is linear in n , whichleads to a total number of events O ( n β s +2 ( n ) log n ), which is independent of d . This improves theprevious randomized kinetic algorithm by Agarwal et al. [5]: The expected total size of the tour-nament trees in their KDS is O ( n β s +2 ( n ) log d n ); so their KDS processes O ( n β s +2 ( n ) log d +1 n )events, which depends on d . Also, the structure and analysis by Agarwal et al. are more complexthan ours. Our results.
For a set of n moving points in R d , we present simple KDS’s to maintain the Semi-Yaograph and all the nearest neighbors. We assume the trajectory of each point is an algebraic functionof at most constant degree s . Our KDS for maintenance of the Semi-Yao graph uses O ( n log d n )space and processes O ( n ) events with total processing time O ( n β s +2 ( n ) log d +1 n ). The KDS iscompact, efficient, responsive (in an amortized sense), and it is local.Our all the nearest neighbors KDS uses O ( n log d n ) space and processes O ( n β s +2 ( n ) log n ))events with total processing time O ( n β s +2 ( n ) log d +1 n ). It is compact, efficient, responsive (in anamortized sense), but it is not local in general. To satisfy the locality criterion and to get a worst-case processing time KDS, we show a KDS for maintenance of all the (1 + ǫ )-nearest neighbors. Inparticular, for each point p we maintain some point ˆ q such that | p ˆ q | < (1 + ǫ ) . | pq | , where q is thenearest neighbor of p and | pq | is the Euclidean distance between p and q . This KDS uses O ( n log d n )space, and handles O ( n log d n ) events, each in worst-case time O (log d n log log n ); it is compact,efficient, responsive, and local. Paper organization.
Section 2 describes the construction of the Semi-Yao graph and gives asolution to the all nearest neighbors problem in R d . In Section 3, we show how the Semi-Yao graphcan be maintained kinetically. Using the kinetic Semi-Yao graph, we give a KDS for maintenanceof all the nearest neighbors in Section 4. Section 5 shows how to maintain all the (1 + ǫ )-nearestneighbors. In the following we describe the construction of the Semi-Yao graph and construction of all thenearest neighbors, which will aid in understanding how our kinetic approach works.Let −→ v be a unit vector in R d with apex at the origin o , and let θ be a constant. We define the infinite right circular cone with respect to −→ v and θ to be the set of points x ∈ R d such that theangle between −→ ox and −→ v is at most θ/
2. A polyhedral cone inscribed in this infinite right circularcone is formed by intersection of d distinct half-spaces such that all the half-spaces contain the3 p q (a) (b) (c) u u o x l f f p C l ( p )¯ C l ( p ) C l θ/ o u u x l + − x l o Fig. 1: (a) The cone C l and its translated copy with apex at p . (b) The point p is connected to the point in P ∩ C l ( p )that has minimum x l -coordinate. The dotted lines are orthogonal to the cone axes. (c) The point p is the nearestneighbor to q and, so q has the minimum x l -coordinate among the points in P ∩ C l ( p ). origin o . The angle between any two rays inside the polyhedral cone emanating from o is at most θ .The d -dimensional space around the origin o can be covered by a collection of disjoint polyhedralcones C , ..., C c , where c = O (1 /θ d − ) [5,1]. Denote by x l the vector in the direction of the unitvector −→ v of C l , 1 ≤ l ≤ c , with the origin at o . Let C l ( p ) denote a translated copy of C l with apexat p ; see Figure 1(a). From now on, we assume d is arbitrary but fixed, so c is constant.Given a point set P in R d , the Semi-Yao graph is constructed by connecting each point p ∈ P tothe point in P ∩ C l ( p ), 1 ≤ l ≤ c , whose x l -coordinate is minimum. Figure 1(b) depicts some edgesincident to the point p in the Semi-Yao graph in R where θ = π/
3; here x = − x , x = − x , and x = − x .The following lemma is used in [8,5,20] to maintain the closest pair and all the nearest neighborsfor a set P of moving points; see Figure 1(c). Lemma 1. (Lemma 8.1. [5])
Let p be the nearest point to q and let C l ( p ) be a cone of openingangle θ ≤ π/ that contains q . Then q has the minimum x l -coordinate among the points in P ∩ C l ( p ) . For a set of points in the plane, Rahmati et al. [20] used Lemma 1 to show that the Semi-Yao graphis a super-graph of the nearest neighbor graph. It is easy to see the same result for a set of pointsin higher dimensions.
Lemma 2.
The Semi-Yao graph of a set of points in R d is a super-graph of the nearest neighborgraph.Proof. Let ( p, q ) be an edge in the nearest neighbor graph such that p is the nearest neighbor to q . The point q is in some cone C l ( p ). Following the restriction θ ≤ π/ C l ( p ) and fromLemma 1, the point q has minimum length projection on x l among the points in P ∩ C l ( p ); thismeans that ( p, q ) is an edge of the Semi-Yao graph. For a fixed dimension d , there is a constant number of cones C l . Denote by f , ..., f d the boundinghalf-spaces of the cone C l and let u i be the coordinate axis orthogonal to f i , 1 ≤ i ≤ d ; Figure 1(a)depicts u and u of the half-spaces f and f of the cone C l . Corresponding to each cone C l , weconstruct a ranked-based range tree (RBRT) T l [1], which describes as follows, and for each point p in T l , we find the point in P ∩ C l ( p ) whose x l -coordinate is minimum; this gives a constructionfor the Semi-Yao graph. Ranked-based range tree.
The RBRT T l is a variant of the range trees which has the followingproperty. When two points exchange their order along an axis u i , the RBRT can be updatedwithout rebalancing the subtrees. The points at the level i of the RBRT T l are sorted at the leavesin ascending order according to their u i -coordinates. The skeleton of a RBRT is independent of the4osition of the points in R d and it depends on the ranks of the points in each of the u i -coordinates.The rank of a point in a tree at level i of the RBRT is its position in the sorted list of all the pointsaccording to their u i -coordinates. Any tree at any level of the RBRT is a balanced binary tree andno matter how many points are in the tree, it is a tree on n ranks [1].Let v be an internal node at level d of the RBRT T l . Denote by R ( v ) the set of points at theleaves of the subtree rooted at v . The set P ∩ C l ( p ) is the union of O (log d n ) sets R ( . ); all of these O (log d n ) sets can be reported in time O (log d n + k ), where k is the cardinality of P ∩ C l ( p ).Corresponding to each node v at level d of T l we define another set B ( v ). Denote by P p thepath from the parent of p to the root of a tree at level d of T l . A point p belongs to B ( v ) if v isthe right child of some node ¯ v ∈ P p ; a point p is in B ( v ) if R ( v ) is one of the O (log d n ) sets whilereporting the points of P ∩ C l ( p ).Let ¯ C l ( p ) = − C l ( p ) be the reflection of C l ( p ) through p ; ¯ C l ( p ) is formed by following the linesthrough p in the half-spaces of C l ( p ); see Figure 1(a). Similar to the way that we report the pointsof P inside a query cone C l ( q ), we can also report the points of P inside a query cone ¯ C l ( q ). Theset P ∩ ¯ C l ( q ) = ∪ v B ( v ), where the nodes v are on the paths P q .The set of all the pairs ( B ( v ) , R ( v )), for all of the internal nodes v at level d of T l , is calleda cone separated pair decomposition (CSPD) for P with respect to C l ; denote this set by Ψ C l = { ( B , R ) , ..., ( B m , R m ) } . The CSPD Ψ C l for P with respect to C l has the following properties [1]: – For the two points p ∈ P and q ∈ P , where q ∈ C l ( p ), there exists a unique pair ( B i , R i ) ∈ Ψ C l such that p ∈ B i and q ∈ R i . – For the pair ( B i , R i ) ∈ Ψ C l , if p ∈ B i and q ∈ R i , then q ∈ C l ( p ) and p ∈ ¯ C l ( q ).Let r ( v ) be the point with minimum x l -coordinate among the points in R ( v ). Denote by lc ( v ) and rc ( v ) the left and the right child of the node v , respectively. For each node v , the value of r ( v )is generated from the values of it children, r ( lc ( v )) and r ( rc ( v )); one which stores the point withminimum x l -coordinate. So, for all internal nodes v at level d of the RBRT T l , we can find all ofthe r ( v ) in O ( n log d − n ) time. Since for each point p ∈ P the point with minimum x l -coordinatein P ∩ C l ( p ) is chosen among O (log d n ) points r ( . ), the following lemma results. Lemma 3.
The Semi-Yao graph of a set of n points in R d can be constructed in time O ( n log d n ) . Vaidya [24] gave an O ( n log n ) time algorithm to solve the all nearest neighbors problem. Giventhe Semi-Yao graph in R d , by examining the edges incident to any point in the Semi-Yao graph,we can find the nearest neighbor to the point. Since the Semi-Yao graph has O ( n ) edges, we canget the following. Lemma 4.
Given the Semi-Yao graph, the all nearest neighbors problem in R d can be solved in O ( n ) time. Fix a cone C l and the corresponding coordinates u , ..., u d , and x l . When the points are moving,the Semi-Yao graph remains unchanged as long as the order of the points in each of the coordinates u , ..., u d , and x l remains unchanged. To maintain the Semi-Yao graph over time, we distinguishbetween two types of events: – u -swap event: Such an event occurs if two points exchange their order in the u i -coordinate. Thisevent can change the structure of the range tree. – x -swap event: This event occurs if two points exchange their order in the x l -coordinate. Therange tree structure remains unchanged when this event occurs.5o track the above changes, we maintain sorted lists L ( u ) , ..., L ( u d ), and L ( x l ) of the points in eachof the coordinates u , ..., u d , and x l , respectively. For each two consecutive points in each sortedlist L ( u i ) we define a certificate that certifies the order of the two points in the u i -coordinate. Totrack the closest time to the current time we put failure times of all of the certificates in a priorityqueue; the element with the highest priority in the queue gives the closest time.Our Semi-Yao graph KDS is based on maintenance of the RBRT T l . Abam and de Berg describehow to maintain a RBRT. Their approach uses O ( n log d n ) space, and a u -swap event can be handledin the worst-case time O (log d n ) without rebalancing the subtrees of the RBRT [1].For the point w ∈ P , the set P ∩ C l ( w ) = S j = kj =1 R ( v j ) where the nodes v j are the right child nodesof the nodes on the paths P w . Denote by ¨ w l the point in P ∩ C l ( w ) with minimum x l -coordinate.To maintain the Semi-Yao graph, for each point w ∈ P we must track ¨ w l which in fact is the pointin { r ( v ) , ..., r ( v k ) } whose x l -coordinate is minimum. To apply changes to the ¨ w l , for all w ∈ P ,besides r ( v ), we need to maintain more information at each internal node v at level d of the RBRT T l that describes as follows.Allocate an id to each point in P . Let B ′ ( v ) = { ( w, ¨ w l ) | w ∈ B ( v ) } and let L ( B ′ ( v )) be a sortedlist of the pairs of B ′ ( v ) according to the ids of the second components ¨ w of the pairs ( w, ¨ w l ). Thissorted list is used to answer the following query while processing x -swap events: Given a query point p , find all the points w ∈ B ( v ) such that ¨ w l = p . Since we have insertions/deletions into the sortedlists L ( B ′ ( . )) over time, we implement them using a dynamic binary search tree ( e.g. , a red-blacktree ); each insertion/deletion operation is performed in worst-case time O (log n ). Furthermore, wemaintain a set of links between each point w ∈ P and the pair ( w, ¨ w l ) in the sorted lists L ( B ′ ( . ))where w ∈ B ( . ); denote this set by Link ( w ). Since, the point w is in at most O (log d n ) sets B ( . ),the cardinality of the set Link ( w ) is O (log d n ).In the preprocessing step before the motion, for any internal node v at level d of the RBRT andfor any point w ∈ P , we find r ( v ) and ¨ w l and then, we construct L ( B ′ ( v )) and Link ( w ).Now, let the points move. The following shows how to maintain and reorganize Link ( . ), L ( B ′ ( . ))and r ( . ) when a u -swap event or an x -swap event occurs. Note that maintenance of the sets Link ( w ),for all w ∈ P , gives a kinetic maintenance of the Semi-Yao graph. p qw w w w Fig. 2: A u -swap between p and q does notchange the points in other cones C l ( w i ). u -swap event. When two points p and q exchangetheir order in the u i -coordinate, we swap them in thesorted list L ( u i ) and update the invalid certificates withnew valid ones; applying a constant number of changes tothe priority queue takes O (log n ) time. Then, we delete p and q and reinsert them into the RBRT with their newranks [1]. Next, we update the values r ( v ) where the nodes v are ancestors of p and q . A change to some r ( v ) can onlychange r ( v par ) where v par is the parent of v . So, theseupdates can easily be done in O (log d n ) time.Let q ∈ C l ( p ) (resp. q / ∈ C l ( p )) before the event. Afteroccurring the event, q moves outside (resp. inside) thecone C l ( p ); see Figure 2. Note that this event does not change the points in cones C l ( w ) of otherpoints w ∈ P . Therefore, the only change that can happen to the Semi-Yao graph is deleting anedge incident to p inside the cone C l ( p ) and adding a new one.We perform the following steps when such event occurs. We first delete the pairs ( p, ¨ p l ) ofthe sorted lists L ( B ′ ( . )) where p ∈ B ( . ); by using the links in Link ( p ), this can be done in time O (log d +1 ). Then, we delete the members of Link ( p ). Next, we find the point ¨ p l in P ∩ C l ( p ) whose x l -coordinate is minimum. Recall that v j , j = 1 , ..., O (log d n ), are the right child nodes of the nodes6n the paths P p . Since we might get a new value for ¨ p l among all of the r ( v j ), we must add thenew pair ( p, ¨ p l ), according to the id of the new value of ¨ p l , into all the sorted lists L ( B ′ ( v j )) where p ∈ B ( v j ). Finally, we construct Link ( p ) of the new links between p and the pair ( p, ¨ p l ) of thesorted lists L ( B ′ ( v j )) which takes O (log d +1 n ) time.Since the number of swaps between the points in the sorted lists L ( u i ), 1 ≤ i ≤ d , is O ( n ), thefollowing results. Lemma 5.
For maintenance of the Semi-Yao graph, our KDS handles O ( n ) u -swap events, eachin the worst-case time O (log d +1 n ) . x -swap event. Let p and q be two consecutive points with p preceding q in the sorted list L ( x l ): x l ( p ) < x l ( q ) before the event. When p and q exchange their order, we swap them in L ( x l ) andupdate the invalid certificates with new valid ones, which takes O (log n ) time. This event does notchange the structure of the RBRT T l ; but it might change the second components of the pairs insome sorted lists L ( B ′ ( . )) and if so, we must apply the changes to the Semi-Yao graph. p qw x l w pw q (a) (b) R i R i R j o x l o Fig. 3:
Two cases when an x -swap between p and q occurs. The number of all changes to the Semi-Yao graph de-pends on how many points w ∈ P have both of p and q intheir cones C l ( w ). While reporting the points in P ∩ C l ( w ),such points w can have both of p and q in the same set R i (Figure 3(a)) or in two different sets R i and R j (Fig-ure 3(b)). To find such points w , ( i ) we seek internal nodes v pq at level d of T l where { p, q } ⊆ R ( v pq ), which meansthat the nodes v pq are common ancestors of p and q , ( ii )we seek for internal nodes v p and v q where p ∈ R ( v p ) and q ∈ R ( v q ). In the first case, it is obvious that we mustfind any point w ∈ B ( v pq ) such that p is the point withminimum x l -coordinate in the cone C l ( w ), meaning that ¨ w l = p . Then, we replace p by q after theevent ( ¨ w l = q ). This means that we replace the edge wp of the Semi-Yao graph with wq .Note that in the second case there is no point w ′ ∈ B ( v p ) such that ¨ w ′ l = q , because x l ( p ) For maintenance of the Semi-Yao graph, our KDS handles O ( n ) x -swap events withtotal processing time O ( n β s +2 ( n ) log d +1 n ) . roof. All of the internal nodes v at Step 1 can be found in O (log d n ) time.For each internal node v of Step 2, the update mechanism spends O (log n + k v ) time where k v is the number of all the pairs ( w, ¨ w l ) ∈ B ′ ( v ) such that ¨ w l = p . For all of the internal nodes v ,the second step takes O (log d +1 n + P v k v ) time. Note that P v k v is equal to the number of exactchanges to the Semi-Yao graph. Since, the number of changes to the Semi-Yao graph of a set of n moving points in a fixed dimension d is O ( n β s +2 ( n )) [20], the total processing time of Step 2 forall of the O ( n ) x -swap events is O ( n log d +1 n + n β s +2 ( n )) = O ( n log d +1 n ).The processing time to apply changes to the KDS for each w of Step 3, which in fact is a changeto the Semi-Yao graph, is O (log d +1 n ). So, the update mechanism spends O ( n β s +2 ( n ) log d +1 n )time to handle all of the O ( n ) events.Hence, the total processing time for all the x -swap events is O ( n β s +2 ( n ) log d +1 n ). The following summarizes the complexity of our Semi-Yao graph KDS. Theorem 1. Our KDS for maintenance of the Semi-Yao graph of a set of n moving points in R d , where the trajectory of each point is an algebraic function of at most constant degree s , uses O ( n log d n ) space and handles O ( n ) events with a total cost of O ( n β s +2 ( n ) log d +1 n ) . The KDSis compact, efficient, responsive (in an amortized sense), and local.Proof. From Lemmas 5 and 6, all of the O ( n ) events can be processed in time O ( n β s +2 ( n ) log d +1 n );this means that the KDS is responsive in an amortized sense. P v | B ( v ) | = O ( n log d n ) and the num-ber of the certificates is O ( n ); so, the KDS is compact. A particular point in a sorted list L ( u i )participates in two certificates, one certificate is created with previous point and one with the nextpoint. So, the number of events associated to a particular point is O (1) which means the KDS islocal. Since the number of the external events is O ( n β s +2 ( n )) and the number of the events thatthe KDS processes is O ( n ), the KDS is efficient. Given the kinetic Semi-Yao graph, a super-graph of the nearest neighbor graph over time, fromSection 3, we can easily maintain the nearest neighbor to each point p ∈ P . Let Inc ( p ) be the set ofedges in the Semi-Yao graph incident to the point p . Using a dynamic and kinetic tournament tree (DKTT) [5,8], we can maintain the nearest neighbor to p over time. Denote by T T p the DKTTcorresponding to the point p . The elements of T T p are the edges in Inc ( p ). The root of the T T p maintains the edge with minimum length between the edges in Inc ( p ). Let m p be the number ofall insertions/deletions into the set Inc ( p ) over time. Lemma 7. (Theorem 3.1. [5]) The dynamic and kinetic tournament tree T T p can be con-structed in linear time. For a sequence of m p insertions and deletions into the T T p , whose maximumsize T T p at any time is n , the T T p generates at most O ( m p β s +2 ( n ) log n ) tournament events, fora total cost of O ( m p β s +2 ( n ) log n ) . Each event can be handled in the worst-case time O (log n ) . From Lemma 7, the number of all events for maintenance of all the nearest neighbors is equal to O ( P p ∈ P m p β s +2 ( n ) log n ) = O ( β s +2 ( n ) log n P p ∈ P m p ). Inserting (resp. deleting) an edge pq inthe Semi-Yao graph makes one insertion (resp. deletion) in T T p and one in T T q . So, P p ∈ P m p isin order of the number of exact changes to the Semi-Yao graph. Since P p | Ins ( p ) | = O ( n ), andsince the number of all changes (edge insertions and edge deletions) to the Semi-Yao graph is equalto O ( n β s +2 ( n )) [20], the following corollary results.8 orollary 1. Given a KDS for maintenance of the Semi-Yao graph, all the nearest neighbors canbe maintained by using a kinetic algorithm that generates O ( n β s +2 ( n ) log n ) tournament events,for a total cost of O ( n β s +2 ( n ) log n ) . Each event can be handled in the worst-case time O (log n ) .The number of events associated to a particular point is constant on average. The following theorem, which results from Theorem 1 and Corollary 1, gives the complexity of theKDS for maintenance of all the nearest neighbors. Theorem 2. Our kinetic data structure for maintenance of all the nearest neighbors of a set of n moving points in R d , where the trajectory of each point is an algebraic function of at most constantdegree s , has the following properties.1. The KDS uses O ( n log d n ) space.2. It processes O ( n ) u -swap events, each in the worst-case time O (log d +1 n ) .3. It processes O ( n ) x -swap events, for a total cost of O ( n β s +2 ( n ) log d +1 n ) .4. The KDS processes O ( n β s +2 ( n ) log n ) tournament events, and processing all the events takes O ( n β s +2 ( n ) log n ) time.5. The KDS is compact, efficient, responsive in an amortized sense, and local on average, meaningthat each point participates in a constant number of certificates on average. ǫ )-Nearest Neighbors Let q be the nearest neighbor of p and let ˆ q be some point such that | p ˆ q | < (1 + ǫ ) . | pq | . We call ˆ q the (1 + ǫ ) -nearest neighbor of p . In this section, we maintain some (1 + ǫ )-nearest neighbor for anypoint p ∈ P . R i B i p q ˆ q x l C l θ o Fig. 4: The point ˆ q (resp. p ) has minimum(resp. maximum) x l -coordinate among thepoints in R i (resp. B i ). Consider a cone C l of opening angle θ , which isbounded by d half-spaces. Let x l be the vector insidethe cone C l that passes through the apex of C l . Recall aCSPD Ψ C l = { ( B , R ) , ..., ( B m , R m ) } for P with respectto the cone C l . Figure 4 depicts the cone C l and a pair( B i , R i ) ∈ Ψ C l . Let b i (resp. r i ) be the point with the max-imum (resp. minimum) x l -coordinate among the pointsin B i (resp. R i ). Let E l = { ( b i , r i ) | i = 1 , ..., m } . We callthe graph G ( P, E l ) the relative nearest neighbor graph (orRNN l graph for short) with respect to C l . Call the graph G ( P, ∪ l E l ) the RNN graph . The RNN graph has the fol-lowing interesting properties: ( i ) It can be constructed in O ( n log d n ) time by using a d -dimensional RBRT, ( ii ) ithas O ( n log d − n ) edges, and ( iii ) the degree of each point is O (log d n ). Lemma 8 below showsanother property of the RNN graph which leads us to find some (1 + ǫ )-nearest neighbor for anypoint p ∈ P . Lemma 8. Between all the edges incident to a point p in the RNN graph, there exists an edge ( p, ˆ q ) such that ˆ q is some (1 + ǫ ) -nearest neighbor to p .Proof. Let q be the nearest neighbor to p and let q ∈ C l ( p ). From the definition of a CSPD withrespect to C l , for p and q there exists a unique pair ( B i , R i ) ∈ Ψ C l such that p ∈ B i and q ∈ R i .From Lemma 1, p has the maximum x l -coordinate among the points in B i .Let ˆ q be the point with the minimum x l -coordinate among the points in R i . For any ǫ > θ and a vector x l such that | p ˆ q | + (1 + ǫ ) . | q ˆ q | ≤ (1 + ǫ ) . | pq | [1]; this9atisfies that | p ˆ q | ≤ (1 + ǫ ) . | pq | . Therefore, the edge ( p, ˆ q ) which is an edge of the RNN graph givessome (1 + ǫ )-nearest neighbor. Consider the set E l of the edges of the RNN l graph. Let N l ( p ) = { r i | ( b i , r i ) ∈ E l and b i = p } .Denote by n l ( p ) the point in N l ( p ) whose x l -coordinate is minimum. Let L ( N l ( p )) be a sorted list ofthe points in N l ( p ) in ascending order according to their x l -coordinates; the first point in L ( N l ( p ))gives n l ( p ). Similar to Section 3 we handle two types of events, u -swap events and x -swap events .Note that we do not need to define a certificate for each two consecutive points in L ( N l ( . )). Thefollowing shows how to apply changes ( e.g. , insertion, deletion, and exchanging the order betweentwo consecutive points) to the sorted lists L ( N l ( . )) when an event occurs.Each event can make O (log d n ) updates to the edges of E l . Consider an updated pair ( b i , r i )that the value of r i (resp. b i ) changes from p to q . For this update, we must delete p (resp. r i ) formthe sorted list L ( N l ( b i )) (resp. L ( N l ( p ))) and insert q (resp. r i ) into L ( N l ( b i )) (resp. L ( N l ( q ))). Ifthe event is an x -swap event, we must find all the i where r i = q and check whether n l ( b i ) = p ornot; if so, p and q are in the same set N l ( . ) and we need to exchange their order in the correspondingsorted list L ( N l ( . )). Since each update to a sorted list L ( N l ( . )) can be done in O (log log n ), an eventcan be handled in worst-case time O (log d n log log n ).From Lemma 8, if the nearest neighbor of p is in some cone R i , then r i gives some (1+ ǫ )-nearestneighbor to p . Note that we do not know which cone C l ( p ), 1 ≤ l ≤ c , of p contains the nearestneighbor of p , but it is obvious that the nearest point to p among these c points n ( p ) , ..., n c ( p )gives some (1 + ǫ )-nearest neighbor of p . So, for all l = 1 , ..., c , we track the distances of all the n l ( p ) to p over time. A tournament tree (or a kinetic sorted list) of size c with O (1) certificatescan be used to maintain the nearest point to p . Since each event makes O (log d n ) changes to thevalues of n l ( . ), and since the size of each tournament tree (or a kinetic sorted list) is constant, thenumber of all events to maintain all the (1 + ǫ )-nearest neighbors is O ( n log d n ), and each pointparticipates in O (log d n ) certificates.From the above discussion the following theorem results. Theorem 3. Our KDS for maintenance of all the (1 + ǫ ) -nearest neighbors of a set of n movingpoints in R d , where the trajectory of each one is an algebraic function of constant degree s , uses O ( n log d n ) space and handles O ( n log d n ) events, each in the worst-case time O (log d n log log n ) .The KDS is compact, efficient, responsive, and local. Hence, for maintenance of all the (1 + ǫ )-nearest neighbors, as opposed to the all nearest neigh-bors KDS in Section 4, each event can be handled in a polylogarithmic worst-case time, and theKDS is local. References 1. Abam, M.A., de Berg, M.: Kinetic spanners in R d . Discrete Comput. Geom. 45(4), 723–736 (2011)2. Abam, M.A., de Berg, M., Speckmann, B.: Kinetic kd-trees and longest-side kd-trees. In: Proceedings of the 2007symposium on Computational geometry. pp. 364–372. SCG ’07, ACM, New York, NY, USA (2007)3. Abam, M.A., Rahmati, Z., Zarei, A.: Kinetic Pie Delaunay graph and its applications. In: Proceedings of the13th Scandinavian Symposium and Workshops on Algorithm Theory. SWAT ’12. LNCS, vol. 7357, pp. 48–58.Springer-Verlag (2012)4. Agarwal, P.K., Arge, L., Erickson, J.: Indexing moving points. J. Comput. Syst. Sci. 66, 207–243 (2003)5. Agarwal, P.K., Kaplan, H., Sharir, M.: Kinetic and dynamic data structures for closest pair and all nearestneighbors. ACM Trans. Algorithms 5, 4:1–37 (2008)6. Alexandron, G., Kaplan, H., Sharir, M.: Kinetic and dynamic data structures for convex hulls and upper envelopes.Comput. Geom. Theory Appl. 36(2), 144–158 (2007) . Barba, L., Bose, P., De Carufel, J.L., van Renssen, A., Verdonschot, S.: On the stretch factor of the theta-4graph. In: Proceedings of the 13th Workshop on Algorithms and Data Structures. WADS ’13. LNCS, vol. 8037,pp. 109–120 (2013)8. Basch, J., Guibas, L.J., Hershberger, J.: Data structures for mobile data. In: Proceedings of the eighth annualACM-SIAM symposium on Discrete algorithms. pp. 747–756. SODA ’97, Society for Industrial and AppliedMathematics, Philadelphia, PA, USA (1997)9. Basch, J., Guibas, L.J., Zhang, L.: Proximity problems on moving points. In: Proceedings of the thirteenth annualsymposium on Computational geometry. pp. 344–351. SCG ’97, ACM, New York, NY, USA (1997)10. de Berg, M., Roeloffzen, M., Speckmann, B.: Kinetic convex hulls and delaunay triangulations in the black-boxmodel. In: Proceedings of the 27th annual ACM symposium on Computational geometry. pp. 244–253. SoCG’11, ACM, New York, NY, USA (2011)11. Bonichon, N., Gavoille, C., Hanusse, N., Ilcinkas, D.: Connections between theta-graphs, delaunay triangulations,and orthogonal surfaces. In: Proceedings of the 36th international conference on Graph-theoretic concepts incomputer science. pp. 266–278. WG’10, Springer-Verlag, Berlin, Heidelberg (2010)12. Bose, P., Morin, P., van Renssen, A., Verdonschot, S.: The θ -graph is a spanner. In: Proceedings of the 39thInternational Workshop on Graph-Theoretic Concepts in Computer Science. WG ’13. To appear13. Bose, P., van Renssen, A., Verdonschot, S.: On the spanning ratio of theta-graphs. In: Proceedings of the 13thWorkshop on Algorithms and Data Structures. WADS ’13. LNCS, vol. 8037, pp. 182–194. Springer Berlin Hei-delberg (2013)14. Clarkson, K.: Approximation algorithms for shortest path motion planning. In: Proceedings of the nineteenthannual ACM symposium on Theory of computing. pp. 56–65. STOC ’87, ACM, New York, NY, USA (1987)15. Gao, J., Guibas, L.J., Nguyen, A.: Deformable spanners and applications. Comput. Geom. Theory Appl. 35(1-2),2–19 (Aug 2006)16. Karavelas, M.I., Guibas, L.J.: Static and kinetic geometric spanners with applications. In: Proceedings of thetwelfth annual ACM-SIAM symposium on Discrete algorithms. pp. 168–176. SODA ’01, Society for Industrialand Applied Mathematics, Philadelphia, PA, USA (2001)17. Keil, J.M.: Approximating the complete euclidean graph. In: No. 318 on SWAT 88: 1st Scandinavian workshopon algorithm theory. pp. 208–213. Springer-Verlag, London, UK, UK (1988)18. Knuth, D.E.: The Art of Computer Programming, Volume III: Sorting and Searching. Addison-Wesley (1973)19. Mehlhorn, K.: Data structures and algorithms 3: multi-dimensional searching and computational geometry.Springer-Verlag New York, Inc., New York, NY, USA (1984)20. Rahmati, Z., King, V., Whitesides, S.: Kinetic data structures for all nearest neighbors and closest pair in theplane. In: Proceedings of the 2013 Symp. on Computational Geometry. SoCG ’13. pp. 137–144. ACM, New York,NY, USA (2013)21. Rahmati, Z., Whitesides, S., King, V.: Kinetic and stationary point-set embeddability for plane graphs. In:Proceedings of the 20th Int. Symp. on Graph Drawing. GD ’12. LNCS, vol. 7704, pp. 279–290 (2013)22. Rahmati, Z., Zarei, A.: Kinetic Euclidean minimum spanning tree in the plane. Journal of Discrete Algorithms16(0), 2–11 (2012)23. Rubin, N.: On topological changes in the delaunay triangulation of moving points. In: Proceedings of the 2012symposuim on Computational Geometry. pp. 1–10. SoCG ’12, ACM, New York, NY, USA (2012)24. Vaidya, P.M.: An O( n log n ) algorithm for the all-nearest-neighbors problem. Discrete Comput. Geom. 4(2),101–115 (1989)25. Willard, D.E., Lueker, G.S.: Adding range restriction capability to dynamic data structures. J. ACM 32(3),597–617 (1985) The Comparison Table problem space total number of events total processing time localityAgarwal et al. [5] all NNs in R d O ( n log d n ) O ( n β s +2 ( n ) log d +1 n ) O ( n β s +2 ( n ) log d +2 n ) O (log d n )on averageRahmati et al. [20] all NNs in R O ( n ) O ( n β s +2 ( n ) log n ) O ( n β s +2 ( n ) log n ) O (1) onaverageSemi-Yaograph in R O ( n ) O ( n β s +2 ( n )) O ( n β s +2 ( n ) log n ) O (1) onaverageThis paper all NNs in R d O ( n log d n ) O ( n β s +2 ( n ) log n ) O ( n β s +2 ( n ) log d +1 n ) O (1) onaverageSemi-Yaograph in R d O ( n log d n ) O ( n ) O ( n β s +2 ( n ) log d +1 n ) O (1) inworst-case Table 1: The comparison between our KDS’s and the previous KDS’s, assuming dd