# Graph Shortest Path (Dijkstra Step-By-Step)

Dijkstra with a full per-iteration trace: settled nodes, relaxations, distance table, and the final path; undirected or directed, negative weights rejected, unreachable targets reported.

> Canonical page: https://elysiatools.com/en/tools/graph-shortest-path

- **Category:** Math & Numbers

- **Keywords:** dijkstra, shortest path, graph, weighted graph, distance table, relaxation, pathfinding, network, algorithm, discrete math

## Overview

The Graph Shortest Path tool computes the optimal route between nodes using Dijkstra's algorithm and provides a complete step-by-step trace of every iteration. It logs settled nodes, edge relaxations, distance updates, and the final reconstructed path for both directed and undirected weighted graphs.

## Inputs

- **Edges (one per line: from, to, weight)** (textarea): One edge per line: two node names (1–8 letters/digits) and a non-negative weight.
- **Source node** (text): e.g. A
- **Target node** (text): e.g. F
- **Treat edges as directed** (checkbox): When checked, each edge only leads from the first node to the second; otherwise the graph is undirected.
- **Decimal Places** (number)

## When to use

- Verifying manual Dijkstra calculations and distance tables for discrete mathematics or algorithm homework.
- Tracing step-by-step edge relaxation behavior to understand why a greedy route fails in complex networks.
- Finding the exact shortest distance and path between two vertices in weighted directed or undirected graphs.

## How it works

- Enter graph edges one per line as source, destination, and non-negative weight (e.g., 'A B 4').
- Specify the source and target node identifiers, and choose whether edges should be treated as directed.
- The tool initializes distances, greedily settles the node with the minimum tentative distance, and relaxes outgoing edges.
- View the generated per-iteration log, settled distance states, and the final shortest path reconstruction.

## Use cases

- Computer science students checking homework traces and edge relaxation steps for Dijkstra exam problems.
- Network engineers evaluating minimum latency or hop costs across simple routed network topologies.
- Instructors generating step-by-step textbook-style pathfinding traces for discrete math lectures.

## Frequently asked questions

### Can this tool handle graphs with negative edge weights?

No. Dijkstra's algorithm requires non-negative edge weights; negative values are rejected.

### How are ties broken when multiple nodes have the same tentative distance?

Ties are resolved deterministically using the lexicographically smallest node identifier.

### What happens if the target node is unreachable from the source?

The execution log traces all reachable settled nodes and reports the target as unreachable.

### Does the tool support directed graphs?

Yes. Enable the 'Treat edges as directed' checkbox to ensure edges only travel from source to destination.

### Can I use decimal numbers for edge weights?

Yes. Decimal weights are supported, and the decimal precision of the output can be customized.

## Related tools

- [Audio to Text Transcriber (AI)](https://elysiatools.com/en/tools/audio-to-text-transcriber): Transcribe speech from audio (wav/mp3/m4a/flac/ogg/webm/aac) to text, SRT, VTT or JSON using the grok-stt AI model. Up to 10 minutes.
- [Indented List to ASCII Tree](https://elysiatools.com/en/tools/ascii-tree-from-indented-list): Convert a 2-space / 4-space / Tab indented hierarchical list (Markdown bullets, -, *, 1. prefixes optional) into a copyable ASCII directory tree. Two styles: Unicode box-drawing (├──└──│) for GitHub/Discord and classic ASCII (|--\--|) for plain text. Toggles for full guide lines, trailing spaces, and bracketed leaf nodes like docs/\[api.md\].
- [Upside-Down Text](https://elysiatools.com/en/tools/upside-down-text): Flip text upside-down (ɥǝllo) with per-letter rotations, plus optional toggles to keep reading order and protect URLs/emails. Plain Unicode text, no font needed.
- [Assignment Problem Solver (Hungarian Algorithm)](https://elysiatools.com/en/tools/assignment-problem-solver): Textbook Hungarian algorithm for 2–8 × 2–8 assignment problems: row/column reductions, augmenting-path zero matching, König line covers, and substitution-verified optimal assignments.
- [Podcast Chapter Marker Builder](https://elysiatools.com/en/tools/podcast-chapter-marker-builder): Build every podcast chapter format from one timecoded list: Podcasting 2.0 JSON + RSS tag, ID3v2.4 CHAP+CTOC burned into an MP3, Vorbis comments, mp4chaps, YouTube timestamps and SRT, with a per-player support matrix.
- [Audio Melody Contour Extractor](https://elysiatools.com/en/tools/audio-melody-contour-extractor): Extract a dominant melody path from audio and export MIDI, note events, a pitch contour, SVG, and JSON in one ZIP.
- [Audio to Multitrack MIDI (Draft)](https://elysiatools.com/en/tools/audio-to-multitrack-midi): Split a full mix into stems (drums/bass/other/vocals) and transcribe each to MIDI — a multi-track starting point for transcription
- [Renal Drug Dose Adjustment Helper](https://elysiatools.com/en/tools/renal-dose-adjustment): Categorize renal function from creatinine clearance (CrCl) and provide FDA/KDIGO-aligned dosing guidance: Normal (CrCl ≥60) → standard dosing; Mild (30–59) → consider dose reduction or interval extension; Moderate (15–29) → reduction and/or extension typically required; Severe (<15) → significant reduction, many drugs contraindicated or post-dialysis only. Outlines two adjustment strategies: (A) interval extension for concentration-dependent drugs (aminoglycosides, vancomycin), (B) dose reduction for time-dependent drugs (β-lactams). Dialysis toggle flags the need for post-dialysis supplementation per the specific drug label. Derived from FDA Pharmacokinetics Guidance, the KDIGO Drug Dosing Consensus, and NIDDK guidance. This tool does NOT replace the FDA-approved package insert for any specific drug. Not medical advice.

## Samples

- [Path Analyzer Samples](https://elysiatools.com/en/samples/path-analyzer): Comprehensive collection of file system paths from Windows, Linux, and macOS for path analysis and testing
- [Import Path Examples](https://elysiatools.com/en/samples/import-path-examples): Collection of JavaScript and TypeScript import examples demonstrating various import patterns and module systems
- [ELK Stack Log Analysis Samples](https://elysiatools.com/en/samples/elk-stack-samples): Comprehensive ELK Stack (Elasticsearch, Logstash, Kibana) samples for log aggregation, processing, and visualization in distributed systems
- [Copyright-Free MP3 Audio Samples](https://elysiatools.com/en/samples/mp3-samples): Collection of royalty-free audio samples for testing and development purposes including nature sounds, meditation music, and ambient audio
