This Python program helps Hogwarts alumni find optimal paths to reunite in Ottawa, Canada. It calculates routes based on:
- Shortest hop path
- Shortest distance path
- Shortest time path
- Fewest Dementors path
- Combined optimal path (extra credit)
- Graph representation of provinces and magical paths
- Pathfinding algorithms (BFS, Dijkstra)
- Visualization of the magical network
- Output for all 4 criteria + combined path (extra credit)
- Ensure Python 3.x is installed.
- Install required libraries:
pip install networkx matplotlib
- Save the code as
Assignment4.py
. - Run the script:
python Assignment4.py
- Output:
- Optimal paths printed in the terminal
- Graph visualization saved as
magical_network.png
=== Harry Potter (British Columbia) ===
SHP: British Columbia -> Quebec -> Ottawa (Hops: 2)
SDP: British Columbia -> Saskatchewan -> Ottawa (Distance: 1400 km)
STP: British Columbia -> Alberta -> Ottawa (Time: 42 hrs)
FDP: British Columbia -> Quebec -> Ottawa (Dementors: 9)
== Extra Credit: Combined Optimal Path (All Criteria Minimized) ==
Path: British Columbia -> Saskatchewan -> Quebec -> Ottawa
Hops: 3, Distance: 1400 km, Time: 24 hrs, Dementors: 9
Combined Score: 0.4321
- User Joins: 🐼 Sarah joined the grove!
- ASCII Art Broadcast: "Test it your self 😜"
- Invalid Command (Private Error): 🐼 No ASCII found for this mood! Try: hey, shy, sleeping, dab, shocked, swag, thanks,
- Python
socket
module: Official Documentation - ASCII Art Inspiration/Used from: ASCII Archive and Emoji Combos