Total Complexity | 4 |
Total Lines | 15 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | import unittest |
||
8 | class ConnectedComponentsUnitTest(unittest.TestCase): |
||
9 | def test_cc(self): |
||
10 | G = create_graph_4_connected_components() |
||
11 | |||
12 | cc = ConnectedComponents(G) |
||
13 | print('connected component count: ' + str(cc.count())) |
||
14 | |||
15 | self.assertEqual(3, cc.count()) |
||
16 | |||
17 | for v in range(G.vertex_count()): |
||
18 | print('id[' + str(v) + ']: ' + str(cc.id(v))) |
||
19 | for v in range(G.vertex_count()): |
||
20 | r = randint(0, G.vertex_count()-1) |
||
21 | if cc.connected(v, r): |
||
22 | print(str(v) + ' is connected to ' + str(r)) |
||
23 | |||
27 |