Code Duplication    Length = 10-11 lines in 3 locations

tests/algorithms/graphs/shortest_path_unit_test.py 3 locations

@@ 21-31 (lines=11) @@
18
                print('path length is ' + str(dijkstra.path_length_to(v)))
19
20
21
class TopologicalSortShortestPathUnitTest(unittest.TestCase):
22
    def test_shortest_path(self):
23
        g = create_edge_weighted_digraph()
24
        assert not DirectedCycle(g).hasCycle()
25
        s = 0
26
        dijkstra = TopologicalSortShortestPath(g, s)
27
        for v in range(1, g.vertex_count()):
28
            if dijkstra.hasPathTo(v):
29
                print(str(s) + ' is connected to ' + str(v))
30
                print('shortest path is ' + ' .. '.join([str(i) for i in dijkstra.shortestPathTo(v)]))
31
                print('path length is ' + str(dijkstra.path_length_to(v)))
32
33
34
class BellmanFordShortestPathUnitTest(unittest.TestCase):
@@ 34-43 (lines=10) @@
31
                print('path length is ' + str(dijkstra.path_length_to(v)))
32
33
34
class BellmanFordShortestPathUnitTest(unittest.TestCase):
35
    def test_shortest_path(self):
36
        g = create_edge_weighted_digraph()
37
        s = 0
38
        dijkstra = BellmanFordShortestPath(g, s)
39
        for v in range(1, g.vertex_count()):
40
            if dijkstra.hasPathTo(v):
41
                print(str(s) + ' is connected to ' + str(v))
42
                print('shortest path is ' + ' .. '.join([str(i) for i in dijkstra.shortestPathTo(v)]))
43
                print('path length is ' + str(dijkstra.path_length_to(v)))
44
45
46
if __name__ == '__main__':
@@ 9-18 (lines=10) @@
6
from tests.algorithms.graphs.util import create_edge_weighted_digraph
7
8
9
class DijkstraShortestPathUnitTest(unittest.TestCase):
10
    def test_shortest_path(self):
11
        g = create_edge_weighted_digraph()
12
        s = 0
13
        dijkstra = DijkstraShortestPath(g, s)
14
        for v in range(1, g.vertex_count()):
15
            if dijkstra.hasPathTo(v):
16
                print(str(s) + ' is connected to ' + str(v))
17
                print('shortest path is ' + ' .. '.join([str(i) for i in dijkstra.shortestPathTo(v)]))
18
                print('path length is ' + str(dijkstra.path_length_to(v)))
19
20
21
class TopologicalSortShortestPathUnitTest(unittest.TestCase):