← Back to All Algorithms

🛤️ Dijkstra's Shortest Path Algorithm

How It Works

Dijkstra finds the shortest path from a source to all other vertices:

  1. Initialize distances: source = 0, all others = ∞
  2. Extract vertex with minimum distance from priority queue
  3. Relax all edges: if d[u] + weight(u,v) < d[v], update d[v]
  4. Repeat until all vertices are processed
Click "Start" to run Dijkstra from node S