views:

604

answers:

3

Given a directed, connected graph with only positive edge weights, are there faster algorithms for finding the shortest path between two vertices, than Dijkstra using a fibonacci heap?

Wikipedia says, that Dijkstra is in O(|E| + |V| * log(|V|)) (using a fibonacci heap).

I'm not looking for optimizations that, for example, half the execution time, but rather algorithms that are in a different time complexity (like going from O(n * log n) to O(n)).

Further, I would like to know your opinion on the following approach:

  1. Determine the GCD of all edge weights.
  2. Transform the graph into a graph with uniform edge weights.
  3. Use BFS to find the shortest path between two given vertices.

Example for point 2:
Imagine the GCD to be 1. Then I would transform the edge
A--->B (edge weight 3)
into
A->A'->A''->B (3 times edge weight 1)
This transformation costs constant time and would have to be done once for every edge. So I expect this algorithm to be in O(|E|) (transformation) + O(|E| + |V|) (BFS) = O(2 * |E| + |V|) = O(|E| + |V|)

Thanks for taking the time to read my question and I hope not having waisted your time^^. Have a nice day.

+7  A: 

The big oh analysis you did for your algorithm is deeply flawed. Assume all edges are prime numbers. The number of edges in the new graph will be equal to sum of all weights. Thus O(|E| + |V|) of the new graph is actually O(W x |E| + |V|) in the original graph which can be much larger than O(|E| + |V| log |V|).

Mehrdad Afshari
You're correct. In a worst case scenario, all edge weights are prime numbers and the graph is complete. Thus W is at least |V|^2 (|V|^2 edges with weights >= 1). So my algorithm runs in |V|^2 * |V|^2 + |E| = |V|^4 + |E| at least. However, my original question remains unanswered.
Dave
Sry, I meant |V|^4 + |V| - why can't I edit my post or my comments?
Dave
I'm not sure whether there's a asymptotically faster algorithm for arbitrary graphs. The fastest I know is Dijkstra with Fibonacci heaps. I can't be sure though.
Mehrdad Afshari
+1  A: 

There is an algorithm which has O(1): Turn the weights into chain lengths and use key rings for nodes (real key rings as those in your pocket). Connect the key rings with the right chains. Select the two nodes and pull them away from each other.

Follow the taut chains from one node to the other. This is the shortest path.

To implement this as a computer program, you'll need two industrial robots :)

For a more real world example, use the Ant colony optimization which gives very good results in a short time. Since you can specify the number of runs in this algorithm, you can decide how much time it spent (i.e. the runtime is only dependent on the number of nodes) which gives you O(n) but not a guaranteed perfect result.

Aaron Digulla
How is that O(1)?
Martinho Fernandes
I can actually think of an O(L) algorithm, where L is the number of nodes in the correct solution: quantum-bogo-shortest-path (http://en.wikipedia.org/wiki/Bogosort#Quantum_Bogosort)
Martinho Fernandes
Is is O(1) if you don't consider the graph building step.
mouviciel
@Marthinho: After the initial setup (which doesn't count), you perform just a single operation: Pulling the nodes apart. Okay, it's tongue in cheek :)
Aaron Digulla
@Aaron: what about "follow the taut chains..."
Martinho Fernandes
I think I can prove a lower bound of O(L) for any such algorithm.
Martinho Fernandes
@Marthinho: +1 You're right. The first algorithm depends on the number of nodes in the result.
Aaron Digulla
@Aaron, anyway, yours still requires less resources than mine (two industrial robots vs destroying several universes).
Martinho Fernandes
@Martinho: Bah. Petty details ;) As long as the quantum theory produces a new universe for every possibility, we ca***UNIVERSE LOST
Aaron Digulla
+3  A: 

Are there faster algorithms than Dijkstra?

Yes. The question isn't qualified so as to require better performance in all cases, or even in most cases. An algorithm with better performance in a single case is sufficient to establish an affirmative answer.

Despite the generally larger number of iterations required by the Bellman-Ford method over Dijkstra’s method, in practice the Bellman-Ford method can be superior because of the smaller overhead per iteration [Golden, B., 1976. “Shortest-Path Algorithms: A Comparison,” Operations Research, Vol. 44, pp. 1164-1168].

The quote above is from Dimitri P. Bertsekas (March 1992). "A Simple and Fast Label Correcting Algorithm for Shortest Paths" (PDF). Networks, Vol. 23, pp. 703-709, 1993. http://www.mit.edu/people/dimitrib/SLF.pdf. Retrieved 2008-10-01.

In short, my claim is based on Bertsekas' interpretation of Golden. Whether my conclusion stands up or not, you may find Bertsekas interesting for its classification of the Dijkstra algorithm as a label setting method, as contrasted with label correcting methods.

Ewan Todd
He specifically asked about solutions with lower asymptotic runtime.
Nick Johnson
OK, so treat this like a lemma on the way to the final result.
Ewan Todd
Firstly, results about what is faster "in practice" are not relevant to what has *asymptotically* better growth, because graphs encountered in practice are finite and usually small. Further,faster in 1976 does not necessarily translate to faster in 2009. For one thing, the "in-practice" graphs are larger today — to take an exaggerated example, `200x^2` is four times faster than `n^3` for n=50, but one-fifth as slow for n=1000.
ShreevatsaR
Yes, I'm explicitly interested in the asymptotic runtime. I would like to know, if Dijkstra is a lower bound for this problem, as n*log n is for sorting arbitrary objects, on which a total order is defined.
Dave