Improve test coverage
This commit is contained in:
parent
6a75ffaf63
commit
50ef772271
|
@ -671,12 +671,11 @@ class _MatchingContext:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Update the priority of "y" in its UnionFindQueue.
|
# Update the priority of "y" in its UnionFindQueue.
|
||||||
prev_min = by.vertex_set.min_prio()
|
|
||||||
self.vertex_set_node[y].set_prio(prio)
|
self.vertex_set_node[y].set_prio(prio)
|
||||||
|
|
||||||
# If the blossom is unlabeled and the new edge becomes its least-slack
|
# 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.
|
# 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
|
prio += by.vertex_dual_offset
|
||||||
if by.delta2_node is None:
|
if by.delta2_node is None:
|
||||||
by.delta2_node = self.delta2_queue.insert(prio, by)
|
by.delta2_node = self.delta2_queue.insert(prio, by)
|
||||||
|
@ -1067,7 +1066,7 @@ class _MatchingContext:
|
||||||
|
|
||||||
if blossom.label == _LABEL_S:
|
if blossom.label == _LABEL_S:
|
||||||
self.remove_blossom_label_s(blossom)
|
self.remove_blossom_label_s(blossom)
|
||||||
elif blossom.label == _LABEL_T:
|
else:
|
||||||
self.remove_blossom_label_t(blossom)
|
self.remove_blossom_label_t(blossom)
|
||||||
|
|
||||||
def _check_alternating_tree_consistency(self) -> None:
|
def _check_alternating_tree_consistency(self) -> None:
|
||||||
|
|
|
@ -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)]),
|
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)])
|
[(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):
|
def test61_triangles_n9(self):
|
||||||
"""t.f 9 nodes"""
|
"""t.f 9 nodes"""
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue