Algorithm. Dijkstra's Algorithm [00O4]

Here is the updated version of Dijkstra's Algorithm using a priority queue for tracking unvisited vertices.

\mathsf {Dijkstra}(G, s):
d \gets empty dictionary
\mathit {parent} \gets empty dictionary
d[s] \gets 0, all other d[v] \gets \infty
Create priority queue Q containing all vertices, using d[v] as the key for each v.
\mathsf {while} Q is not empty:
u \gets Q.\mathit {removeMin}
\mathsf {for} each neighbor v of u:
\mathsf {if} d[u] + w_{uv} < d[v]:
d[v] \gets d[u] + w_{uv}
Q.\mathit {updateKey}(v, d[v])
\mathit {parent}[v] \gets u
\mathsf {return} \mathit {parent}, d