Campus Mapper

A live version of my A-level project. It finds the quickest walking route between two Cambridge colleges. Press play and watch Dijkstra's algorithm work, step by step.

FitzMagdaleneSt John'sChurchillTrinityCaiusSidneyClareKing'sEmmanuelQueens'Downing
Start
Destination / working
Locked in
Final route
Tip: click any college to re-route.
Start
Destination
Speed
How it works
1
Start at zero
The start college is 0 minutes away. Every other college is unknown (infinity).
2
Pick the closest
Take the unvisited college with the smallest distance and lock its value in as final.
3
Update neighbours
For each neighbour, check if going through this college is quicker. If so, lower its distance.
4
Trace the route
Once the destination is locked in, follow the saved steps backwards to read off the route.

The numbers on the lines are walking minutes between colleges. Dijkstra's algorithm always expands from the closest known college first, which guarantees that once a college is locked in, no shorter route to it can exist. The exam required me to write the supporting data structures by hand, so the original program uses my own hash map and queue, with the college graph stored in a SQLite database.