| Total Complexity | 4 |
| Total Lines | 15 |
| Duplicated Lines | 100 % |
| Changes | 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 |
||
| 26 | View Code Duplication | class StronglyConnectedComponentsUnitTest(unittest.TestCase): |
|
| 27 | def test_cc(self): |
||
| 28 | G = create_digraph_4_strongly_connected_components() |
||
| 29 | |||
| 30 | cc = StronglyConnectedComponents(G) |
||
| 31 | print('strongly connected component count: ' + str(cc.count())) |
||
| 32 | |||
| 33 | self.assertEqual(5, cc.count()) |
||
| 34 | |||
| 35 | for v in range(G.vertex_count()): |
||
| 36 | print('id[' + str(v) + ']: ' + str(cc.id(v))) |
||
| 37 | for v in range(G.vertex_count()): |
||
| 38 | r = randint(0, G.vertex_count() - 1) |
||
| 39 | if cc.connected(v, r): |
||
| 40 | print(str(v) + ' is connected to ' + str(r)) |
||
| 41 | |||
| 45 |