def initialize(self): graph = Graph() graph.parseFile(FILE)
def initialize(self): graph = Graph() graph.parseFile(FILE);
FILE = Graph.FILE class CircleMap(): # A function to create a URL leading to # the Great Circle Mapper website which # will display the image for us. # # E.g. "http://www.gcmap.com/mapui?P=LIM-MEX,+LIM-BOG,+MEX-LAX" # # @input graph the given graph representation # for our input def createURL(self, graph): url = "http://www.gcmap.com/mapui?P=" routes = "" for start in graph.nodes: for end in graph.nodes[start]['rels'].keys(): routes += start + "-" + end + ",+" url += routes[:-2] return url if __name__ == '__main__': map = CircleMap() graph = Graph() graph.parseFile(FILE) url = map.createURL(graph) webbrowser.open(url, new=2)
def testGraphRelations(self): graph = Graph() graph.parseFile(TESTFILE) self.assertEqual(graph.nodes['LIM']['rels'].keys(),[u'SCL',u'MEX',u'BOG'])
def testGraphDistances(self): graph = Graph() graph.parseFile(TESTFILE) self.assertEqual(graph.nodes['LIM']['rels']['SCL'],2453)
def testGraphNode(self): graph = Graph() graph.parseFile(TESTFILE) self.assertEqual(graph.nodes['SCL']['code'],'SCL') self.assertEqual(graph.nodes['SCL']['continent'],'South America')
FILE = Graph.FILE class CircleMap(): # A function to create a URL leading to # the Great Circle Mapper website which # will display the image for us. # # E.g. "http://www.gcmap.com/mapui?P=LIM-MEX,+LIM-BOG,+MEX-LAX" # # @input graph the given graph representation # for our input def createURL(self,graph): url = "http://www.gcmap.com/mapui?P=" routes = "" for start in graph.nodes: for end in graph.nodes[start]['rels'].keys(): routes += start + "-" + end + ",+" url += routes[:-2] return url if __name__ == '__main__': map = CircleMap() graph = Graph() graph.parseFile(FILE) url = map.createURL(graph) webbrowser.open(url,new=2)
def testGraphDistances(self): graph = Graph() graph.parseFile(TESTFILE) self.assertEqual(graph.nodes['LIM']['rels']['SCL'], 2453)
def testGraphRelations(self): graph = Graph() graph.parseFile(TESTFILE) self.assertEqual(graph.nodes['LIM']['rels'].keys(), [u'SCL', u'MEX', u'BOG'])
def testGraphNode(self): graph = Graph() graph.parseFile(TESTFILE) self.assertEqual(graph.nodes['SCL']['code'], 'SCL') self.assertEqual(graph.nodes['SCL']['continent'], 'South America')