An intelligent C++ console-based transportation network simulator that models a city’s road system using graph theory and finds optimal routes using Dijkstra’s Algorithm with AI-based congestion prediction and Explainable AI (XAI).
Modern cities struggle with:
This project simulates a smart city routing system that:
It also includes:
✔ AI-inspired congestion adjustment
✔ Step-by-step decision explanations (XAI)
✔ Route searching and sorting features
| Concept | Implementation |
|---|---|
| Programming Language | C++ |
| Graph Representation | Adjacency List (map<int, vector<Edge>>) |
| Pathfinding Algorithm | Dijkstra’s Algorithm |
| Data Structures | Map, Vector, Priority Queue (Min-Heap), Set |
| AI Feature | Time-based congestion prediction |
| XAI | Detailed step-by-step path reasoning |
Find the shortest path based on:
Simulates real-world traffic: | Time | Traffic Condition | Effect | |——|——————|——–| | 7–9 AM | Morning Peak | +50% travel time | | 5–7 PM | Evening Peak | +50% travel time | | Other hours | Normal | No change |
The system explains:
struct Edge — Represents roads between intersectionsmap<int, vector<Edge>> — Adjacency list for the city networkpriority_queue — Efficient shortest path node selectionmap<int, double> — Stores shortest distancesmap<int, int> — Stores parent nodes for path reconstructionThe system initializes with:
| Node ID | Location |
|---|---|
| 1 | Downtown |
| 2 | Airport |
| 3 | University |
| 4 | Harbor |
| 5 | Stadium |
```bash g++ main.cpp -o smart_city
Run: ./smart_city
Example Output 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