RouteWiseAlgorithm Deep Dive
ALGOfest 2026 — Algorithm Deep Dive

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?

❌ Dijkstra's Algorithm

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.

❌ Greedy Nearest Neighbour

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.

❌ Dynamic Programming (TSP)

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* Search Algorithm — Our Choice

A* combines the best of Dijkstra (guaranteed optimality) with a heuristic function that guides the search toward the goal — dramatically reducing unnecessary exploration.

f(n) = g(n) + h(n)
g(n) = actual cost from start
h(n) = heuristic estimate to goal
f(n) = total estimated path cost
✅ 2-opt Local Search Improvement

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

AlgorithmTime ComplexitySpace ComplexityReal-time Feasible?
Greedy Nearest NeighbourO(n²)O(n)⚠️ Barely
Dijkstra'sO(V² + E)O(V)❌ No heuristic
Dynamic Programming (TSP exact)O(n² × 2ⁿ)O(n × 2ⁿ)❌ Exponential
RouteWise A* + 2-optO(n log n)O(n)✅ <2 seconds

🚀 Scalability Story

Can RouteWise handle 10,000 users? 1 million routes? Here's the answer.

Today
👥 50 vehicles
🗺️ 500 routes/day
&lt;2s per re-route
✅ Live now
Phase 2
👥 10,000 users
🗺️ 100K routes/day
&lt;5s with caching
🔧 Redis + queue
Phase 3
👥 1M+ routes
🗺️ Enterprise scale
Distributed A*
📐 Microservices

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