def test_of_three_components(self): """ 1-2 3 4 """ nodes = self.nodes nodes[0].neighbors.append(nodes[1]) nodes[1].neighbors.append(nodes[0]) self.assertEqual(cc.connected_components(nodes), [[1, 2], [3], [4]])
def test_of_four_components(self): """ 1 2 3 4 """ nodes = self.nodes self.assertEqual( cc.connected_components(nodes), [[1], [2], [3], [4]])