← All tools

Shortest Path (Dijkstra)

Find the shortest path between nodes in a weighted graph with Dijkstra's algorithm. Enter edges as from to weight (one per line), choose directed or undirected, pick a source, and the tool computes the minimum distance to every node plus the actual path to a target. Reports unreachable nodes. Everything runs locally in your browser.

Edges (one per line: from to weight)

Nodes are labels (letters/words). Weight is optional (defaults to 1). Example: A B 4.

Graph type
Source node
Target (optional)

Result

Distance table from source

Dijkstra's algorithm grows a settled set from the source, repeatedly relaxing the unsettled node with the smallest tentative distance. It requires non-negative edge weights (negative weights need Bellman-Ford). The predecessor array reconstructs the actual path. For unweighted graphs (all weights 1) it reduces to BFS. The shortest path in a graph with non-negative weights is itself a simple path (no repeated nodes). Pairs with the Maze Generator and Matrix Calculator tools. Everything runs locally — nothing leaves your browser.