This project is a simple example of building Dijkstra's shortest path algorithm using Open Street Map data, using only the standard Python library. The class Graph
builds the directed graph by adding nodes and edges for each weighted edge between two nodes. The get_shortest_path
method implements Dikstra's algorithm to find the distance of the shortest path.
-
Install Python 3.6 on your Operating System as per the Python Docs. Continuum's Anaconda distribution is recommended.
-
Checkout the repo:
git clone https://github.com/jhole89/osm-router
-
Setup the project dependencies:
$ cd osm-router
$ export PYTHONPATH=$PYTHONPATH:$(pwd)
$ pip install -r requirements.txt
$ chmod +x run.sh
A simple shell script run.sh
has been provided to execute the program. This passes 3 arguements to the Python application
./run.sh <path to graph> <from-osm-id> <to-osm-id>
.
./run.sh citymapper-coding-test-graph.dat 316319897 316319936
121
This project uses Travis-CI for our CI/CD to run style checks (pycodestyle) against every new commit and against the nightly CPython build to ensure we are always aligned with the latest CPython dev builds. Build status is shown at the top of this README.
- Test coverage - currently no unit or integration tests have been implemented, this should be rectified with a couple of simple tests using
pytest