Skip to content

Commit a547676

Browse files
Merge remote-tracking branch 'origin/master'
# Conflicts: # graphs/edmonds_blossom_algorithm.py
2 parents 11a3c24 + d286529 commit a547676

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

graphs/tests/test_edmonds_blossom_algorithm.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55

66
class EdmondsBlossomAlgorithmTest(unittest.TestCase):
7-
87
def convert_matching_to_array(self, matching):
9-
""" Helper method to convert a
8+
"""Helper method to convert a
109
list of matching pairs into a sorted 2D array.
1110
"""
1211
# Convert the list of pairs into a list of lists
@@ -21,39 +20,39 @@ def convert_matching_to_array(self, matching):
2120
return result
2221

2322
def test_case_1(self):
24-
""" Test Case 1: A triangle graph where vertices 0, 1, and 2 form a cycle. """
23+
"""Test Case 1: A triangle graph where vertices 0, 1, and 2 form a cycle."""
2524
edges = [[0, 1], [1, 2], [2, 0]]
2625
matching = EdmondsBlossomAlgorithm.maximum_matching(edges, 3)
2726

2827
expected = [[0, 1]]
2928
assert expected == self.convert_matching_to_array(matching)
3029

3130
def test_case_2(self):
32-
""" Test Case 2: A disconnected graph with two components. """
31+
"""Test Case 2: A disconnected graph with two components."""
3332
edges = [[0, 1], [1, 2], [3, 4]]
3433
matching = EdmondsBlossomAlgorithm.maximum_matching(edges, 5)
3534

3635
expected = [[0, 1], [3, 4]]
3736
assert expected == self.convert_matching_to_array(matching)
3837

3938
def test_case_3(self):
40-
""" Test Case 3: A cycle graph with an additional edge outside the cycle. """
39+
"""Test Case 3: A cycle graph with an additional edge outside the cycle."""
4140
edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5]]
4241
matching = EdmondsBlossomAlgorithm.maximum_matching(edges, 6)
4342

4443
expected = [[0, 1], [2, 3], [4, 5]]
4544
assert expected == self.convert_matching_to_array(matching)
4645

4746
def test_case_no_matching(self):
48-
""" Test Case 4: A graph with no edges. """
47+
"""Test Case 4: A graph with no edges."""
4948
edges = [] # No edges
5049
matching = EdmondsBlossomAlgorithm.maximum_matching(edges, 3)
5150

5251
expected = []
5352
assert expected == self.convert_matching_to_array(matching)
5453

5554
def test_case_large_graph(self):
56-
""" Test Case 5: A complex graph with multiple cycles and extra edges. """
55+
"""Test Case 5: A complex graph with multiple cycles and extra edges."""
5756
edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [1, 4], [2, 5]]
5857
matching = EdmondsBlossomAlgorithm.maximum_matching(edges, 6)
5958

@@ -69,5 +68,5 @@ def test_case_large_graph(self):
6968
assert result in (possible_matching_1, possible_matching_2)
7069

7170

72-
if __name__ == '__main__':
71+
if __name__ == "__main__":
7372
unittest.main()

0 commit comments

Comments
 (0)