Skip to content

25Rohit25/Traffic-Navigation-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RouteNavigator - Smart City Routing Engine

A C++ Traffic Navigation System that calculates optimal routes in a city network using Dijkstra's and A* algorithms.

Features

  • Graph-based Map: Models intersections as nodes and roads as weighted edges.
  • Pathfinding: Supports Dijkstra and A* algorithms.
  • Dynamic Routing:
    • Fastest Route (Time-based, considers traffic).
    • Shortest Route (Distance-based).
  • Traffic Simulation:
    • Update traffic levels (Low, Medium, High).
    • block/unblock roads.
  • Persistence: Save and load map data from CSV files.

Project Structure

  • include/: Header files.
  • src/: Source code.
  • data/: Sample CSV data (nodes.csv, roads.csv).

System Design

Class Diagram

classDiagram
    class App {
        -Graph graph
        -unique_ptr~Router~ router
        -unique_ptr~TrafficManager~ trafficManager
        +run()
    }
    class Graph {
        -unordered_map~int, Node~ nodes
        -unordered_map~int, vector~Edge~~ adjacencyList
        +addNode(Node)
        +addEdge(Edge)
        +getOutgoingEdges(int)
    }
    class Node {
        +int id
        +string name
        +double x, y
        +distanceTo(Node)
    }
    class Edge {
        +int sourceId, destId
        +double distanceKm
        +TrafficLevel trafficLevel
        +getEffectiveTime()
    }
    class Router {
        -Graph& graph
        +findShortestPathDijkstra()
        +findShortestPathAStar()
    }
    class TrafficManager {
        -Graph& graph
        +updateTrafficLevel()
        +blockRoad()
    }
    
    App --> Graph : Owns
    App --> Router : Uses
    App --> TrafficManager : Uses
    Router ..> Graph : Reads
    TrafficManager ..> Graph : Modifies
    Graph *-- Node
    Graph *-- Edge
Loading

Architectural Flow

graph TD
    User([User])
    CLI[App CLI Interface]
    TM[Traffic Manager]
    Router[Router Engine]
    Graph[Graph Data Structure]
    FileSys[(CSV Files)]

    User -->|Commands| CLI
    CLI -->|Load/Save| FileSys
    FileSys <-->|Parsing| Graph
    
    CLI -->|Update Traffic| TM
    TM -->|Modify Weights| Graph
    
    CLI -->|Find Route| Router
    Router -->|Query Nodes/Edges| Graph
    Graph -->|Return Path Cost| Router
    Router -->|Return Optimal Path| CLI
    CLI -->|Display Result| User
Loading

Build Instructions

Prerequisites

  • C++17 compliant compiler.
  • CMake (3.10+).

Steps

  1. Create a build directory:
    mkdir build
    cd build
  2. Generate build files:
    cmake ..
  3. Compile:
    cmake --build .
  4. Run:
    ./RouteNavigator
    # On Windows:
    RouteNavigator.exe
    Note: Ensure you run the executable from the project root (where data/ folder is located) or move the data/ folder to build/.

Input Format

  • nodes.csv: id,name,x,y
  • roads.csv: src,dest,distance,time,type
    • Types: 0 (Local), 1 (Highway), 2 (Expressway).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published