A Django-based web application for managing airport routes in a binary tree structure. This application allows users to create, visualize, and analyze routes between airports.
- Airport Management: Add airports as nodes in a binary tree structure
- Tree Visualization: View the airport network as a binary tree
- Route Analysis:
- Find the shortest route between two airports
- Find the longest route in the network
- Calculate path lengths between airports
Airport/
├── config/ # Django project settings
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── routes/ # Main application
│ ├── models.py # AirportNode model
│ ├── views.py # View functions
│ ├── forms.py # Django forms
│ ├── urls.py # URL routing
│ └── migrations/ # Database migrations
├── static/ # Static files (CSS, JS, images)
├── templates/ # HTML templates
│ ├── base.html
│ ├── home.html
│ ├── longest_route.html
│ ├── path_length.html
│ └── shortest_route.html
├── db.sqlite3 # SQLite database
└── manage.py # Django management script
- Backend: Django 6.0.4
- Database: SQLite3
- Frontend: HTML, CSS, JavaScript
- Python: 3.x
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- Windows:
venv\Scripts\activate - Linux/Mac:
source venv/bin/activate
- Windows:
-
Install dependencies:
pip install django
-
Run migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
-
Access the application: Open your browser and navigate to
http://127.0.0.1:8000/
- Navigate to the home page
- Use the airport form to add a new airport
- Specify:
- Airport code (e.g., "JFK", "LAX")
- Parent airport (if not root)
- Position (Left or Right child)
- Distance from parent (in KM)
- Shortest Route: Enter two airport codes to find the shortest path between them
- Longest Route: View the longest route in the entire network
- Path Length: Calculate the total distance between two airports
| Field | Type | Description |
|---|---|---|
airport_code |
CharField | Unique airport code (max 10 chars) |
parent |
ForeignKey | Self-referential parent node |
position |
CharField | ROOT, LEFT, or RIGHT |
distance_from_parent |
PositiveIntegerField | Distance in KM |
created_at |
DateTimeField | Auto-created timestamp |
MIT License