TSP Route Planner & Visualizer

Solve the Traveling Salesman Problem across 30 major Pakistani cities with multiple algorithms

⚙️

Multiple Algorithms

Implement and compare Nearest Neighbor, Brute Force, and Held-Karp algorithms for solving TSP.

📈

Performance Analysis

Compare execution times, solution quality, and complexity across different algorithmic approaches.

🗺️

Real-World Data

Uses 30 major Pakistani cities with authentic GPS coordinates for practical route optimization.

🎯

Interactive Selection

Choose your starting city and watch algorithms build optimal routes in real-time.

Fast Execution

Optimized implementation with efficient distance calculations and memory management.

🎓

Educational Focus

Well-documented code demonstrating algorithm design patterns and complexity analysis.

Interactive Algorithm Visualizations

Select Starting City

Currently Selected: Karachi

1. Nearest Neighbor (NN) - O(n²)

Greedy heuristic that selects the closest unvisited city at each step. Fast but may not be optimal. Click Play to watch it explore the map of Pakistan!

0 kmTotal Distance
0 msExecution Time
30Cities Visited
ReadyStatus
Time Complexity: O(n²)
Space Complexity: O(n)

2. Brute Force (BF) - O(n!)

Exhaustively examines all possible permutations to guarantee the optimal solution. Watch it explore all paths across Pakistan!

0 kmBest Distance
0 msExecution Time
0Paths Explored
ReadyStatus
Time Complexity: O(n!)
Space Complexity: O(n!)

3. Held-Karp (DP) - O(n²2ⁿ)

Optimal algorithm using dynamic programming with better scalability than brute force. See the optimal solution being built across Pakistan!

0 kmOptimal Distance
0 msExecution Time
0Subsets Computed
ReadyStatus
Time Complexity: O(n²2^n)
Space Complexity: O(n2^n)

Project Statistics

30
Pakistani Cities
3
Core Algorithms
~7K
Optimal Tour (km)
100%
Interactive

Pakistan Cities Dataset

This project uses authentic geographic data of 30 major cities across Pakistan. Each city includes precise latitude and longitude coordinates from the Pakistan coordinate system, enabling accurate distance calculations for route optimization.

The dataset covers all regions of Pakistan from northern mountain cities like Islamabad to southern coastal areas like Karachi, providing a comprehensive geographic diversity for TSP analysis.

Dataset Includes

  • Major metropolitan areas
  • Regional city centers
  • Northern mountain regions
  • Southern coastal zones
  • Eastern and western boundaries
  • Precise geographic coordinates
  • Haversine distance calculation
  • Real-world route optimization

Quick Start Guide

Installation

git clone https://github.com/Viblla/CS-378_Sem_Project.git cd CS-378_Sem_Project pip install -r requirements.txt

Run with Nearest Neighbor

python daa_project_2022064.py # Select: 0 (start city) # Select: 30 (number of cities) # Select: nn (algorithm)

Compare All Algorithms

python daa_project_2022064.py # Select: 0 (start city) # Select: 15 (number of cities) # Select: all (run comparison)

Interactive Jupyter Notebook

jupyter notebook DAA_Project_2022064.ipynb