def test_multiple_components(self): graph = {1: {2}, 2: {3}, 3: {4}, 6: {7, 8}} components = get_connected_components(graph) self.assertEqual(2, len(components)) self.assertEqual({1, 2, 3, 4}, components[0]) self.assertEqual({6, 7, 8}, components[1])
def test_no_connections(self): graph = {1: {}, 2: {}, 3: {}} components = get_connected_components(graph) self.assertEqual(3, len(components))
def test_fully_connected(self): graph = {1: {2, 3, 1}, 2: {1, 2, 2}, 3: {3, 2}} components = get_connected_components(graph) self.assertEqual(1, len(components)) self.assertEqual([{1, 2, 3}], components)
def test_no_nodes(self): self.assertEqual([], get_connected_components({}))
def test_no_nodes(self): assert get_connected_components({}) == []
def test_multiple_components(self): graph = {1: {2}, 2: {3}, 3: {4}, 6: {7, 8}} components = get_connected_components(graph) assert len(components) == 2 assert components[0] == {1, 2, 3, 4} assert components[1] == {6, 7, 8}
def test_fully_connected(self): graph = {1: {2, 3, 1}, 2: {1, 2, 2}, 3: {3, 2}} components = get_connected_components(graph) assert len(components) == 1 assert components == [{1, 2, 3}]
def test_no_connections(self): graph = {1: {}, 2: {}, 3: {}} components = get_connected_components(graph) assert len(components) == 3