https://github.com/healeycodes/country-borders
🗺️ Calculating the path between two countries with the least border crossings.
https://github.com/healeycodes/country-borders
breadth-first-search country-borders matplotlib networkx
Last synced: about 1 year ago
JSON representation
🗺️ Calculating the path between two countries with the least border crossings.
- Host: GitHub
- URL: https://github.com/healeycodes/country-borders
- Owner: healeycodes
- License: mit
- Created: 2020-07-04T10:34:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-05T15:44:42.000Z (almost 6 years ago)
- Last Synced: 2024-10-05T17:42:23.302Z (over 1 year ago)
- Topics: breadth-first-search, country-borders, matplotlib, networkx
- Language: Python
- Homepage:
- Size: 243 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# country-borders
> My blog post: https://healeycodes.com/practical-intro-to-graphs/
Calculating the path between two countries with the least border crossings.
This repository shows some examples of:
- Consuming CSV data and building multiple graphs
- Displaying graphs with `networkx`/`matplotlib.pyplot`
- Finding the shortest path (Breadth-First Search) between vertices (e.g. France to China)
- Building a graph of all the non-islands of the world
### The shortest path between France and China
`fr-to-cn.py` builds multiple graphs and dynamically outputs:
```
France is connected to 8 countries.
They are Andorra, Belgium, Germany, Italy, Luxembourg, Monaco, Spain, Switzerland.
The shortest path from France to China is: France -> Germany -> Poland -> Russian Federation -> China.
```
and displays:

### The non-islands of the world
`non-islands.py` builds the same graphs, culls the islands, and displays:

### License
MIT.
_This site or product includes Country Borders data available from https://www.geodatasource.com_