Avoid leaking reference cycles
This commit is contained in:
parent
4c6115fb2f
commit
6a75ffaf63
|
@ -115,6 +115,7 @@ class UnionFindQueue(Generic[_NameT, _ElemT]):
|
||||||
if node is not None:
|
if node is not None:
|
||||||
node.owner = None
|
node.owner = None
|
||||||
while node is not None:
|
while node is not None:
|
||||||
|
node.min_node = None # type: ignore
|
||||||
prev_node = node
|
prev_node = node
|
||||||
if node.left is not None:
|
if node.left is not None:
|
||||||
node = node.left
|
node = node.left
|
||||||
|
|
|
@ -610,7 +610,7 @@ class _MatchingContext:
|
||||||
# For each T-vertex or unlabeled vertex "x",
|
# For each T-vertex or unlabeled vertex "x",
|
||||||
# "vertex_sedge_queue[x]" is a queue of edges between "x" and any
|
# "vertex_sedge_queue[x]" is a queue of edges between "x" and any
|
||||||
# S-vertex. The priority of an edge is 2 times its pseudo-slack.
|
# S-vertex. The priority of an edge is 2 times its pseudo-slack.
|
||||||
self.vertex_sedge_queue: list[PriorityQueue]
|
self.vertex_sedge_queue: list[PriorityQueue[int]]
|
||||||
self.vertex_sedge_queue = [PriorityQueue() for _x in range(num_vertex)]
|
self.vertex_sedge_queue = [PriorityQueue() for _x in range(num_vertex)]
|
||||||
self.vertex_sedge_node: list[Optional[PriorityQueue.Node]]
|
self.vertex_sedge_node: list[Optional[PriorityQueue.Node]]
|
||||||
self.vertex_sedge_node = [None for _e in graph.edges]
|
self.vertex_sedge_node = [None for _e in graph.edges]
|
||||||
|
@ -623,9 +623,9 @@ class _MatchingContext:
|
||||||
|
|
||||||
for blossom in itertools.chain(self.trivial_blossom,
|
for blossom in itertools.chain(self.trivial_blossom,
|
||||||
self.nontrivial_blossom):
|
self.nontrivial_blossom):
|
||||||
|
blossom.parent = None
|
||||||
blossom.vertex_set.clear()
|
blossom.vertex_set.clear()
|
||||||
del blossom.vertex_set
|
del blossom.vertex_set
|
||||||
blossom.tree_blossoms = None
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Least-slack edge tracking:
|
# Least-slack edge tracking:
|
||||||
|
@ -1316,6 +1316,9 @@ class _MatchingContext:
|
||||||
|
|
||||||
self.delta2_enable_blossom(sub)
|
self.delta2_enable_blossom(sub)
|
||||||
|
|
||||||
|
# Avoid leaking a reference cycle.
|
||||||
|
del blossom.vertex_set
|
||||||
|
|
||||||
# Delete the expanded blossom.
|
# Delete the expanded blossom.
|
||||||
self.nontrivial_blossom.remove(blossom)
|
self.nontrivial_blossom.remove(blossom)
|
||||||
|
|
||||||
|
@ -1827,7 +1830,7 @@ class _MatchingContext:
|
||||||
# This loop runs through at most O(n) iterations per stage.
|
# This loop runs through at most O(n) iterations per stage.
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
self._check_alternating_tree_consistency() # TODO -- remove this
|
# self._check_alternating_tree_consistency() # TODO -- remove this
|
||||||
|
|
||||||
# Consider the incident edges of newly labeled S-vertices.
|
# Consider the incident edges of newly labeled S-vertices.
|
||||||
self.scan_new_s_vertices()
|
self.scan_new_s_vertices()
|
||||||
|
|
Loading…
Reference in New Issue