The complexity of Dijkstra's shortest path algorithm:
O(|E| |decrease-key(Q)| + |V| |extract-min(Q)|)
where Q are the ordinal vertices of the queue with the lowest priority according to their current distance estimate.
For the Fibonacci heap and the binary heap, the complexity of the extract-min operation in this queue is O(log |V|) . This explains the total amount |V| log |V| |V| log |V| in total. For a queue implemented with an unsorted array, the extract-min operation will have complexity O(|V|) (the entire queue must be passed), and this part of the sum will be O(|V|^2) .
In the remaining part of the sum (the one with the edge coefficient | E |), O(1) vs The difference O(log |V|) comes precisely from the use of the Fibonacci heap, and not the binary heap, respectively. The operation of the reduction keys, which can occur for each edge, is of such complexity. Thus, the remainder of the sum ultimately has complexity O(|E|) for the Fibonacci heap and O(|E| log |V|) for the binary heap. For a queue implemented with an unsorted array, the key reduction operation will be of constant complexity (the queue directly stores the keys indexed by vertices), and this part of the sum will thus be O(|E|) , which is also O(|V|^2) .
Summarizing:
- Fibonacci heap:
O(|E| + |V| log |V|) - binary heap:
O((|E| + |V|) log |V|) - unsorted array:
O(|V|^2)
Since in the general case |E| = O(|V|^2) |E| = O(|V|^2) , this cannot be simplified further without making further assumptions about the graphs under consideration.
source share