Exemple #1
0
 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])
Exemple #2
0
 def test_no_connections(self):
     graph = {1: {}, 2: {}, 3: {}}
     components = get_connected_components(graph)
     self.assertEqual(3, len(components))
Exemple #3
0
 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)
Exemple #4
0
 def test_no_nodes(self):
     self.assertEqual([], get_connected_components({}))
Exemple #5
0
 def test_no_nodes(self):
     assert get_connected_components({}) == []
Exemple #6
0
 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}
Exemple #7
0
 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}]
Exemple #8
0
 def test_no_connections(self):
     graph = {1: {}, 2: {}, 3: {}}
     components = get_connected_components(graph)
     assert len(components) == 3