diff --git a/python/mwmatching.py b/python/mwmatching.py index 8f2d62d..787df39 100644 --- a/python/mwmatching.py +++ b/python/mwmatching.py @@ -6,7 +6,6 @@ from __future__ import annotations import sys import math -import collections from collections.abc import Sequence from typing import NamedTuple, Optional @@ -600,7 +599,7 @@ class _MatchingContext: self.vertex_best_edge: list[int] = num_vertex * [-1] # Queue of S-vertices to be scanned. - self.scan_queue: collections.deque[int] = collections.deque() + self.scan_queue: list[int] = [] def __del__(self) -> None: """Delete reference cycles during cleanup of the matching context.""" @@ -1412,10 +1411,7 @@ class _MatchingContext: # Process S-vertices waiting to be scanned. # This loop runs through O(n) iterations per stage. - while self.scan_queue: - - # Take a vertex from the queue. - x = self.scan_queue.popleft() + for x in self.scan_queue: # Double-check that "x" is an S-vertex. bx = self.vertex_set_node[x].find() @@ -1464,6 +1460,8 @@ class _MatchingContext: # tracked. self.lset_add_vertex_edge(y, by, e) + self.scan_queue.clear() + # # Delta steps: #