All algorithms

Dijkstra's Shortest Path

Greedy single-source shortest path on non-negative weighted graphs. Always expands the unvisited node with the smallest tentative distance, relaxing edges to its neighbours.

time O((V + E) log V)
space O(V)

Press Tab out of the box or click Resetto regenerate frames from the current input.

Visualization
No frames yet — edit input and click Run.
Pseudocode
dist[start] = 0; others = ∞
pq = min-heap of (dist, node)
while pq:
  d, u = pq.pop()
  for (v, w) in neighbours(u):
    if d + w < dist[v]:
      dist[v] = d + w
      pq.push((dist[v], v))