Paths & Graphs
Italy Route Explorer
Choose two Italian cities, select a search method and watch how the program finds the shortest path. Compare four different approaches on the same route.
This demo starts with a simple question: how does a program find the shortest path between two cities? It's not just academic curiosity. The same logic powers GPS navigation, delivery systems, transport planning, and video games.
The point is that there are different ways to approach it, each with its own strengths and trade-offs. Here you can watch all four work on the same Italian cities and understand, with your own eyes, why they behave differently.
The four methods compared
Each method approaches the problem differently. Some always guarantee the best path, others trade accuracy for speed. Choosing the right one depends on context: how large is the network? How much does precision matter? Do you already know roughly where the destination is?
Dijkstra
Searches in all directions and always guarantees the shortest path. Precise but slower on large networks because it doesn't use information about the destination's position.
A* (A-star)
Like Dijkstra, but steers toward the destination using straight-line distance. Faster without losing the guarantee of finding the optimal path.
Breadth-First Search
Explores level by level, starting from nearby cities. Works well when all connections have the same cost, but ignores real distances.
Greedy Best-First
Always moves toward what looks closest to the destination. Fast, but can get the wrong path because it ignores the cost of segments already traveled.
What you learn watching this demo
- Why some methods always find the best path while others can get it wrong
- How the cost of each road segment completely changes the final result
- The difference between exploring systematically and aiming directly at the goal
- How much work the program does: how many cities it visits before reaching the answer
- Why a "smarter" method is not always the one that explores less
How to use the demo
Select a starting city and a destination on the map. Choose the search method from the menu. Press Play to watch the automatic animation, or Step to advance one step at a time and observe every single decision the program makes.
Try running multiple methods on the same route: you'll see different cities highlighted during exploration, final paths of different lengths, and a counter showing how many stops were visited before finding the solution.
These concepts are used every day in professional development
Want a method to apply them on your real code, with a senior architect at your side?
Try the demo
Select start and destination, choose the method and watch. Use Play for automatic animation or Step to advance manually.
Drag: pan
Alt + mouse: tilt 3D
Clic nodo: alterna start/end