Python Find Shortest Path Railway