Implement scan queue as a list instead of deque
This commit is contained in:
parent
04b6908449
commit
73479532ac
|
@ -6,7 +6,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
import collections
|
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import NamedTuple, Optional
|
from typing import NamedTuple, Optional
|
||||||
|
|
||||||
|
@ -600,7 +599,7 @@ class _MatchingContext:
|
||||||
self.vertex_best_edge: list[int] = num_vertex * [-1]
|
self.vertex_best_edge: list[int] = num_vertex * [-1]
|
||||||
|
|
||||||
# Queue of S-vertices to be scanned.
|
# Queue of S-vertices to be scanned.
|
||||||
self.scan_queue: collections.deque[int] = collections.deque()
|
self.scan_queue: list[int] = []
|
||||||
|
|
||||||
def __del__(self) -> None:
|
def __del__(self) -> None:
|
||||||
"""Delete reference cycles during cleanup of the matching context."""
|
"""Delete reference cycles during cleanup of the matching context."""
|
||||||
|
@ -1412,10 +1411,7 @@ class _MatchingContext:
|
||||||
|
|
||||||
# Process S-vertices waiting to be scanned.
|
# Process S-vertices waiting to be scanned.
|
||||||
# This loop runs through O(n) iterations per stage.
|
# This loop runs through O(n) iterations per stage.
|
||||||
while self.scan_queue:
|
for x in self.scan_queue:
|
||||||
|
|
||||||
# Take a vertex from the queue.
|
|
||||||
x = self.scan_queue.popleft()
|
|
||||||
|
|
||||||
# Double-check that "x" is an S-vertex.
|
# Double-check that "x" is an S-vertex.
|
||||||
bx = self.vertex_set_node[x].find()
|
bx = self.vertex_set_node[x].find()
|
||||||
|
@ -1464,6 +1460,8 @@ class _MatchingContext:
|
||||||
# tracked.
|
# tracked.
|
||||||
self.lset_add_vertex_edge(y, by, e)
|
self.lset_add_vertex_edge(y, by, e)
|
||||||
|
|
||||||
|
self.scan_queue.clear()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Delta steps:
|
# Delta steps:
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue