Exemple #1
0
 def setUp(self):
     f = open('assets/data/map_data.json', 'r')
     decoded = json.loads(f.read())
     self.g = Graph()
     self.g.build_nodes(decoded['metros'])
     self.g.build_edges(decoded['routes'])
     self.utils = GraphUtils()
 def testSave(self):
     self.utils.save_to_disk(self.g)
     f2 = open('assets/data/map_data_written.json', 'r')
     decoded = json.loads(f2.read())
     self.g2 = graph.Graph()
     self.g2.build_nodes(decoded['metros'])
     self.g2.build_edges(decoded['routes'])
     self.utils = GraphUtils()
     assert (self.utils.longest_flight(self.g2) == ('SYD', 'LAX', 12051))
     assert (self.utils.shortest_flight(self.g2) == ('NYC', 'WAS', 334))
     assert (self.utils.average_distance(self.g2) == 2300)
     assert self.utils.biggest_city(self.g2) == ('TYO', 34000000)
     assert self.utils.smallest_city(self.g2) == ('ESS', 589900)
Exemple #3
0
 def setUp(self):
   controller = Controller()
   files = ['assets/data/map_data.json', 'assets/data/cmi_hub.json']
   self.g = Graph()
   controller.build_graph_from_files(self.g, files)
   self.utils = GraphUtils()