Change Dijkstra's algorithm

Let be G (V, E)a weighted directed graph with a non-negative weight function W : E -> {0, 1, 2... W }for some non-negative integer W. How to change Dijkstra’s algorithm for calculating the shortest paths from a given source vertex s in O(V W + E)time.

+4
source share
2 answers

I've done research on this topic, and the algorithm that you are looking for Dial algorithm. There is also additional optimization of Dijkstra's algorithm, so I also attached it below. At the very bottom, I put my performance tests on these three algorithms.

Dialing algorithm

pseudo code

enter image description here

. 0 . O(m+n*C), n - , C - , m - .

- Radix algorithm.

enter image description here

ln(C) . i th [2^i, 2^(i+1)]. O(m+nln(n*C)).

1

enter image description here

2

enter image description here

3

enter image description here

4

enter image description here

+1

Dijkstra . .

: . , , , ( ), .

:

  • 0, 1, 2, 3, ..., W(V-1), W - , V - . Bucket k , k. .
  • 0, 1, 2, ..., WV , . .
  • node , .
  • (2-4) ( 2 ), .

WV buckets , W=1, - . W(V-1).

.

+1

Source: https://habr.com/ru/post/1678716/


All Articles