예제 #1
0
 def test_directed_example(self):
     file_name = '../data/medium.txt'
     expected = {
         1: {
             2: 2,
             4: 1
         },
         2: {
             4: 3,
             5: 10
         },
         3: {
             1: 4,
             6: 5
         },
         4: {
             3: 2,
             5: 2,
             6: 8,
             7: 4
         },
         5: {
             7: 6
         },
         7: {
             6: 1
         }
     }
     result = file_to_graph(file_name)
     self.assertDictEqual(expected, result)
예제 #2
0
 def test_large_example(self):
     file_name = '../data/large.txt'
     start, finish = 13,5
     expected = 26
     G = file_to_graph(file_name)
     final_dist = dijkstra(G,start)
     result = final_dist[finish]
     self.assertEqual(expected, result)
예제 #3
0
 def test_medium_example(self):
     file_name = '../data/medium.txt'
     start, finish = 1,7
     expected = 5
     G = file_to_graph(file_name)
     final_dist = dijkstra(G,start)
     result = final_dist[finish]
     self.assertEqual(expected, result)
예제 #4
0
 def test_small_example(self):
     file_name = '../data/small.txt'
     start, finish = 1, 4
     expected = 2
     G = file_to_graph(file_name)
     final_dist = dijkstra(G,start)
     result = final_dist[finish]
     self.assertEqual(expected, result)
예제 #5
0
 def test_small_example(self):
     file_name = '../data/small.txt'
     expected = {
         1: {
             2: 5,
             3: 1
         },
         2: {
             1: 5,
             4: 10
         },
         3: {
             1: 1,
             4: 1
         },
         4: {
             2: 10,
             3: 1
         }
     }
     result = file_to_graph(file_name)
     self.assertDictEqual(expected, result)