I have a program which works with a list of points (in 3D, but it could be in 1D as well, it won't make a difference). Within a loop, it keeps adding new points to the list. To calculate the coordinates of a new point, it needs to use a NearestFunction generated from the list of existing points.
When a new point is added to the list, the NearestFunction needs to be rebuilt as well. This is rather time consuming if I do it using the list of existing points.
Is it possible to more efficiently append a new point to an already constructed NearestFunction? (Perhaps by making use of the knowledge of the internal structure of a NearestFunction)
Here's an example to illustrate the question better:
points = RandomReal[1, {1000, 3}]; (* we have lots of points ... *) nf = Nearest[points]; (* ... and the corresponding NearestFunction *) AppendTo[points, RandomReal[1, 3]]; (* we add an extra point, ... *) nf = Nearest[points]; (* so we need to rebuild the NearestFunction, but doing it from scratch is inefficient *) Rebuilding the NearestFunction for a large number of points is not very efficient. Is there a way to add a single point more efficiently, making use of the existing NearestFunction?


Nearest[data,x,n]and use the second element if the first one has been "deleted" $\endgroup$