| Total Complexity | 4 |
| Total Lines | 15 |
| 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 |
||
| 9 | View Code Duplication | class ConnectedComponentsUnitTest(unittest.TestCase): |
|
|
|
|||
| 10 | def test_cc(self): |
||
| 11 | G = create_graph_4_connected_components() |
||
| 12 | |||
| 13 | cc = ConnectedComponents(G) |
||
| 14 | print('connected component count: ' + str(cc.count())) |
||
| 15 | |||
| 16 | self.assertEqual(3, cc.count()) |
||
| 17 | |||
| 18 | for v in range(G.vertex_count()): |
||
| 19 | print('id[' + str(v) + ']: ' + str(cc.id(v))) |
||
| 20 | for v in range(G.vertex_count()): |
||
| 21 | r = randint(0, G.vertex_count() - 1) |
||
| 22 | if cc.connected(v, r): |
||
| 23 | print(str(v) + ' is connected to ' + str(r)) |
||
| 24 | |||
| 45 |