Skip to main content
. 2013 Nov 5;139(17):174105. doi: 10.1063/1.4827495

Table 1.

Algorithm 1 - Dijkstra's algorithm to find the shortest path lengths from vertex s to all other vertices in graph G.

Procedure shortestPath(G,s)  
For each v in G 1
  L(v) = ∞ 2
  3
L(s) = 0 4
Q = V  // Add all the vertices to Q 5
  6
while Q ≠ NULL 7
  u = EXTRACT_MIN(Q) 8
  for each v in Adj(u) 9
    if L(v) > L(u) + d(u,v)   // L(v) = min(L(v),L(u)+d(u,v)) 10
       L(v) = L(u)+d(u,v) 11
return L 12