Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb52212

Browse files
🎨 style(blossom): Detect uncovered cases with assertions.
1 parent f10a183 commit fb52212

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/core/blossom/blossom.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
189189
console.debug('DEBUG: assignLabel(' + w + ',' + t + ',' + p + ')');
190190
const b = inblossom[w];
191191
assert(label[w] === 0 && label[b] === 0);
192+
assert(t === 1 || t === 2);
192193
label[w] = t;
193194
label[b] = t;
194195
labelend[w] = p;
@@ -202,7 +203,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
202203
}
203204

204205
console.debug('DEBUG: PUSH ' + queue);
205-
} else if (t === 2) {
206+
} else {
206207
// B became a T-vertex/blossom; assign label S to its mate.
207208
// (If b is a non-trivial blossom, its base is the only vertex
208209
// with an external mate.)
@@ -888,6 +889,12 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
888889

889890
// Take action at the point where minimum delta occurred.
890891
console.debug('DEBUG: delta' + deltatype + '=' + delta);
892+
assert(
893+
deltatype === 1 ||
894+
deltatype === 2 ||
895+
deltatype === 3 ||
896+
deltatype === 4
897+
);
891898
if (deltatype === 1) {
892899
// No further improvement possible; optimum reached.
893900
break;
@@ -910,7 +917,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
910917
const i = edges[deltaedge][0];
911918
assert(label[inblossom[i]] === 1);
912919
queue.push(i);
913-
} else if (deltatype === 4) {
920+
} else {
914921
// Expand the least-z blossom.
915922
expandBlossom(deltablossom, false);
916923
}

0 commit comments

Comments
 (0)