diff --git a/python/datastruct.py b/python/datastruct.py index 0b970a0..22e0647 100644 --- a/python/datastruct.py +++ b/python/datastruct.py @@ -1,8 +1,4 @@ -""" -Data structures for matching. - -Experimental. -""" +"""Data structures for matching.""" from typing import Generic, Optional, TypeVar diff --git a/python/mwmatching.py b/python/mwmatching.py index b019301..83ca277 100644 --- a/python/mwmatching.py +++ b/python/mwmatching.py @@ -341,13 +341,13 @@ class _Blossom: An alternating cycle is an alternating path that starts and ends in the same sub-blossom. + Blossoms are recursive structures: A non-trivial blossoms contains + sub-blossoms, which may themselves contain sub-blossoms etc. + A single vertex by itself is also a blossom: a "trivial blossom". An instance of this class represents either a trivial blossom, - or a non-trivial blossom which consists of multiple sub-blossoms. - - Blossoms are recursive structures: A non-trivial blossoms contains - sub-blossoms, which may themselves contain sub-blossoms etc. + or a non-trivial blossom. Each blossom contains exactly one vertex that is not matched to another vertex in the same blossom. This is the "base vertex" of the blossom. @@ -620,7 +620,6 @@ class _MatchingContext: def __del__(self) -> None: """Delete reference cycles during cleanup of the matching context.""" - for blossom in itertools.chain(self.trivial_blossom, self.nontrivial_blossom): blossom.parent = None @@ -1085,10 +1084,7 @@ class _MatchingContext: assert blossom.tree_edge is None assert blossom.tree_blossoms is None - def remove_alternating_tree( - self, - tree_blossoms: set[_Blossom] - ) -> None: + def remove_alternating_tree(self, tree_blossoms: set[_Blossom]) -> None: """Reset the alternating tree consisting of the specified blossoms. Marks the blossoms as unlabeled. @@ -1196,6 +1192,9 @@ class _MatchingContext: Assign label S to the new blossom. Relabel all T-sub-blossoms as S and add their vertices to the queue. + A blossom will not be expanded during the same stage in which + it was created. + This function takes total time O((n + m) * log(n)) per stage. """