Dijkstra
Find and explore shortest paths with Dijkstra, Bellman-Ford, BFS and A*.
About this tool
Enter one edge per line: A B 4, or A B for weight 1. Separate tokens with spaces or commas; use a decimal point in weights. Blank lines and lines starting with # are ignored. Up to 30 nodes, 100 edges, 12 characters per node and absolute weight 10⁹. Start and target names are case-sensitive.
Find path calculates immediately. One step shows an initialization, node or edge event; Animate follows these events at the chosen delay. Pause retains the current state. Edits clear stale results. Reset restores the example. Leaving or hiding the tool stops animation. Graph text, source, target, direction, algorithm and delay are saved locally, including unfinished drafts. Reload restores inputs, not search progress.
Dijkstra and A* require non-negative weights. BFS accepts only weight 1. Bellman-Ford supports negative weights, but rejects a run with any negative cycle reachable from the start, even if the target is unaffected. In an undirected graph a negative edge creates a negative cycle. A* uses minimum edge weight times reverse hop distance as a consistent lower bound; if that minimum is zero, it behaves like Dijkstra.
The example has cost 9: A → C → E → F. Only the reported target path is guaranteed final; other table distances may still be tentative when the target is reached. Ties return one shortest path. Circle positions are schematic, unrelated to weights. Long node names are shortened in the drawing; full names remain in the table and node tooltip. This is a small-graph teaching tool, not a map or large-network solver.