[prev] 20 [next]

Dijkstra's Algorithm (C implementation) (cont)

Rough time complexity analysis ...

Outer loop has O(V) iterations, and PQ updates are O(logV).

Implementing "find (edge e=(s,t,w)) satisfying ..."

  1. try all e ∈ E ... cost = O(VE)
  2. classical Djiskstra approach ... cost = O(V2)
    • consider only edges (s,t,w) where s ∈ vSet and t ∉ vSet
  3. use a PQueue to find edge to relax
    • cost = V*Costjoin + V*Costleave + ~E*Costreorder

In case 3, cost is dependent on efficiency of PQueue.