next up previous
Next: Up: Previous:

Dijkstra's Algorithm

Dijkstra(G, w, s)                        ANALYSIS
  Init-Single-Source(G, s)                O(V)
  Q = V
  (S = {})
  while Q <> {}               Q (LINEAR  Q (BINARY)  Q (FIBONACCI)
     u = Extract-Min(Q)          ARRAY)      HEAP)      HEAP)
     (S = S u {u})               O(V^2)      VlgV       VlgV
     foreach v in Adj(u)
        Relax(u, v, w)            O(E)       ElgV        E
                              ------------------------------------
                               O(V^2 + E)  O((V+E)lgV) O(E+VlgV)
                                                       amortized

Theorem 25.10 and Corollary 25.11:

$\;\;\;\;\;$Dijkstra's algorithm produces a shortest path tree.


next up previous
Next: Up: Previous: