Real GPS data: 6 Saudi cities with actual distances and coordinates
h(n) = straight-line distance to Makkah • Now includes Taif (90km from Makkah)Expansion rule: Expand the node that has the lowest value of the heuristic function h(n).
This demo uses real GPS coordinates and actual road distances between Saudi cities. The heuristic h(n) represents the straight-line distance to Makkah:
Greedy search will always choose the city with the lowest h(n) value first!
Click "Next Step" to begin Greedy Best-First search from Riyadh to Makkah, or click "Auto Play" for automatic visualization.
Current Status: Ready
| Property | Greedy | A* |
|---|---|---|
| Evaluation | h(n) only | f(n) = g(n) + h(n) |
| Optimality | Not guaranteed | Guaranteed* |
| Speed | Fast | Slower |
| Memory | Less | More |
Always expand the frontier node with the lowest h(n) value - the one that appears closest to the goal according to the heuristic.
Greedy search will prioritize cities with the lowest h(n) values. From Riyadh, it has three options with these heuristic values:
Greedy Decision: Will choose Jeddah first (lowest h(n) = 65km), then directly to Makkah.
The straight-line distances are calculated using the Haversine formula, which accounts for the spherical nature of Earth:
d = 2R × arcsin(√(sin²(Δlat/2) + cos(lat₁) × cos(lat₂) × sin²(Δlng/2)))
where R = 6,371km (Earth's radius)