Explore BFS, DFS, Dijkstra & A* algorithms with 5 Saudi cities for clear learning
Simplified network: Riyadh → Qassim → Medina → Jeddah → MakkahThis simplified 5-city network provides 2 distinct paths from Riyadh to Makkah:
BFS explores all nodes at the current depth level before moving to nodes at the next depth level. It guarantees finding the shortest path in unweighted graphs.
Select an algorithm above and click "Next Step" to begin the search, or click "Auto Play" for automatic visualization.
Current Status: Ready
Not exactly! Our demo shows different types of pathfinding problems. Only Dijkstra and A* solve the true "shortest path problem" (minimum distance). BFS and DFS solve different optimization problems entirely.
Goal: Minimize total distance/cost
Algorithms: Dijkstra, A*
Our Result: Riyadh → Jeddah → Makkah (929km)
Goal: Minimize number of intermediate stops
Algorithm: BFS
Our Result: Riyadh → Jeddah → Makkah (2 stops)
Goal: Find any route to destination
Algorithm: DFS
Our Result: Either route (depends on search order)
| Algorithm | Path Found | Distance | Hops |
|---|---|---|---|
| Dijkstra | Direct Route | 929km | 2 |
| A* | Direct Route | 929km | 2 |
| BFS | Direct Route | 929km | 2 |
| DFS | Variable | Variable | 2 or 4 |