Routing Algorithm Shortest Path Algorithm Python