1
0
Fork 0

Remove expand_unlabeled_blossom()

This commit is contained in:
Joris van Rantwijk 2024-11-21 21:46:39 +01:00
parent 3815335a9f
commit b5ccbdeda4
1 changed files with 7 additions and 42 deletions

View File

@ -1383,17 +1383,14 @@ public:
blossom->tree_root = subblossoms.front()->tree_root; blossom->tree_root = subblossoms.front()->tree_root;
} }
/** Erase the specified non-trivial blossom. */ /** Expand and delete the specified T-blossom. */
void erase_nontrivial_blossom(NonTrivialBlossomT* blossom) void expand_t_blossom(NonTrivialBlossomT* blossom)
{
nontrivial_blossom.erase(blossom->this_blossom_iterator);
}
/** Expand the specified unlabeled blossom but do not yet delete it. */
void expand_unlabeled_blossom_core(NonTrivialBlossomT* blossom)
{ {
assert(blossom->parent == nullptr); assert(blossom->parent == nullptr);
assert(blossom->label == LABEL_NONE); assert(blossom->label == LABEL_T);
// Remove label from blossom.
remove_blossom_label_t(blossom);
// Remove blossom from the delta2 queue. // Remove blossom from the delta2 queue.
delta2_disable_blossom(blossom); delta2_disable_blossom(blossom);
@ -1420,26 +1417,6 @@ public:
// Add unlabeled blossom to the delta2 queue. // Add unlabeled blossom to the delta2 queue.
delta2_enable_blossom(sub_blossom); delta2_enable_blossom(sub_blossom);
} }
}
/** Expand and delete the specified unlabeled blossom. */
void expand_unlabeled_blossom(NonTrivialBlossomT* blossom)
{
expand_unlabeled_blossom_core(blossom);
erase_nontrivial_blossom(blossom);
}
/** Expand and delete the specified T-blossom. */
void expand_t_blossom(NonTrivialBlossomT* blossom)
{
assert(blossom->parent == nullptr);
assert(blossom->label == LABEL_T);
// Remove label from blossom.
remove_blossom_label_t(blossom);
// Expand the unlabeled blossom.
expand_unlabeled_blossom_core(blossom);
// The expanded blossom was part of an alternating tree. // The expanded blossom was part of an alternating tree.
// We must now reconstruct the part of the alternating tree // We must now reconstruct the part of the alternating tree
@ -1506,7 +1483,7 @@ public:
} }
// Delete the expanded blossom. // Delete the expanded blossom.
erase_nontrivial_blossom(blossom); nontrivial_blossom.erase(blossom->this_blossom_iterator);
} }
/* ********** Augmenting: ********** */ /* ********** Augmenting: ********** */
@ -1714,8 +1691,6 @@ public:
* a matched edge to the base of the newly labeled T-blossom. * a matched edge to the base of the newly labeled T-blossom.
* That newly labeled S-blossom is also added to the alternating tree. * That newly labeled S-blossom is also added to the alternating tree.
* *
* Note that this function may expand blossoms that contain vertex "y".
*
* @pre "x" is an S-vertex. * @pre "x" is an S-vertex.
* @pre "y" is an unlabeled, matched vertex. * @pre "y" is an unlabeled, matched vertex.
* @pre The top-level blossom that contains "y" has a matched base vertex. * @pre The top-level blossom that contains "y" has a matched base vertex.
@ -1727,16 +1702,6 @@ public:
BlossomT* by = top_level_blossom(y); BlossomT* by = top_level_blossom(y);
assert(bx->label == LABEL_S); assert(bx->label == LABEL_S);
// If "y" is part of a zero-dual blossom, expand it.
// This would otherwise likely happen through a zero-delta4 step,
// so we can just do it now and avoid a substage.
NonTrivialBlossomT* ntb = by->nontrivial();
while (ntb != nullptr && ntb->dual_var == 0) {
expand_unlabeled_blossom(ntb);
by = top_level_blossom(y);
ntb = by->nontrivial();
}
// Assign label T to the top-level blossom that contains vertex "y". // Assign label T to the top-level blossom that contains vertex "y".
assign_blossom_label_t(by); assign_blossom_label_t(by);
by->tree_edge = std::make_pair(x, y); by->tree_edge = std::make_pair(x, y);