computational geometry - efficient algorithm to find nearest point in a graph that does not have a known equation -
i'm asking questions out of curiostity, since quick , dirty implementation seems enough. i'm curious better implementation be.
i have graph of real world data. there no duplicate x values , x value increments @ consistant rate across graph, y data based off of real world output. want find nearest point on graph arbitrary given point p programmatically. i'm trying find efficient (ie fast) algorithm doing this. don't need the exact closest point, can settle point 'nearly' closest point.
the obvious lazy solution increment through every single point in graph, calculate distance, , find minimum of distance. theoretically slow large graphs; slow want.
since need approximate closest point imagine ideal fastest equation involve generating best fit line , using line calculate point should in real time; sounds potential mathematical headache i'm not take on.
my solution hack works because assume point p isn't arbitrary, namely assume p close graph line , when happens can cross out distant x values consideration. calculating how close point on line shares x coordinate p , use distance between point , p calculate largest/smallest x value possible closer points.
i can't feel there should faster algorithm solution (which useful because assume 99% of time point p point close line already). tried googling better algorithms found many algorithms didn't quite fit hard find looking amongst clutter of inappropriate algorithms. so, here have suggested algorithm more efficient? keep in mind don't need full algorithm since have works needs, i'm curious proper solution have been.
if can use data structure, common data structures spacial searching (including nearest neighbour) are...
- quad-tree (and octree etc).
- kd-tree
- bsp tree (only practical static set of points).
- r-tree
the r-tree comes in number of variants. it's closely related b+ tree, (depending on variant) different orderings on items (points) in leaf nodes.
the hilbert r tree uses strict ordering of points based on hilbert curve. hilbert curve (or rather generalization of it) @ ordering multi-dimensional data nearby points in space nearby in linear ordering.
in principle, hilbert ordering applied sorting simple array of points. natural clustering in mean search need search few fairly-short spans in array - complication being need work out spans are.
i used have link paper on doing hilbert curve ordering calculations, i've lost it. ordering based on gray codes simpler, not quite efficient @ clustering. in fact, there's deep connection between gray codes , hilbert curves - paper i've lost uses gray code related functions quite bit.
edit - found link - http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.133.7490
Comments
Post a Comment