11import 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' ;
1212
1313// Adapted from http://jorisvr.nl/maximummatching.html
1414// 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) {
281281 ' w=' +
282282 w +
283283 ') -> ' +
284- b
284+ b ,
285285 ) ;
286286 blossombase [ b ] = base ;
287287 blossomparent [ b ] = - 1 ;
@@ -299,7 +299,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
299299 endps . push ( labelend [ bv ] ) ;
300300 assert (
301301 label [ bv ] === 2 ||
302- ( label [ bv ] === 1 && labelend [ bv ] === mate [ blossombase [ bv ] ] )
302+ ( label [ bv ] === 1 && labelend [ bv ] === mate [ blossombase [ bv ] ] ) ,
303303 ) ;
304304 // Trace one step back.
305305 assert ( labelend [ bv ] >= 0 ) ;
@@ -320,7 +320,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
320320 endps . push ( labelend [ bw ] ^ 1 ) ;
321321 assert (
322322 label [ bw ] === 2 ||
323- ( label [ bw ] === 1 && labelend [ bw ] === mate [ blossombase [ bw ] ] )
323+ ( label [ bw ] === 1 && labelend [ bw ] === mate [ blossombase [ bw ] ] ) ,
324324 ) ;
325325 // Trace one step back.
326326 assert ( labelend [ bw ] >= 0 ) ;
@@ -404,7 +404,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
404404 // Expand the given top-level blossom.
405405 const expandBlossom = ( b , endstage ) => {
406406 console . debug (
407- 'DEBUG: expandBlossom(' + b + ',' + endstage + ') ' + blossomchilds [ b ]
407+ 'DEBUG: expandBlossom(' + b + ',' + endstage + ') ' + blossomchilds [ b ] ,
408408 ) ;
409409 // Convert sub-blossoms into top-level blossoms.
410410 for ( let i = 0 ; i < blossomchilds [ b ] . length ; ++ i ) {
@@ -569,7 +569,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
569569 endpoint [ p ^ 1 ] +
570570 ' (k=' +
571571 Math . floor ( p / 2 ) +
572- ')'
572+ ')' ,
573573 ) ;
574574 }
575575
@@ -588,7 +588,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
588588 const w = edges [ k ] [ 1 ] ;
589589
590590 console . debug (
591- 'DEBUG: augmentMatching(' + k + ') (v=' + v + ' w=' + w + ')'
591+ 'DEBUG: augmentMatching(' + k + ') (v=' + v + ' w=' + w + ')' ,
592592 ) ;
593593 console . debug ( 'DEBUG: PAIR ' + v + ' ' + w + ' (k=' + k + ')' ) ;
594594
@@ -631,7 +631,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
631631 // it will be assigned to mate[s] in the next step.
632632 p = labelend [ bt ] ^ 1 ;
633633 console . debug (
634- 'DEBUG: PAIR ' + s + ' ' + t + ' (k=' + Math . floor ( p / 2 ) + ')'
634+ 'DEBUG: PAIR ' + s + ' ' + t + ' (k=' + Math . floor ( p / 2 ) + ')' ,
635635 ) ;
636636 }
637637 } ;
@@ -684,7 +684,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
684684
685685 // Continue labeling until all vertices which are reachable
686686 // through an alternating path have got a label.
687- while ( queue . length && ! augmented ) {
687+ while ( queue . length > 0 && ! augmented ) {
688688 // Take an S vertex from the queue.
689689 const v = queue . pop ( ) ;
690690 console . debug ( 'DEBUG: POP v=' + v ) ;
@@ -746,13 +746,13 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
746746 const b = inblossom [ v ] ;
747747 if ( bestedge [ b ] === - 1 || kslack < slack ( bestedge [ b ] ) )
748748 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
751751 // a T-blossom) but we can not reach it yet;
752752 // 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 ;
756756 }
757757 }
758758
@@ -776,7 +776,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
776776 endpoint,
777777 bestedge,
778778 slack,
779- inblossom
779+ inblossom,
780780 } ) ;
781781 checkDelta3 ( {
782782 nvertex,
@@ -788,7 +788,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
788788 endpoint,
789789 bestedge,
790790 slack,
791- inblossom
791+ inblossom,
792792 } ) ;
793793 }
794794
@@ -877,7 +877,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
877877 deltatype === 1 ||
878878 deltatype === 2 ||
879879 deltatype === 3 ||
880- deltatype === 4
880+ deltatype === 4 ,
881881 ) ;
882882 if ( deltatype === 1 ) {
883883 // No further improvement possible; optimum reached.
@@ -931,7 +931,7 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
931931 endpoint,
932932 dualvar,
933933 blossombase,
934- blossomendps
934+ blossomendps,
935935 } ) ;
936936
937937 // Transform mate[] such that mate[v] is the vertex to which v is paired.
0 commit comments