This is an old revision of the document!
4.4. Shortest paths in a graph
The Problem
- We are given a directed graph G = (V,E) with a starting node S.We assume that s has a path to every other node in G.
- Each edge e has a length le≥ 0, which it the cost of traversing e.
- For each path P, the length of P(l(P)) = ∑ of all edges in P.
–>Goal of the algorithm: Determine the shortest path from S to every other node in the graph.
Designing the algorithm-The Dijkstra algorithm
Dijkstra's algorithm(G,l)
Let S be the set of explored nodes
For each u in S, store the distance d(u)
Initially, S = {s} and d(s) = 0
While S ≠ V:Select a node v ∉ S with at least one edge from S for which:
d'(v) = mine = (u,v):u in S + le is as small as possible
The formula above for d'(v) simply means that we choose a node v ∉ S that minimizes the path through S to u followed by the edge (u,v)
Then add v to S and delete d(v) = d'(v)EndWhile