Dijkstra shortest path calculator
Enter a weighted graph as edges ("A, B, 4" per line) and a source node: Dijkstra's algorithm returns the shortest distance and the exact path from the source to every reachable vertex. Works for directed or undirected graphs, accepts many edge formats, and flags unreachable vertices — ideal for routing, networks and pathfinding.
Related tools
All Discrete maths & graphs tools →Dijkstra shortest path calculator is free to use as often as you like, directly from this page. It covers "A, B, 4" per line — adjust any of them and the result follows immediately.
How to use it
- Open the tool — no signup or install needed.
- Enter your input or adjust the available options.
- Get your result instantly, then copy or download it.
Frequently asked questions
What is Dijkstra shortest path calculator?
Enter a weighted graph as edges ("A, B, 4" per line) and a source node: Dijkstra's algorithm returns the shortest distance and the exact path from the source to every reachable vertex. Works for directed or undirected graphs, accepts many edge formats, and flags unreachable vertices — ideal for routing, networks and pathfinding.
What does a concrete case look like?
A→B 4, B→C 3, A→C 9 → A→C = 7 via B — the tool shows every step in between, not just the final figure.
What does it take into account?
It factors in "A, B, 4" per line. Change any of them and the output follows immediately.
When would I actually use this?
Anything modelled as points and connections: a shortest route, a network's capacity, a schedule with dependencies, or a circuit reduced to its logic.
What is the most common mistake?
Assuming a shortest path stays shortest when a weight changes sign. Negative edges break the greedy argument Dijkstra rests on, and the algorithm returns a confident wrong answer rather than an error.
How is Dijkstra shortest path calculator different from Hamiltonian path & cycle checker?
They sit next to each other but answer different questions: Hamiltonian path & cycle checker is the one to open when you need it to check whether a graph has a Hamiltonian path (visits every vertex once) or a Hamiltonian cycle (also returns to the start). Enter an edge list, pick directed or undirected, and an exhaustive backtracking search either returns a concrete path and cycle or proves that none exists. Capped at 12 vertices for speed. Pick whichever matches what you're starting from — both are free.
Where do the figures come from?
The algorithms are the textbook ones and their results are exact for the graph you enter. What varies is cost: several of these problems have no known efficient solution, so large inputs are answered by heuristic and the tool says when that is the case.