This project focuses on computing visibility graphs and the shortest path between two points while avoiding polygonal obstacles. It offers two primary functionalities:
- Dynamic GUI for visibility graph algorithm: Allows users to interactively define obstacles and compute paths in real time.
- World Map Visualization: Calculates the shortest path between points on a global map and visualizes the result in an HTML file.
- Kush Mahajan (2022CSB1089)
- Dhruv Gupta (2022CSB1079)
- Prakhar Maurya (2022CSB1102)
- Nishant Patil (2022CSB1097)
- Swapnil Pandey (2022CSB1133)
The primary objective of this project is to implement a computational geometry algorithm that:
- Constructs Visibility Graphs: Determines visibility relationships between points while avoiding obstacles.
- Calculates Shortest Paths: Computes paths efficiently using the constructed visibility graph.
- Visualizes Results: Offers outputs through an interactive GUI or a world map HTML file.
The project demonstrates how visibility graphs can be used in real-world applications like geographic navigation and obstacle avoidance.
main.py
: Entry point for the interactive GUI.graph.py
: Contains graph data structures and traversal methods.visible_vertices.py
: Calculates visible vertices for a given point.shortest_path.py
: Implements the shortest path algorithms.vis_graph.py
: Computes visibility graphs for polygonal obstacles.
1_build_graph_from_shapefiles.py
: Builds the visibility graph from shapefiles.2_compute_shortest_path.py
: Computes the shortest path using the visibility graph.3_visualize_on_map.py
: Visualizes the shortest path on a global map using the Folium library.
To construct the visibility graph:
python 1_build_graph_from_shapefiles.py
This script reads a shapefile (GSHHS_c_L1
), extracts shoreline data, and saves the visibility graph as GSHHS_c_L1.graph
.
To calculate the shortest path between two points on the globe:
python 2_compute_shortest_path.py
This script uses the visibility graph to compute the shortest path and outputs the total distance in kilometers.
To visualize the computed shortest path on a world map:
python 3_visualize_on_map.py
This script creates an HTML map with markers and a polyline representing the shortest path. The map is saved as example_shortest_path_plot.html
and can be opened in any web browser.
To run:
python main.py
- Right-Click: Add nodes to create a polygon.
- Left-Click: Complete the polygon.
- Reset Button: Clear all inputs to start over.
- Shortest Path: Compute and display the shortest path.
- Visibility Graph: Compute visbility graph.
-
Obstacle Visualization:
The GUI allows users to define polygonal obstacles interactively. -
Visibility Graph:
Displays the computed visibility graph connecting visible points while avoiding obstacles. -
Shortest Path:
Computes and visually highlights the shortest path between the start and end points on the GUI.Sample Screenshots:
-
Output Distance:
The calculated distance is displayed in the terminal, showing the shortest path distance between the selected points on the globe. -
World Map:
The shortest path is plotted on a world map and saved as an HTML file (example_shortest_path_plot.html
). This file can be opened in any browser to view the visualization.Sample Screenshot:
The project requires the following Python libraries:
matplotlib
: For GUI plotting and visualizations.numpy
: For numerical computations.shapely
: For geometric calculations and obstacle management.folium
: For creating interactive maps.haversine
: For calculating the great-circle distance.pyshp
: For handling shapefiles.
- Visibility Graph Construction: Handles obstacles and computes relationships between points.
- Shortest Path Calculation: Efficiently computes paths using the visibility graph.
- Dynamic GUI: Real-time obstacle navigation and shortest path visualization.
- World Map Integration: Displays results on a global scale.
Thank you for exploring the Visibility Graph Algorithm project!