#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🗺️ FREE · STEP BY STEP

Dijkstra Algorithm Visualizer: Shortest Paths, One Step at a Time

Type edges with weights, choose a start node and replay every pick and relaxation on the graph.

  • 📍 Every relaxation shown
  • 📋 Distance table
  • ➡️ Full shortest paths

How to use the Dijkstra Algorithm Visualizer

  1. 1. Enter the graphOne edge per line, like A-B 4. Tick directed if edges go one way.
  2. 2. Pick a start nodeChoose where the shortest paths begin.
  3. 3. ReplayWatch the closest unfinished node get picked and its edges relaxed, with distances updated under each node.

Worked example

The sample graph has six nodes and nine undirected edges. From A, the algorithm first finalises A at 0, then C at 2. Relaxing C–B gives B a distance of 2 + 1 = 3, better than the direct edge A–B of 4. B then improves D to 3 + 5 = 8, D gives E 8 + 2 = 10 (beating C–E's 12), and E gives F 10 + 2 = 12 (beating D–F's 14). The final paths include A → C → B → D → E → F for F. The replay has 17 steps.

How it works

Dijkstra keeps a tentative distance for every node, starting with 0 for the source and ∞ for the rest. Each round it takes the unfinished node with the smallest distance, which is now final, and checks each edge from it: if going through this node is shorter, the neighbour's distance and previous node are updated. With a binary heap this runs in O((V + E) log V). Ties are broken alphabetically here so the replay is predictable.

Negative weights

Dijkstra assumes a finalised distance can never improve, which is false when edges can be negative. The tool refuses negative weights for that reason; use Bellman-Ford, which handles them and detects negative cycles. For unweighted graphs, plain BFS finds shortest paths faster.

Frequently asked questions

Can I use directed graphs?

Yes. Tick directed edges and A-B means only A → B.

How many nodes can I use?

Up to 14, so the drawing stays readable.

What if a node can't be reached?

Its distance stays ∞ and it's listed as unreachable.

Is the Dijkstra visualizer free?

Yes. Everything in the Dijkstra visualizer works without signing up. The first time you ask for a result, we ask once for your name and WhatsApp number; after that the Dijkstra visualizer and every other Uncodemy tool open straight away.

More free tools

See all free tools