Travel Metro is a Spring Boot based metro route optimization system that models realistic Delhi Metro traversal using graph-based routing and dynamic transit simulation.
The project allows users to:
- Select source and destination stations
- Compute optimized metro routes
- Simulate realistic traversal conditions
- Visualize routes using interactive Leaflet maps
Unlike traditional shortest-path implementations, the routing engine incorporates dynamic runtime edge weighting based on waiting time, traffic behavior, rush-hour congestion and interchange overhead.
The backend architecture is centered around a dynamically constructed weighted graph representation of the metro network.
- Stations are modeled as graph nodes
- Metro connections are modeled as weighted edges
- Graph topology is loaded from MongoDB
- Graphs are cached in memory for fast traversal
| Component | Responsibility |
|---|---|
| MongoDB | Station topology storage |
| GraphService | Graph construction |
| TransitWeightService | Dynamic edge weighting |
| TraversalTimeManager | Runtime time simulation |
| Dijkstra Engine | Route optimization |
| Leaflet.js | Route visualization |
The routing engine uses Dijkstra’s algorithm to compute optimized traversal paths across metro stations.
Instead of using only geographical distance, traversal weights are dynamically calculated using contextual transit behavior.
| Weight Component | Purpose |
|---|---|
| Base Travel Time | Core station traversal |
| Waiting Time | Platform delay simulation |
| Peak Hour Penalty | Office rush-hour impact |
| Weekday Traffic Factor | Realistic weekday behavior |
| Interchange Penalty | Platform transfer overhead |
The project introduces runtime traversal simulation using the TraversalTimeManager.
As traversal progresses through the graph, accumulated travel time is tracked continuously. This enables contextual edge weighting based on the estimated arrival time at each station.
The system therefore simulates:
- Office rush-hour congestion
- Weekday traffic behavior
- Dynamic waiting penalties
- Realistic transit conditions
Interchange penalties are applied only when traversal switches metro lines.
This prevents unrealistic traversal inflation while accurately modeling platform transfer delays inside major interchange stations such as:
- Rajiv Chowk
- Kashmere Gate
| Traversal Behavior | Penalty Applied |
|---|---|
| Same-Line Continuation | No |
| Metro Line Switch | Yes |
The Blue Line contains multiple branches.
The graph initialization layer models branch topology independently to prevent invalid cross-branch traversal and preserve realistic metro connectivity constraints.
The frontend layer uses Thymeleaf together with Leaflet.js for interactive metro visualization.
- Interactive metro rendering
- Dynamic route highlighting
- Station marker visualization
- Autocomplete station selection
- Compact route summaries
| Concept | Usage |
|---|---|
| Adjacency List Graph | Metro topology modeling |
| Dijkstra Traversal | Route optimization |
| Dynamic Edge Weighting | Transit simulation |
| Haversine Formula | Distance calculation |
| In-Memory Graph Cache | Traversal optimization |
| Runtime Time Simulation | Context-aware routing |
travel-metro/
│
├── backend/
│ ├── services/
│ ├── controllers/
│ ├── graph/
│ └── traversal/
│
├── frontend/
│ ├── templates/
│ ├── static/
│ └── leaflet/
│
├── assets/
│
└── README.md- Full Delhi Metro network support
- Fare estimation system
- Live metro timing integration
- Predictive crowd analytics
- Multi-objective route optimization
- Distributed graph caching
git clone https://github.com/YOUR_USERNAME/travel-metro.gitcd travel-metro./gradlew bootRunhttps://metro-router-production.up.railway.app/```






