function dijkstra(G, S)
for each vertex V in G
dist[V] <- infinite
prev[V] <- NULL
If V != S, add V to Priority Queue Q
dist[S] <- 0
while Q IS NOT EMPTY
U <- Extract MIN from Q
for each unvisited neighbour V of U
temperoryDist <- dist[U] + edgeWeight(U, V)
if temperoryDist < dist[V]
dist[V] <- temperoryDist
prev[V] <- U
return dist[], prev[]