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 ... "
- try all e ∈ E ... cost = O(VE)
- classical Djiskstra approach ... cost = O(V2)
- consider only edges (s,t,w) where s ∈ vSet and t ∉ vSet
- 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.
|