Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortest-path algorithms which use a space-time tradeoff?

Problem: finding shortest paths in an unweighted, undirected graph.

Breadth-first search can find the shortest path between two nodes, but this can take up to O(|V| + |E|) time. A precomputed lookup table would allow requests to be answered in O(1) time, but at the cost of O(|V|^2) space.

What I'm wondering: Is there an algorithm which offers a space-time tradeoff that's more fine-grained? In other words, is there an algorithm which:

  1. Finds shortest paths in more time than O(1), but is faster than a bidirectional breadth-first search
  2. Uses precomputed data which takes up less space than O(|V|^2)?

On the practical side: The graph is 800,000 nodes and is believed to be a small-world network. The all-pairs shortest paths table would be on the order of gigabytes -- that's not outrageous these days, but it doesn't suit our requirements.

However, I am asking my question out of curiosity. What's keeping me up at night is not "how can I reduce cache misses for an all-pairs lookup table?", but "Is there a completely different algorithm out there that I've never heard of?"

The answer may be no, and that's okay.

like image 347
Chris Mounce Avatar asked Nov 06 '22 13:11

Chris Mounce


1 Answers

You should start by looking at Dijkstra's algorithm for finding the shortest path. The a* algorithm is a variant that uses a heuristic to reduce the time taken to calculate the optimal route between the start and goal node (such as the euclidean distance). You can modify this heuristic for performance or accuracy.

like image 182
James Westgate Avatar answered Nov 15 '22 05:11

James Westgate