예제 #1
0
 def initialize(self):
     graph = Graph()
     graph.parseFile(FILE)
예제 #2
0
파일: Stats.py 프로젝트: mukichou/cs242-1
 def initialize(self):
     graph = Graph()
     graph.parseFile(FILE);
예제 #3
0
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)
예제 #4
0
 def testGraphRelations(self):
     graph = Graph()
     graph.parseFile(TESTFILE)
     self.assertEqual(graph.nodes['LIM']['rels'].keys(),[u'SCL',u'MEX',u'BOG'])
예제 #5
0
 def testGraphDistances(self):
     graph = Graph()
     graph.parseFile(TESTFILE)
     self.assertEqual(graph.nodes['LIM']['rels']['SCL'],2453)
예제 #6
0
 def testGraphNode(self):
     graph = Graph()
     graph.parseFile(TESTFILE)
     self.assertEqual(graph.nodes['SCL']['code'],'SCL')
     self.assertEqual(graph.nodes['SCL']['continent'],'South America')
예제 #7
0
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)
    
예제 #8
0
 def testGraphDistances(self):
     graph = Graph()
     graph.parseFile(TESTFILE)
     self.assertEqual(graph.nodes['LIM']['rels']['SCL'], 2453)
예제 #9
0
 def testGraphRelations(self):
     graph = Graph()
     graph.parseFile(TESTFILE)
     self.assertEqual(graph.nodes['LIM']['rels'].keys(),
                      [u'SCL', u'MEX', u'BOG'])
예제 #10
0
 def testGraphNode(self):
     graph = Graph()
     graph.parseFile(TESTFILE)
     self.assertEqual(graph.nodes['SCL']['code'], 'SCL')
     self.assertEqual(graph.nodes['SCL']['continent'], 'South America')