README_TrafficSignal.
txt
# Traffic Signal Control System (C Program)
This project simulates a simple **traffic signal control system** using C. It uses a
**priority queue** to manage vehicle flow at an intersection and a **graph structure**
model a basic road network. The system also includes logic to adjust signal timings bas
on queue length.
---
## Ὢ Features
- **Graph-Based Road Network**
Represents a road system using an adjacency matrix with weighted edges indicating t
times between intersections.
- **Priority Queue for Vehicles**
Vehicles are added to a queue based on priority (e.g., emergency vehicles, VIPs). The
lower the priority number, the higher the actual priority.
- **Dynamic Signal Timing Adjustment**
Based on the number of vehicles in the queue, the system prints recommendations to
adjust the green light duration:
- Increase if queue > 10
- Maintain if 6–10
- Decrease if ≤ 5
---
## ᾞ How It Works
1. **Initialize the Graph**
- Nodes represent intersections.
- Weighted edges represent travel time between intersections.
2. **Vehicle Queue Management**
- Vehicles are enqueued with their priorities.
- Vehicles are dequeued in order of priority for intersection passage.
3. **Adjust Signal Timing**
- Based on `currentQueueLength`, signal timing is adjusted and recommended on-sc
---
## ᾞ Sample Output
```
Dequeuing vehicles based on priority:
Vehicle 2 passed the intersection.
Vehicle 1 passed the intersection.
Vehicle 3 passed the intersection.
Current queue length: 8
Maintain current green light duration.
```
---
## Ὦ️ How to Compile and Run
### Requirements:
- GCC Compiler
### Compile:
```bash
gcc -o traffic_signal traffic_signal.c
```
### Run:
```bash
./traffic_signal
```
---
## Ὄ File Structure
```
traffic_signal.c # Main C source file
README.md # Project documentation
```
---
## Ὄ Notes
- The program currently supports up to 10 nodes (`MAX_NODES`).
- This is a simplified simulation. Real-world traffic systems use sensors, adaptive timing
algorithms, and real-time data analytics.
---
## ᾝὋ Author
Developed as a conceptual demonstration of combining **data structures** and **traff
control logic** in C.
---
## Ἴ Future Improvements
- Implement Dijkstra's algorithm to find shortest paths in the graph.
- Integrate real-time sensor data input (simulated).
- Use dynamic memory for flexible queue and graph sizing.
Madhav.txt
Project Title:
Smart Traffic Management System Using Graphs and Priority Queues
Problem Statement:
Urban areas often suffer from severe traffic congestion, leading to increased travel
times, fuel consumption, and pollution. Current traffic management systems do not
dynamically adapt to real-time traffic conditions, resulting in inefficient flow and
delays. This project aims to design a smart traffic management system that optimizes
traffic flow at intersections by using real-time data to dynamically adjust signal timings
and suggest optimal routes to vehicles.
Data Structures Used and Justification:
Graphs:
Representation of the city’s road network (nodes as intersections, edges as roads).
Useful for implementing path-finding algorithms (e.g., Dijkstra’s) to determine shortest
or least-congested paths.
Priority Queues (Min-Heaps):
Used to manage vehicle flow based on urgency and congestion levels.
Efficiently identifies vehicles/roads that should be prioritized.
Hash Maps:
Store traffic density, signal timings, and real-time updates efficiently.
Queues:
Model the waiting vehicles at signals.
Expected Outcome:
A simulation or prototype that dynamically manages traffic signals based on real-time
data.
Reduced average wait time at intersections.
Optimized vehicle routing with minimal congestion.
A visual representation of traffic flow and management decisions.