A full-stack route optimization application built with a focus on graph algorithms, specifically Dijkstraโs shortest path algorithm, to compute optimal metro routes in Delhi. Users can select source and destination stations and receive:
- ๐ค๏ธ Step-by-step route
- ๐ Interchanges
- โฑ๏ธ Time / ๐ Distance
- ๐ฐ Fare calculation
- ๐บ๏ธ Interactive Metro Map
- ๐ Downloadable PDF route
This project was built to demonstrate the real-world application of graph data structures and Dijkstraโs algorithm in metro navigation and routing systems.
- Graph (Adjacency Map): Each station is a node; connections are weighted edges (distance in km or time in seconds).
- Min-Heap: Custom priority queue used for Dijkstra's efficient shortest path computation.
- Dijkstraโs Algorithm: Finds the optimal path from source to destination using a min-cost traversal.
- HashMaps: For storing vertex data and visited tracking.
- Custom Pair structures: For maintaining cost, path-so-far, and time during traversal.
| Feature | Description |
|---|---|
| ๐ Station Autocomplete | Easy-to-search source & destination fields |
| ๐ง Dijkstra Optimization | Fast, accurate path calculation |
| ๐งญ Distance / Time Mode | Choose based on preference |
| ๐ Interchange Detection | Counts and displays interchange points |
| ๐งพ Fare Estimator | Based on distance bands |
| ๐บ๏ธ Interactive SVG Metro Map | Route path visualized, with a legend |
| ๐จ Responsive UI | React + Tailwind CSS (warm theme) |
| Layer | Tech Used |
|---|---|
| Frontend | React 18 + TypeScript + Tailwind |
| State/API | React Query + Axios |
| Backend | Node.js + Express + TypeScript |
| Graph Logic | Custom JavaScript Dijkstra Engine |
Implemented as:
- Priority Queue with
MinHeap<T>(custom-built) - Relaxation of neighbors based on edge weights
- Supports both:
- Distance-based mode (edge weight = distance)
- Time-based mode (edge weight =
120 + 40 * distanceseconds)
- Based on station line suffixes (
~B,~Y, etc.) - Compares line transitions in the route
- Labels interchanges like:
Janak Puri~B ==> Dwarka~Y
# Clone the repo
git clone https://github.com/yourusername/metro-route-finder.git
cd metro-route-finder
# Install backend
cd server
npm install
npm run dev
# In another terminal, start frontend
cd ../client
npm install
npm run dev