Total Complexity | 5 |
Total Lines | 11 |
Duplicated Lines | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | import unittest |
||
20 | View Code Duplication | class TopologicalSortShortestPathUnitTest(unittest.TestCase): |
|
21 | def test_shortest_path(self): |
||
22 | g = create_edge_weighted_digraph() |
||
23 | assert not DirectedCycle(g).hasCycle() |
||
24 | s = 0 |
||
25 | dijkstra = TopologicalSortShortestPath(g, s) |
||
26 | for v in range(1, g.vertex_count()): |
||
27 | if dijkstra.hasPathTo(v): |
||
28 | print(str(s) + ' is connected to ' + str(v)) |
||
29 | print('shortest path is ' + ' .. '.join([str(i) for i in dijkstra.shortestPathTo(v)])) |
||
30 | print('path length is ' + str(dijkstra.path_length_to(v))) |
||
31 | |||
34 | unittest.main() |