def getRouteInfo(): ''' This function will call relative functions to calculate distance, cost and consuming time about a particular route ''' cities = raw_input("Please enter cities in route: \n") # city1, city2, city3 ... toGoCityList = re.split(', |,| ,', cities) print toGoCityList distance = CostHelper.calculateDistance(toGoCityList) cost = CostHelper.calculateCost(toGoCityList) time = CostHelper.calculateTime(toGoCityList) print "Total distance is: " + str(distance) + " kilometers" print "Total cost is: $" + str(cost) print "Total consuming time is: " + str(time) + " hours" return cost
def getShortestPath(): ''' This function will find the shortest path between two cities And calculate the distance, cost and consuming time about the Shortest path ''' graph = {} pathList = None source = raw_input("Please enter the source city: \n") destionation = raw_input("Please enter the destination city: \n") for city in QueryingData.cityDicationary: graph[city] = UserQuerying.getFlyToCity(city) pathList = DijkstraAlgorithm.shortestPath(graph, source, destionation) print "Ths shortest path: " for city in pathList: print '>' + city print "" distance = CostHelper.calculateDistance(pathList) cost = CostHelper.calculateCost(pathList) time = CostHelper.calculateTime(pathList) print "Total distance is: " + str(distance) + " kilometers" print "Total cost is: $" + str(cost) print "Total consuming time is: " + str(time) + " hours"