def test_dijkstra_simple(self):
     graph = Graph('test/netfiles/test1.net.xml', False)
     costs = {}
     for edge in graph.edges:
         costs[edge] = 1
     graph.set_destination_and_costs(graph.edges[-1], costs)
     self.assertEqual(graph.dijkstra(graph.edges[1], costs), ['-25','5'])
 def test_dijkstra_complex(self):
     graph = Graph('test/netfiles/test4.net.xml', False)
     costs = {}
     for edge in graph.edges:
         costs[edge] = 1
     graph.set_destination_and_costs('30668', costs)
     self.assertEqual(graph.dijkstra('-31439', costs), ['-31439','-30057','-28887','28866','-23377','-22520','-21950','-17064','-16421','-15637','-3694','-3348','-158','144','-212','213','-370','420','-809','1807','-2481','2488','2556','-3837','3836','4158','4982','12338','-20947','-20171','20161','20824','-22781','-22135','22133','22780','27742','29467','30668'])
 def test_is_optimalization_needed(self):
     graph = Graph('test/netfiles/test1.net.xml', False)
     graph.edges = ['1', '2', '3', '4', '5']
     graph.set_destination_and_costs('5', {'1':10, '2':10, '3':10, '4':10, '5':10})
     self.assertTrue(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':10, '3':12, '4':10, '5':10}, 0.1))
     self.assertTrue(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':8, '3':10, '4':10, '5':10}, 0.1))
     self.assertFalse(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':10, '3':8, '4':10, '5':10}, 0.1))
     self.assertFalse(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':12, '3':10, '4':10, '5':10}, 0.1))