Skip to content

Commit ede74d8

Browse files
🎨 style(blossom): Reduce scope of variables.
1 parent 8c7383b commit ede74d8

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/core/blossom/blossom.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
644644
}
645645
};
646646

647-
let b;
648647
let d;
649-
let v;
650648
let kslack;
651649
let base;
652650
let deltatype;
@@ -696,7 +694,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
696694
// through an alternating path have got a label.
697695
while (queue.length && !augmented) {
698696
// Take an S vertex from the queue.
699-
v = queue.pop();
697+
const v = queue.pop();
700698
console.debug('DEBUG: POP v=' + v);
701699
assert(label[inblossom[v]] === 1);
702700

@@ -753,7 +751,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
753751
} else if (label[inblossom[w]] === 1) {
754752
// Keep track of the least-slack non-allowable edge to
755753
// a different S-blossom.
756-
b = inblossom[v];
754+
const b = inblossom[v];
757755
if (bestedge[b] === -1 || kslack < slack(bestedge[b]))
758756
bestedge[b] = k;
759757
} else if (label[w] === 0) {
@@ -859,7 +857,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
859857
}
860858

861859
// Update dual variables according to delta.
862-
for (v = 0; v < nvertex; ++v) {
860+
for (let v = 0; v < nvertex; ++v) {
863861
if (label[inblossom[v]] === 1) {
864862
// S-vertex: 2*u = 2*u - 2*delta
865863
dualvar[v] -= delta;
@@ -869,7 +867,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
869867
}
870868
}
871869

872-
for (b = nvertex; b < 2 * nvertex; ++b) {
870+
for (let b = nvertex; b < 2 * nvertex; ++b) {
873871
if (blossombase[b] >= 0 && blossomparent[b] === -1) {
874872
if (label[b] === 1) {
875873
// Top-level S-blossom: z = z + 2*delta
@@ -917,7 +915,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
917915
if (!augmented) break;
918916

919917
// End of a stage; expand all S-blossoms which have dualvar = 0.
920-
for (b = nvertex; b < 2 * nvertex; ++b) {
918+
for (let b = nvertex; b < 2 * nvertex; ++b) {
921919
if (
922920
blossomparent[b] === -1 &&
923921
blossombase[b] >= 0 &&
@@ -945,13 +943,13 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
945943
});
946944

947945
// Transform mate[] such that mate[v] is the vertex to which v is paired.
948-
for (v = 0; v < nvertex; ++v) {
946+
for (let v = 0; v < nvertex; ++v) {
949947
if (mate[v] >= 0) {
950948
mate[v] = endpoint[mate[v]];
951949
}
952950
}
953951

954-
for (v = 0; v < nvertex; ++v) {
952+
for (let v = 0; v < nvertex; ++v) {
955953
assert(mate[v] === -1 || mate[mate[v]] === v);
956954
}
957955

0 commit comments

Comments
 (0)