1
0
Fork 0

Fix wrong assumption about subblossom labels

When a blossom forms, the labels of sub-blossoms do NOT strictly alternate between S and T when walking around the blossom.
This commit is contained in:
Joris van Rantwijk 2023-02-06 09:04:43 +01:00
parent 575d33c90f
commit 99bc2912d8
1 changed files with 10 additions and 7 deletions

View File

@ -753,7 +753,8 @@ def _make_blossom(
# Former T-vertices which are part of this blossom have now become # Former T-vertices which are part of this blossom have now become
# S-vertices. Add them to the queue. # S-vertices. Add them to the queue.
for sub in subblossoms[1::2]: for sub in subblossoms:
if stage_data.blossom_label[sub] == _LABEL_T:
if sub < num_vertex: if sub < num_vertex:
stage_data.queue.append(sub) stage_data.queue.append(sub)
else: else:
@ -780,7 +781,9 @@ def _make_blossom(
0 for b in range(2 * num_vertex)] 0 for b in range(2 * num_vertex)]
# Add the least-slack edges of every S-sub-blossom. # Add the least-slack edges of every S-sub-blossom.
for sub in subblossoms[0::2]: for sub in subblossoms:
if stage_data.blossom_label[sub] != _LABEL_S:
continue
if sub < num_vertex: if sub < num_vertex:
# Trivial blossoms don't have a list of least-slack edges, # Trivial blossoms don't have a list of least-slack edges,
# so we just look at all adjacent edges. This happens at most # so we just look at all adjacent edges. This happens at most
@ -1072,7 +1075,7 @@ def _find_path_through_blossom(
# ^^^ ^^^ # ^^^ ^^^
# <------------------- # <-------------------
# #
# We must flip edges from (v,w) to (w,v) to make them fit # We flip edges from (v,w) to (w,v) to make them fit
# in the path from "s" to base. # in the path from "s" to base.
edges.append(blossom.edges[i-1][::-1]) edges.append(blossom.edges[i-1][::-1])
nodes.append(blossom.subblossoms[i-1]) nodes.append(blossom.subblossoms[i-1])