Loading algorithms…
Loading visualizer…
Find the shortest paths from a source node to all other nodes in a weighted graph.
Dijkstra's algorithm, published by Edsger W. Dijkstra in 1959, finds the shortest path from a source node to all other nodes in a weighted graph with non-negative edge weights.
prev pointers backward from target to source.The core operation is relaxation: for a neighbor v of the current node u, if dist[u] + weight(u,v) < dist[v], update dist[v] and record prev[v] = u. Dijkstra's greedy approach guarantees that once a node is dequeued, its distance is final.
⚠️ Limitation: Dijkstra's algorithm does not work with negative edge weights. For graphs with negative weights, use the Bellman-Ford algorithm instead.
Click nodes to set source/target · Drag nodes to rearrange layout · Use controls to step through