1
1
import assert from 'assert' ;
2
- import min from " ./min.js" ;
3
- import rotate from " ./rotate.js" ;
4
- import verifyOptimum from " ./verifyOptimum.js" ;
5
- import checkDelta2 from " ./checkDelta2.js" ;
6
- import checkDelta3 from " ./checkDelta3.js" ;
7
- import statistics from " ./statistics.js" ;
8
- import endpoints from " ./endpoints.js" ;
9
- import neighbours from " ./neighbours.js" ;
10
- import blossomLeaves from " ./blossomLeaves.js" ;
11
- import blossomEdges from " ./blossomEdges.js" ;
2
+ import min from ' ./min.js' ;
3
+ import rotate from ' ./rotate.js' ;
4
+ import verifyOptimum from ' ./verifyOptimum.js' ;
5
+ import checkDelta2 from ' ./checkDelta2.js' ;
6
+ import checkDelta3 from ' ./checkDelta3.js' ;
7
+ import statistics from ' ./statistics.js' ;
8
+ import endpoints from ' ./endpoints.js' ;
9
+ import neighbours from ' ./neighbours.js' ;
10
+ import blossomLeaves from ' ./blossomLeaves.js' ;
11
+ import blossomEdges from ' ./blossomEdges.js' ;
12
12
13
13
// Adapted from http://jorisvr.nl/maximummatching.html
14
14
// All credit for the implementation goes to Joris van Rantwijk [http://jorisvr.nl].
@@ -281,7 +281,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
281
281
' w=' +
282
282
w +
283
283
') -> ' +
284
- b
284
+ b ,
285
285
) ;
286
286
blossombase [ b ] = base ;
287
287
blossomparent [ b ] = - 1 ;
@@ -299,7 +299,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
299
299
endps . push ( labelend [ bv ] ) ;
300
300
assert (
301
301
label [ bv ] === 2 ||
302
- ( label [ bv ] === 1 && labelend [ bv ] === mate [ blossombase [ bv ] ] )
302
+ ( label [ bv ] === 1 && labelend [ bv ] === mate [ blossombase [ bv ] ] ) ,
303
303
) ;
304
304
// Trace one step back.
305
305
assert ( labelend [ bv ] >= 0 ) ;
@@ -320,7 +320,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
320
320
endps . push ( labelend [ bw ] ^ 1 ) ;
321
321
assert (
322
322
label [ bw ] === 2 ||
323
- ( label [ bw ] === 1 && labelend [ bw ] === mate [ blossombase [ bw ] ] )
323
+ ( label [ bw ] === 1 && labelend [ bw ] === mate [ blossombase [ bw ] ] ) ,
324
324
) ;
325
325
// Trace one step back.
326
326
assert ( labelend [ bw ] >= 0 ) ;
@@ -404,7 +404,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
404
404
// Expand the given top-level blossom.
405
405
const expandBlossom = ( b , endstage ) => {
406
406
console . debug (
407
- 'DEBUG: expandBlossom(' + b + ',' + endstage + ') ' + blossomchilds [ b ]
407
+ 'DEBUG: expandBlossom(' + b + ',' + endstage + ') ' + blossomchilds [ b ] ,
408
408
) ;
409
409
// Convert sub-blossoms into top-level blossoms.
410
410
for ( let i = 0 ; i < blossomchilds [ b ] . length ; ++ i ) {
@@ -569,7 +569,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
569
569
endpoint [ p ^ 1 ] +
570
570
' (k=' +
571
571
Math . floor ( p / 2 ) +
572
- ')'
572
+ ')' ,
573
573
) ;
574
574
}
575
575
@@ -588,7 +588,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
588
588
const w = edges [ k ] [ 1 ] ;
589
589
590
590
console . debug (
591
- 'DEBUG: augmentMatching(' + k + ') (v=' + v + ' w=' + w + ')'
591
+ 'DEBUG: augmentMatching(' + k + ') (v=' + v + ' w=' + w + ')' ,
592
592
) ;
593
593
console . debug ( 'DEBUG: PAIR ' + v + ' ' + w + ' (k=' + k + ')' ) ;
594
594
@@ -631,7 +631,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
631
631
// it will be assigned to mate[s] in the next step.
632
632
p = labelend [ bt ] ^ 1 ;
633
633
console . debug (
634
- 'DEBUG: PAIR ' + s + ' ' + t + ' (k=' + Math . floor ( p / 2 ) + ')'
634
+ 'DEBUG: PAIR ' + s + ' ' + t + ' (k=' + Math . floor ( p / 2 ) + ')' ,
635
635
) ;
636
636
}
637
637
} ;
@@ -684,7 +684,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
684
684
685
685
// Continue labeling until all vertices which are reachable
686
686
// through an alternating path have got a label.
687
- while ( queue . length && ! augmented ) {
687
+ while ( queue . length > 0 && ! augmented ) {
688
688
// Take an S vertex from the queue.
689
689
const v = queue . pop ( ) ;
690
690
console . debug ( 'DEBUG: POP v=' + v ) ;
@@ -746,13 +746,13 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
746
746
const b = inblossom [ v ] ;
747
747
if ( bestedge [ b ] === - 1 || kslack < slack ( bestedge [ b ] ) )
748
748
bestedge [ b ] = k ;
749
- } else if ( label [ w ] === 0 ) {
750
- // W is a free vertex (or an unreached vertex inside
749
+ } else if (
750
+ label [ w ] === 0 && // W is a free vertex (or an unreached vertex inside
751
751
// a T-blossom) but we can not reach it yet;
752
752
// keep track of the least-slack edge that reaches w.
753
- if ( bestedge [ w ] === - 1 || kslack < slack ( bestedge [ w ] ) )
754
- bestedge [ w ] = k ;
755
- }
753
+ ( bestedge [ w ] === - 1 || kslack < slack ( bestedge [ w ] ) )
754
+ )
755
+ bestedge [ w ] = k ;
756
756
}
757
757
}
758
758
@@ -776,7 +776,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
776
776
endpoint,
777
777
bestedge,
778
778
slack,
779
- inblossom
779
+ inblossom,
780
780
} ) ;
781
781
checkDelta3 ( {
782
782
nvertex,
@@ -788,7 +788,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
788
788
endpoint,
789
789
bestedge,
790
790
slack,
791
- inblossom
791
+ inblossom,
792
792
} ) ;
793
793
}
794
794
@@ -877,7 +877,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
877
877
deltatype === 1 ||
878
878
deltatype === 2 ||
879
879
deltatype === 3 ||
880
- deltatype === 4
880
+ deltatype === 4 ,
881
881
) ;
882
882
if ( deltatype === 1 ) {
883
883
// No further improvement possible; optimum reached.
@@ -931,7 +931,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
931
931
endpoint,
932
932
dualvar,
933
933
blossombase,
934
- blossomendps
934
+ blossomendps,
935
935
} ) ;
936
936
937
937
// Transform mate[] such that mate[v] is the vertex to which v is paired.
0 commit comments