Skip to content

Commit 09db4f7

Browse files
committed
fix Assignment vector in abnormal cases
1 parent ed4f94f commit 09db4f7

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Hungarian.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ double HungarianAlgorithm::Solve(vector<vector<double>>& DistMatrix, vector<int>
2323
{
2424
unsigned int nRows = DistMatrix.size();
2525
unsigned int nCols = DistMatrix[0].size();
26-
Assignment.clear();
27-
28-
if (nRows == 0 || nCols == 0)
29-
return 0.0;
3026

3127
double *distMatrixIn = new double[nRows * nCols];
3228
int *assignment = new int[nRows];
@@ -43,6 +39,7 @@ double HungarianAlgorithm::Solve(vector<vector<double>>& DistMatrix, vector<int>
4339
// call solving function
4440
assignmentoptimal(assignment, &cost, distMatrixIn, nRows, nCols);
4541

42+
Assignment.clear();
4643
for (unsigned int r = 0; r < nRows; r++)
4744
Assignment.push_back(assignment[r]);
4845

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy