The best known algorithm for continuous kNN queries is CPM proposed by Mouratidis et al. [MHP05]. It visits minimal set of cells during initial computation. CPM organizes the cells into conceptual rectangles based on their proximity to . Each rectangle is defined by a direction and a level number. The direction is U, D, L or R (for up, down, left, and right), and the level number indicates the number of rectangles between the rectangle and . Fig. (a) illustrates the conceptual partitioning of space for around the cell .
CPM initializes a heap by inserting , the resident cell of with key 0 , and the zero level rectangle for each direction , with key ( which is the minimum possible distance between the query and the rectangle . Then it starts deheaping the entries. If the deheaped entry is a cell, it examines all the objects inside it and updates the accordingly, the list of nearest neighbors. If the deheaped entry is a rectangle , CPM enheaps (1) each cell with key and (2) the next level rectangle with key . The algorithm terminates when the next entry in the heap (either a cell or a rectangle) has key greater than or equal to the (the distance of Nearest Neighbor from ). It can be easily seen that the algorithm only processes the cells that intersect with the circle centered at with radius equal to . This is the minimal set of cells to visit in order to guarantee the correctness. In Fig. (a), the shaded cells in light color are those that are visited by the algorithm.
In order to handle the updates efficiently, CPM needs to store (1) visit list that contains the cells visited during NN search (in ascending order with respect to their from ) and (2) search heap that contains the entries (cells and rectangles) which were enheaped but were not deheaped (for which ). The visit list, in our running example of Fig. (a), contains the light shaded cells. The search heap contains the shaded cells in dark color plus the four boundary rectangles and . The influence region of query are the cells such that . In other words, this is the set of cells that intersect the circle centered at with radius . Only updates affecting these cells can influence the NN result.
CPM handles the updates as follows: If an object enters into the influence region (incoming update), CPM inserts it in and deletes the nearest neighbor. If an object leaves the influence region (outgoing update), CPM removes from and calls the re-computation module to compute nearest neighbor set. NN re-computation algorithm first starts visiting the cells in visit list of and then it continues with the entries of search heap in the same way as it does in NN initial computation. The algorithm stops when the next entry in visit list or search heap has greater than or equal to the distance of NN found so far. Note that NN re-computation algorithm is same as initial computation algorithm except that it re-uses the previous information. i.e., It does not need to calculate the of cells in visit list and it avoids enheap and deheap operations.
Consider the example of Fig. (b) where an object moves to (to illustrate clearly, we ignore the update issued by ). Since this is an incoming update, the object is added to the and the old NN is deleted from . Now take the example where moves to (now we ignore the update of ). Since it is an outgoing update, the object is removed from the and the NN re-computation module is invoked.
To handle multiple updates, CPM counts the number of incoming and outgoing updates for each query . If incoming updates are greater than outgoing updates, the new nearest neighbors can be found among the incoming objects. Otherwise, re-computation module is called. If query changes its position, it is deleted from the query list and added as a new query at new location. Then, it is computed from scratch.
Muhammad Aamir Cheema 2007-10-11