How lokesh-reddy18/dijkstra-travel-planner works
Project Type and Purpose
• This is a C++ command-line travel route planner (an open-source DSA/tool project) that demonstrates Dijkstra’s algorithm.
• It reads city and route data from CSV files, builds an in-memory graph, runs shortest-path searches (fastest/cheapest), and emits an HTML file with a Leaflet/Google Maps visualization.
File Structure Analysis
• Top-level files:
• Main.cpp – entry point, CLI interface
• GraphFunctions.h – graph construction & Dijkstra implementation
• FileOperations.h, Parser.h – CSV parsing & file I/O utilities
• cities.csv, routes.csv – data sources
• output.html – generated visualization
• travel.make – build script
• There is a clear layering: Presentation (CLI), Infrastructure (I/O, parsing), Domain/Algorithms (graph & Dijkstra), and Output (HTML/Leaflet).
Key README Insights
• Uses adjacency-list graph, priority-queue (min-heap), stack for path reconstruction.
• Supports modes: plane/train/bus; cost multiplier for planes.
• Generates an HTML with embedded Leaflet map (external API).
• No persistent database—flat files only.
Components
• cities.csv
• routes.csv
b. Infrastructure Layer (rectangles)
• CSV Parser (Parser.h)
• FileOperations (FileOperations.h)
c. Domain & Algorithm Layer (stacked rectangles)
• Location & Route classes
• Graph Builder (adjacency list)
• Dijkstra Engine (GraphFunctions.h)
• Path Reconstructor (using stack)
d. Presentation Layer
• CLI Module (Main.cpp): user prompts, collects parameters
e. Output Layer
• HTML Generator (writes output.html, embeds Leaflet scripts)
• Leaflet / Google Maps for map tiles & visualization
Relationships and Data Flows
• FileOperations ↔ Parser (reads/writes)
• Graph Builder → Dijkstra Engine → Path Reconstructor
• CLI Module → (triggers) Algorithm Layer → HTML Generator
• HTML Generator → Output File → Browser + Leaflet Service
Architectural Patterns & Principles
• Layered Architecture: separates I/O, domain logic, UI, and external integration
• Single Responsibility: each module (parsing, graph logic, CLI, HTML gen) has its own file
• Modular Domain Model: Location and Route encapsulate data, easing graph construction
• Algorithmic Core: Dijkstra encapsulated in GraphFunctions for reusability/testing
Detailed Capture of Essential Elements
• Be explicit about:
• Input parameters (origin, destination, preference) flowing from CLI to Algorithm
• Graph representation structure (adjacency lists)
• Priority queue usage in Dijkstra
• Path reconstruction step
• HTML templating and Leaflet API calls