def load_map(mapFilename): """ _parses the map file and constructs a directed graph _parameters: mapFilename : name of the map file Assumes: Each entry in the map file consists of the following four positive integers, separated by a blank space: From To TotalDistance DistanceOutdoors e.g. 32 76 54 23 This entry would become an edge from 32 to 76. Returns: a directed graph representing the map """ # TODO print "Loading map from file..." campus = WeightedDigraph() with open(mapFilename) as infile: for line in infile: data = line.split() for d in data[:2]: try: campus.addNode(d) except ValueError: pass campus.addEdge(Edge(data[0], data[1])) campus.addWeights(data[0], data[1], map(int, data[2:])) return campus