A simple Flask-based web application that visualizes and computes the shortest path between locations using Dijkstra's Algorithm or A* search.
The app renders an interactive map (via Leaflet.js) and lets users click two points to find the optimal route.
- Graph-based city map with nodes and edges.
- Two pathfinding algorithms:
- Dijkstra's Algorithm
- A* Search (Euclidean heuristic)
- Interactive UI using Leaflet.js and OpenStreetMap tiles.
- Path visualization on the map with route cost.
- Simple and beginner-friendly Python implementation.
.
├── app.py # Flask backend server
├── smart\_traffic\_core.py # Graph structure & algorithms
├── templates/
│ └── index.html # Frontend UI with Leaflet map
└── README.md # Project documentation
1️⃣ Clone the repository
git clone https://github.com/yourusername/smart-traffic-optimizer.git
cd smart-traffic-optimizer2️⃣ Install dependencies
pip install flask3️⃣ Run the application
python app.py4️⃣ Open in browser Visit:
http://127.0.0.1:5000/
- Select the algorithm (Dijkstra or A*).
- Click a start node on the map.
- Click a destination node.
- The optimal route will be drawn in red, and the total cost will be displayed.
-
Dijkstra's Algorithm Finds the shortest path from a source to all nodes in a weighted graph.
-
A* Search Uses a heuristic (Euclidean distance) to guide the search, often faster for large maps.
Both algorithms use a min-heap priority queue (heapq) for efficiency.
This project is licensed under the Apache License 2.0 — you are free to use, modify, and distribute it.
Pull requests are welcome! If you find a bug or want to add features, feel free to fork this repo and submit a PR.
- Flask for backend framework
- Leaflet.js for interactive maps
- OpenStreetMap for map tiles