Find shortest map with 3 algorithms: Dijistra, Bellman-Ford, Floyd warshall
- Khởi tạo dữ liệu ma trận từ bản đồ Google Maps, bao gồm một vùng diện tích ở khu vực Thành phố Hồ Chí Minh có ít nhất 100 đỉnh và 100 cạnh. (2 điểm)
- Cài đặt ba thuật toán Dijkstra, Bellman-Ford, và Floyd-Warshall trên dữ liệu đã khởi tạo và đưa ra đánh giá về hiệu suất khi chọn ngẫu nhiên các cặp đỉnh. (3 điểm)
- Tạo chức năng nhập điểm đầu và điểm cuối trên bản đồ và xuất ra ba đường đi ngắn nhất. Minh họa ba đường đi này trên bản đồ Google Maps. (4 điểm)
- So sánh kết quả của các thuật toán với dữ liệu thực tế từ Google. (1 điểm)
Reference code:
https://stackoverflow.com/questions/76483447/adding-custom-nodes-in-osmnx-map
https://github.com/TrafficGCN/optimal_path_dijkstra_for_data_science/blob/main/dijkstra_map.py
https://github.com/gboeing/osmnx-examples/tree/main/notebooks
Python: 3.10.12 OS: wsl2 (window) Library:
- streamlit==1.33.0
- streamlit_folium
- leafmap==0.31.9
- osmnx==1.9.2
- networkx==3.1
- geopy==2.4.1
- folium==0.16.0
To setup lib, run command
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
First we need to create a map with osm.
- Open the link https://www.openstreetmap.org/export#map=17/18.68012/105.66745
- Choose "Manually select a different area"
- Click Export
- Save file
.osm
and save in data folder
Here I have data with 380 nodes and 810 edges in Ho Chi Minh city.
Move to the folder having the project and run command
streamlit run app.py
It will open the streamlit web app
Figure. Result
To change basemap click choose basemap. Options inculde:
- Satellite
- Roadmap
- Terrain
- Hybrid
- OpenStreetMap
To change travel mode, click choose transport. Options include:
- Drive
- Walk
- Bike
Click choose algorithm to change algorithms. Options include
- Dijkstra
- Bellman-Ford
- Floyd Warshall
Then we click on the map, it will appear the lat, lon of the position, copy and paste them to Go from and Go to section
Figure. Click for lat long