From 50ef7722714ec611872104db9c7993ad74b398a4 Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Sat, 6 Jul 2024 20:21:33 +0200 Subject: [PATCH] Improve test coverage --- python/mwmatching.py | 5 ++--- python/test_mwmatching.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/python/mwmatching.py b/python/mwmatching.py index 9c58709..b019301 100644 --- a/python/mwmatching.py +++ b/python/mwmatching.py @@ -671,12 +671,11 @@ class _MatchingContext: return # Update the priority of "y" in its UnionFindQueue. - prev_min = by.vertex_set.min_prio() self.vertex_set_node[y].set_prio(prio) # If the blossom is unlabeled and the new edge becomes its least-slack # S-edge, insert or update the blossom in the global delta2 queue. - if (by.label == _LABEL_NONE) and (prio < prev_min): + if by.label == _LABEL_NONE: prio += by.vertex_dual_offset if by.delta2_node is None: by.delta2_node = self.delta2_queue.insert(prio, by) @@ -1067,7 +1066,7 @@ class _MatchingContext: if blossom.label == _LABEL_S: self.remove_blossom_label_s(blossom) - elif blossom.label == _LABEL_T: + else: self.remove_blossom_label_t(blossom) def _check_alternating_tree_consistency(self) -> None: diff --git a/python/test_mwmatching.py b/python/test_mwmatching.py index 05a3a68..e36efc1 100644 --- a/python/test_mwmatching.py +++ b/python/test_mwmatching.py @@ -243,6 +243,23 @@ class TestMaximumWeightMatching(unittest.TestCase): mwm([(1,2,19), (1,4,17), (1,5,19), (2,3,15), (2,5,21), (4,6,18), (4,7,11), (5,6,19)]), [(1,5), (2,3), (4,6)]) + def test52_augment_blossom_nested2(self): + """augment nested blossoms""" + # + # [4]--15 19--[2] + # | \ / | + # 16 [1] 21 + # | / \ | + # [5]--17 19--[3] + # | + # 10 + # | + # [6] + # + self.assertEqual( + mwm([(1,2,19), (1,3,19), (1,4,15), (1,5,17), (2,3,21), (4,5,16), (5,6,10)]), + [(1,4), (2,3), (5,6)]) + def test61_triangles_n9(self): """t.f 9 nodes""" #