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"
Example #2
0
'''
Created on Feb 27, 2013

@author: shengchao
'''
from DataParse import Parser
from DataParse import QueryingData
from DataParse import UserQueryingExpand
from DataParse import UserQuerying
from DataParse import DijkstraAlgorithm

Parser.Parser()

graph = {}
for city in QueryingData.cityDicationary:
    
    graph[city] = UserQuerying.getFlyToCity(city)
    
print DijkstraAlgorithm.shortestPath(graph, "Los Angeles", "London")