@@ -3,12 +3,12 @@ import sequentialFill from 'ml-array-sequential-fill';
33import type { Matrix } from 'ml-matrix' ;
44
55interface GetShortestPathOptions {
6- currUnAssCol : number ,
7- dualVariableForColumns : DoubleArray ,
8- dualVariableForRows : DoubleArray ,
9- rowAssignments : DoubleArray ,
10- columnAssignments : DoubleArray ,
11- matrix : Matrix ,
6+ currUnAssCol : number ;
7+ dualVariableForColumns : DoubleArray ;
8+ dualVariableForRows : DoubleArray ;
9+ rowAssignments : DoubleArray ;
10+ columnAssignments : DoubleArray ;
11+ matrix : Matrix ;
1212}
1313
1414export function getShortestPath ( options : GetShortestPathOptions ) {
@@ -21,7 +21,7 @@ export function getShortestPath(options: GetShortestPathOptions) {
2121 matrix,
2222 } = options ;
2323
24- let nbRows = matrix . rows
24+ let nbRows = matrix . rows ;
2525 let nbColumns = matrix . columns ;
2626
2727 let pred = new Float64Array ( nbColumns ) ;
@@ -43,10 +43,14 @@ export function getShortestPath(options: GetShortestPathOptions) {
4343 for ( let curRowScan = 0 ; curRowScan < numRows2Scan ; curRowScan ++ ) {
4444 let curRow = rows2Scan [ curRowScan ] ;
4545
46- let reducedCost = delta + matrix . get ( curRow , curColumn ) - dualVariableForColumns [ curColumn ] - dualVariableForRows [ curRow ] ;
46+ let reducedCost =
47+ delta +
48+ matrix . get ( curRow , curColumn ) -
49+ dualVariableForColumns [ curColumn ] -
50+ dualVariableForRows [ curRow ] ;
4751 if ( reducedCost < shortestPathCost [ curRow ] ) {
4852 pred [ curRow ] = curColumn ;
49- shortestPathCost [ curRow ] = reducedCost
53+ shortestPathCost [ curRow ] = reducedCost ;
5054 }
5155
5256 if ( shortestPathCost [ curRow ] < minVal ) {
@@ -74,16 +78,20 @@ export function getShortestPath(options: GetShortestPathOptions) {
7478 for ( let sel = 0 ; sel < nbColumns ; sel ++ ) {
7579 if ( scannedColumns [ sel ] === 0 ) continue ;
7680 if ( sel === currUnAssCol ) continue ;
77- dualVariableForColumns [ sel ] += delta - shortestPathCost [ columnAssignments [ sel ] ] ;
81+ dualVariableForColumns [ sel ] +=
82+ delta - shortestPathCost [ columnAssignments [ sel ] ] ;
7883 }
7984 for ( let sel = 0 ; sel < nbRows ; sel ++ ) {
8085 if ( scannedRows [ sel ] === 0 ) continue ;
81- dualVariableForRows [ sel ] -= ( delta - shortestPathCost [ sel ] ) ;
86+ dualVariableForRows [ sel ] -= delta - shortestPathCost [ sel ] ;
8287 }
8388
8489 return {
85- sink, pred, dualVariableForColumns, dualVariableForRows
86- }
90+ sink,
91+ pred,
92+ dualVariableForColumns,
93+ dualVariableForRows,
94+ } ;
8795}
8896
8997function getArrayOfInfinity ( nbElements = 1 , value = Number . POSITIVE_INFINITY ) {
@@ -92,4 +100,4 @@ function getArrayOfInfinity(nbElements = 1, value = Number.POSITIVE_INFINITY) {
92100 array [ i ] = value ;
93101 }
94102 return array ;
95- }
103+ }
0 commit comments