How to run each algorithm 01 Load a graph and set the endpoints. Build a preset or paste an adjacency matrix, then choose Source and Target; a preset build resets them to the first and last node. 02 Dijkstra answers distance, path and settle order, and refuses any graph with a negative edge — the error names the edge and points to Bellman–Ford. 03 A\ adds a heuristic selector (manhattan / euclidean / zero) and reports nodes expanded versus Dijkstra, the heuristic scale actually used, and whether the heuristic is consistent, hence optimal. 04 Bellman–Ford reports the relaxation rounds, lists the final distances per node and flags a negative cycle if one exists. 05 Floyd–Warshall fills the distance matrix from one source, marks negative-cycle nodes, and can answer any source/target pair through the same table.
Worked readouts Read from the panel:
Setup
Readout
Default 6-node graph, Dijkstra A → F
distance 13 ; path A → C → B → D → E → F ; settle order A → C → B → D → E → F ; d[B] 3 , d[C] 2 , d[D] 8 , d[E] 10
Grid 4 × 5, Dijkstra 1-1 → 4-5
distance 7 ; settle order lists all 20 nodes; path 1-1 → 1-2 → 2-2 → 3-2 → 3-3 → 3-4 → 3-5 → 4-5
Default graph, A* with euclidean
distance 13 , same path; nodes expanded 6 / Dijkstra 6 ; heuristic scale 0.01346 ; consistent optimal Yes
Negative-weights preset, Bellman–Ford from S
3 relaxation rounds; d[S] 0 , d[A] 3 , d[B] 5 , d[C] 0 , d[D] 3 ; negative cycle None
Negative-weights preset, Floyd–Warshall S → D
distance 3 ; path S → B → A → C → D ; negative-cycle nodes None
Dijkstra's d[C] = 2 comes from the direct A–C edge, and d[B] = 3 from A → C → B, not from the heavier 4 edge A–B. Bellman–Ford reaches the same values on a graph with a −3 edge, and Floyd–Warshall finds S → B → A → C → D by chaining a negative and a positive edge.
Why A* prints a scale Canvas coordinates and edge weights are different quantities, so A* measures the heuristic on the layout and scales it by the largest factor that still keeps h(u) ≤ w(u,v) + h(v) on every arc. On the default graph the euclidean scale is 0.01346 , and all three heuristics expand the same 6 nodes as Dijkstra. The consistent-optimal row is the promise that the returned distance is exact.
Limits
Non-negative weights for Dijkstra and A\*. Either refuses a negative edge instead of returning a too-large distance; switch to Bellman–Ford in the same panel for the Negative weights preset. One source per run. There is no multi-source Dijkstra and no Johnson all-pairs; Floyd–Warshall is the all-pairs option, at cubic cost. The panel also does not read edge lists from a file or export a route — write the adjacency matrix to the workspace and take it to the matrix tools , the spanning tree panel for cheapest wiring, or flow & matching for capacity questions.
The negative-edge boundary Build the Negative weights preset (S → A 4, S → B 5, A → C −3, B → A −2, B → C 4, C → D 3) and press Dijkstra with Source S. The panel refuses with the message "Edge 3 has weight -3. Dijkstra cannot handle negative weights (a settled distance could still be lowered) — use Bellman–Ford instead" rather than a plausible wrong number. Switch the algorithm to Bellman–Ford and S → C reads 0 , a distance Dijkstra's greedy settle could never have produced. A* carries the same refusal; its message points to Bellman–Ford too.
Where it is useful Proof of optimality for a tour Dijkstra's settle order is the proof that the final distances are right: each vertex is finalised once and never revisited. On the default graph the direct A–B edge weighs 4 but the route through C costs 3 , and the order A → C → B → D → E → F shows C finalised before B — the panel is displaying its own correctness argument.
Teaching why heuristics must be scaled Set A* to the zero heuristic and the run is Dijkstra with bookkeeping (scale 1 ); set euclidean on the laid-out default graph and the scale drops to 0.01346 , so the estimate can never overrun the true cost while the route stays exact.
Negative costs in planning The Negative weights preset models a credit between two stages. Bellman–Ford answers S → D in 3 ; Floyd–Warshall confirms the same value, and neither reports a negative cycle, so the improvement chain S → B → A → C → D terminates.
Privacy Graph editing and every shortest-path run happen in your browser; nothing is uploaded.
References
Wikipedia, Dijkstra's algorithm , en.wikipedia.org (访问日期:2026-10-07)— greedy settle and non-negative weights.
Wikipedia, Bellman–Ford algorithm , en.wikipedia.org (访问日期:2026-10-07)— relaxation rounds and negative-cycle detection.
Wikipedia, Floyd–Warshall algorithm , en.wikipedia.org (访问日期:2026-10-07)— all-pairs dynamic programming.
Wikipedia, A* search algorithm , en.wikipedia.org (访问日期:2026-10-07)— admissible and consistent heuristics.
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein, Introduction to Algorithms , 4th ed., MIT Press, 2022, mitpress.mit.edu (访问日期:2026-10-07)— single-source shortest paths.
Calculators in this hub
Hand-picked tools, one click away. The mini versions compute live and carry your values into the full calculator.
Sources & review
Reviewed by CalcX Editorial Team
Updated 2026-10-07