From fa524ce754d25a3894e08b242b289306514635ba Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Sun, 12 Feb 2023 15:04:27 +0100 Subject: [PATCH] Simplify deletion of expanded blossoms --- python/max_weight_matching.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/python/max_weight_matching.py b/python/max_weight_matching.py index cbac8b6..2660901 100644 --- a/python/max_weight_matching.py +++ b/python/max_weight_matching.py @@ -1137,16 +1137,9 @@ class _MatchingContext: # Delete the expanded blossoms. # We do this in one pass over the array to ensure O(n) time. - p = 0 - for (i, blossom) in enumerate(self.nontrivial_blossom): - if not blossom.marker: - # Keep this blossom. - if i > p: - self.nontrivial_blossom[p] = blossom - p += 1 - - # Trim the array. - del self.nontrivial_blossom[p:] + self.nontrivial_blossom = [blossom + for blossom in self.nontrivial_blossom + if not blossom.marker] # # Augmenting: