Shortest Path Routing Algorithm In Python