Tutorials Books Videos Forums

Change the theme! Search!
Rambo ftw!

Customize Theme


Color

Background


Done

Dijkstra Lab

by kirupa   |   filed under Data Structures and Algorithms

This lab will allow you to test your knowledge of what you saw earlier in Dijkstra's Shortest Path Algorithm with practical examples. The default graph asks you to find the cheapest path from node A to node F. Generate weighted node networks, create your own nodes and edges, and then step through Dijkstra's algorithm as it gradually discovers the cheapest path.

Dijkstra Graph Lab

Select or drag nodes. Dijkstra is waiting patiently.

0 nodes
0 edges
0 steps

Goal: A to F

Generate a graph or run an algorithm to begin.

0 / 0

Tip: drag nodes to rearrange the graph. Use Customize to generate graphs, add nodes, connect edges, and choose start/end nodes.

Customize Graph

Generate a fresh graph, edit nodes and edges, or choose endpoints for the next shortest-path run.

Node Generator

Custom Editing

Use these when you want to make the graph misbehave in a very educational way.

Shortest Path

Algorithm Steps

Step What Happened

Dijkstra Result

No run yet.

Distance Notes

Node Best Known Cost Came From Status

What to Look For

Dijkstra's algorithm cares about the total cost of the edges, not just the number of connections between nodes. When the graph has uneven weights, the path with fewer hops is often not the cheapest path. That mismatch is where the algorithm earns its snacks.

The generator always creates a connected graph first, then adds extra weighted edges based on the density slider. That means Dijkstra should usually have a valid route to discover, while still leaving enough randomness for surprising paths to show up.

If you need a quick refresher, revisit the Dijkstra's Shortest Path Algorithm walkthrough and then come back here to keep experimenting.

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!

The KIRUPA Newsletter

Thought provoking content that lives at the intersection of design 🎨, development 🤖, and business 💰 - delivered weekly to over a bazillion subscribers!

SUBSCRIBE NOW

Creating engaging and entertaining content for designers and developers since 1998.

Follow:

Popular

Loose Ends

:: Copyright KIRUPA 2026 //--