← Back to all tools

🗺️ Find the Shortest Route

GCSE route costs · Dijkstra extension

Calculate and compare route costs for GCSE. Then explore how Dijkstra’s algorithm finds a minimum-cost route in the A-level extension.

CS GCSE (2025) §1.3.1CS A-level Units 3 and 4
Extension / A-level: open Dijkstra’s algorithm and graph builder

🤔 What is Dijkstra's algorithm?

Dijkstra's algorithm finds the shortest path between two points in a network with weighted connections. It's used everywhere - from GPS navigation to internet routing to finding cheapest flights!

🍕 Analogy: Imagine you're in a maze where each path has a toll fee. Dijkstra's is like having a smart guide who always knows the cheapest route to any destination!
⚙️

Controls

Not yet checked
Waiting to check
Checking now
Done
Shortest route
👋 A map is already loaded! Choose a start and end location above, then click ▶ Find Route to watch the algorithm find the shortest path. Or click ⏭ Step to go one step at a time.
Choose a start and end location, then click ▶ Find Route.
📊

Distance Table

LocationCostCame fromStatus
📋

Graph Representation

CS A-Level Unit 3

There are two ways to represent a graph (network) in a computer's memory. Click to see each one for your current map:

Matrix = a grid showing the cost between every pair of locations (0 = no direct road). Good for dense graphs.
List = each location lists only its neighbours. Good for sparse graphs (fewer roads).

The animation uses a sorted array for clarity. The heap-based complexity shown below describes an efficient implementation; sorting the queue repeatedly here can cost more.

💡

How does it work?

Dijkstra's algorithm finds the shortest route - like a sat-nav working out directions.

  1. Start at your chosen location. It costs 0 to be here. Everywhere else starts as "unknown" (∞)
  2. Look around: Check all roads from where you are
  3. If cheaper route found - update the cost and remember how you got there
  4. Mark as "done" - cheapest way here is confirmed
  5. Move to cheapest unvisited location and repeat
  6. Stop when you reach the destination!
Efficient heap version
O((V+E) log V) with a heap
Memory
O(V+E) for graph and queue
📝

Exam Tips

  • GCSE: It finds the shortest weighted path - not just fewest steps. A route with 5 hops costing 2 each (total 10) beats a route with 2 hops costing 8 each (total 16)
  • A-Level: Know it uses a priority queue of unvisited nodes, always picking the one with the lowest cost
  • Key point: Dijkstra's does NOT work with negative edge weights - use Bellman-Ford for that
  • Extension practice: use the distance table to follow Dijkstra’s steps. Current GCSE 1.3 asks for route-cost calculation; it does not specify a Dijkstra trace table.
  • Real world: Google Maps, Uber route planning, network routing protocols (OSPF) all use variants of this