Real GPS data: Optimal pathfinding with f(n) = g(n) + h(n)
Combines actual cost + heuristic estimate • Guaranteed optimal solutionA* uses the evaluation function f(n) = g(n) + h(n) where:
This demo uses actual road distances for g(n) and straight-line GPS distances for h(n):
A* will find the cheapest total distance route, not just the fewest hops!
Click "Next Step" to begin A* search from Riyadh to Makkah, or click "Auto Play" for automatic visualization.
Current Status: Ready
| Algorithm | Function | Optimal? |
|---|---|---|
| BFS | Fewest hops | Unweighted only |
| Dijkstra | g(n) only | Yes |
| Greedy | h(n) only | No |
| A* | g(n) + h(n) | Yes* |
A* will find the optimal 929km route (Riyadh → Jeddah → Makkah) because: