0

I have ~6500 nodes with (x,y,z)-coordinates. For my task, I need to find a route from Node A to Node B, given that I can only move K distance between nodes. K changes between routes (so it's constant while calculating a given route, but for a new start and end node it may be different).

I imagined doing an A* algorithm, but that would mean that I would have to calculate the distance between each "current" node and all other nodes for each jump, which is unfeasable. I could also pre-compute the graph for each increment of K (1, 2, 3, 4) but that would leave me a massive amount of data (maximum K would be around 15).

Is there a smart way that, with some precomputation, allows me to quickly lookup such a route. The data set is expected to grow slightly, but would probably never exceed 10.000.

Christian P.
  • 4,784
  • 7
  • 53
  • 70
  • This post seems useful: http://stackoverflow.com/questions/6371187/find-all-coordinates-within-a-circle-in-geographic-data-in-python. I don't quite understand the `k-d tree` (still reading about it), but if it gives you a reasonable time complexity for finding neighbors (given a jump distance) then you could do this in reasonable time. This makes a simple Dijkstra's feasible. 10000 input points also doesn't seem too bad, but I don't have the napkin math to estimate the size of storing such a graph in memory. – rliu May 04 '13 at 04:06
  • Do you need the shortest route? If not, the unique path in a minimum spanning tree has the property of minimizing the maximum jump distance. – David Eisenstat May 04 '13 at 12:58
  • I am afraid it is the shortest route I am looking for. Otherwise not a bad suggestion. – Christian P. May 06 '13 at 07:37
  • Is `K` an upper bound? You could store the neighbors at distance at most 15 in order of increasing distance. – David Eisenstat May 07 '13 at 00:32
  • I may end up just precomputing all neighbors within `K` from each node along with actual distance, and then doing a lookup based off that in descending order. Can't think of any smarter way of doing it at the moment. – Christian P. May 07 '13 at 07:53
  • You could pre-compute the graph with the Floyd-Warshall algorithm: http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm – dave1010 Jun 13 '13 at 13:40

0 Answers0