Skip to content

Commit d43f225

Browse files
🎨 style(blossom): Reduce scopes.
1 parent ede74d8 commit d43f225

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/core/blossom/blossom.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
264264
// connects a pair of S vertices. Label the new blossom as S; set its dual
265265
// variable to zero; relabel its T-vertices to S and add them to the queue.
266266
const addBlossom = (base, k) => {
267-
let i;
268267
let v = edges[k][0];
269268
let w = edges[k][1];
270269
const bb = inblossom[base];
@@ -381,7 +380,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
381380

382381
blossombestedges[b] = [];
383382
const length_2 = bestedgeto.length;
384-
for (i = 0; i < length_2; ++i) {
383+
for (let i = 0; i < length_2; ++i) {
385384
k = bestedgeto[i];
386385
if (k !== -1) blossombestedges[b].push(k);
387386
}
@@ -391,7 +390,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
391390
const length_3 = blossombestedges[b].length;
392391
if (length_3 > 0) {
393392
bestedge[b] = blossombestedges[b][0];
394-
for (i = 1; i < length_3; ++i) {
393+
for (let i = 1; i < length_3; ++i) {
395394
k = blossombestedges[b][i];
396395
if (slack(k) < slack(bestedge[b])) {
397396
bestedge[b] = k;
@@ -408,19 +407,8 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
408407
'DEBUG: expandBlossom(' + b + ',' + endstage + ') ' + blossomchilds[b]
409408
);
410409
// Convert sub-blossoms into top-level blossoms.
411-
let i;
412-
let j;
413-
let s;
414-
let p;
415-
let entrychild;
416-
let jstep;
417-
let endptrick;
418-
let bv;
419-
let stop;
420-
let base;
421-
422-
for (i = 0; i < blossomchilds[b].length; ++i) {
423-
s = blossomchilds[b][i];
410+
for (let i = 0; i < blossomchilds[b].length; ++i) {
411+
const s = blossomchilds[b][i];
424412

425413
blossomparent[s] = -1;
426414
if (s < nvertex) inblossom[s] = s;
@@ -443,9 +431,13 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
443431
// Figure out through which sub-blossom the expanding blossom
444432
// obtained its label initially.
445433
assert(labelend[b] >= 0);
446-
entrychild = inblossom[endpoint[labelend[b] ^ 1]];
434+
const entrychild = inblossom[endpoint[labelend[b] ^ 1]];
447435
// Decide in which direction we will go round the blossom.
448-
j = blossomchilds[b].indexOf(entrychild);
436+
let j = blossomchilds[b].indexOf(entrychild);
437+
let jstep;
438+
let endptrick;
439+
let stop;
440+
let base;
449441
if (j & 1) {
450442
// Start index is odd; go forward.
451443
jstep = 1;
@@ -461,7 +453,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
461453
}
462454

463455
// Move along the blossom until we get to the base.
464-
p = labelend[b];
456+
let p = labelend[b];
465457
while (j !== stop) {
466458
// Relabel the T-sub-blossom.
467459
label[endpoint[p ^ 1]] = 0;
@@ -478,7 +470,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
478470

479471
// Relabel the base T-sub-blossom WITHOUT stepping through to
480472
// its mate (so don't call assignLabel).
481-
bv = blossomchilds[b][0];
473+
let bv = blossomchilds[b][0];
482474
label[endpoint[p ^ 1]] = 2;
483475
label[bv] = 2;
484476
labelend[endpoint[p ^ 1]] = p;

0 commit comments

Comments
 (0)