From 73479532ac1ab818ae296a372b0173fc9871d6c3 Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Sun, 9 Jun 2024 18:01:06 +0200 Subject: [PATCH] Implement scan queue as a list instead of deque --- python/mwmatching.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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: #