Project Overview
This C++ console application simulates a city’s transportation network and finds optimal routes based on distance, travel time, and cost. It also introduces an AI-inspired congestion model that adjusts travel time during peak hours, and provides a step-by-step explanation of how the route was chosen (XAI).
Why I Built This Project
I built this project to practice designing a realistic routing system like the ones used in navigation and smart-city planning. I wanted to go beyond “shortest distance” and include real constraints (time, cost, congestion), while also improving how systems explain decisions.
This helped me strengthen both algorithmic thinking and software structure—especially modeling networks, managing weights, and reconstructing paths cleanly.
Problem Statement
Cities face congestion and route inefficiencies that increase travel time and cost. Navigation systems also often behave like “black boxes,” giving routes without showing why they’re optimal.
This project addresses these problems by simulating smart route selection using graph algorithms and providing transparent step-by-step reasoning for the final path (Explainable AI).
Technologies Used
- C++ for core system implementation
- Adjacency List using
map<int, vector<Edge>>for the road network - Dijkstra’s Algorithm for shortest-path computation with non-negative weights
- STL Data Structures:
map,vector,priority_queue,set - AI-inspired congestion prediction (peak-hour travel-time adjustment)
- XAI logging to explain each decision step
Key Features
- City network modeling: intersections as nodes, roads as weighted edges
- Shortest-path routing using Dijkstra (supports distance, time, cost metrics)
- AI-inspired congestion prediction (e.g., peak-hour travel time increases)
- Explainable routing (XAI): step-by-step reasoning for why nodes/paths were chosen
- Route management actions (add/update/remove routes) and network viewing
My Role in the Project
- Designed the network model and
Edgestructure for route data - Implemented Dijkstra using a min-heap (
priority_queue) for efficient node selection - Added congestion logic to adjust travel-time weights based on time windows
- Implemented path reconstruction and readable console explanations (XAI)
- Built modular functions for route management and reporting
Challenges Faced
- Designing weight calculations across multiple metrics (distance, time, cost) without breaking correctness
- Implementing Dijkstra cleanly with maps/priority queues and avoiding stale heap entries
- Reconstructing paths reliably (parent tracking) after the shortest distances are computed
- Making explanations readable and useful (XAI) instead of overwhelming logs
What I Learned
- How to model real transport networks using graphs and adjacency lists
- How Dijkstra behaves step-by-step, and how data structures impact performance
- How to extend a classic algorithm with realistic constraints (like congestion)
- How to produce transparent, explainable outputs for algorithmic decisions (XAI)
Project Access
The complete source code is hosted on GitHub:
- GitHub Repository: View Source Code
This is a C++ console application and can be compiled locally using a standard C++ compiler.
How to Run the Project
git clone https://github.com/Phumudzo2006/Smart-City-Route-Management-System.git
cd Smart-City-Route-Management-System
g++ main.cpp -o smart_city
./smart_city
If your compiler requires it, add -std=c++17:
g++ -std=c++17 main.cpp -o smart_city
Sample Output
SMART CITY ROUTE MANAGEMENT SYSTEM
----------------------------------
Step 1: Exploring node Downtown
--> Found path to University via Main_Street
Step 2: Exploring node University
--> Better path to Harbor via Coastal_Drive
Optimal Path:
Downtown → University → Harbor → Stadium
Total Distance: 27.5 km
Total Time: 42 minutes
Total Cost: $20.50
Future Improvements
- Add a GUI (Qt) to visualize the network and chosen routes
- Use real-time traffic simulation (dynamic edge weights) instead of fixed time windows
- Store routes in a database (SQLite) and load networks from files
- Generate analytics reports (average congestion impact, route comparisons, heatmaps)