The Algorithm Behind RouteWise
RouteWise is not just a product. It is an algorithmic solution to one of Lagos's most expensive problems. Here is exactly how it works — mathematically, computationally, and practically.
Why A* and not Dijkstra, Greedy, or Dynamic Programming?
Finds shortest path but explores ALL nodes uniformly. No heuristic — wastes time evaluating irrelevant Lagos zones far from the delivery path. O(V²) or O(E log V). Too slow for real-time re-routing.
Always picks the closest next stop. Fast but produces routes 20-35% longer than optimal. No global awareness. Used as our baseline to prove RouteWise superiority.
Exact solution for Travelling Salesman Problem but O(n² × 2ⁿ) — completely infeasible for real-time use. With 10 stops, that's 102,400 operations per re-route. Unusable at scale.
A* combines the best of Dijkstra (guaranteed optimality) with a heuristic function that guides the search toward the goal — dramatically reducing unnecessary exploration.
After A* finds the initial route, we run 2-opt passes — swapping pairs of route segments to find shorter alternatives. This is the same technique used by Google Maps and enterprise logistics platforms.
📊 Time & Space Complexity
| Algorithm | Time Complexity | Space Complexity | Real-time Feasible? |
|---|---|---|---|
| Greedy Nearest Neighbour | O(n²) | O(n) | ⚠️ Barely |
| Dijkstra's | O(V² + E) | O(V) | ❌ No heuristic |
| Dynamic Programming (TSP exact) | O(n² × 2ⁿ) | O(n × 2ⁿ) | ❌ Exponential |
| RouteWise A* + 2-opt | O(n log n) | O(n) | ✅ <2 seconds |
🚀 Scalability Story
Can RouteWise handle 10,000 users? 1 million routes? Here's the answer.
Key insight: Because A* runs in O(n log n) and our graph has a fixed number of Lagos zones (20), the algorithm complexity stays constant regardless of order volume. Only the priority queue grows — and that scales linearly with active vehicles.
See the algorithm in action — step by step