-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi phoemur,
congratulations on this amazing implementation of the Hungarian Algorithm!
I found a problem with the size of the vector path used on step 5 to track zero primes and zero stars. I believe the size must be at least twice the size of the squared matrix (original). The change should be made on the following line:
hungarian_algorithm/hungarian.cpp
Line 496 in 89af778
std::vector<std::vector<int>> path (sz+1, std::vector<int>(2, 0)); |
It should be 2*sz instead of sz+1.
You can check this problem with the following input:
tests.push_back({{100,100,100,81},
{100,100,100,100},
{100,100,100,17},
{100,100,100,100},
{100,100,100,99}});
After a few iterations you end-up on the following situation:
0' 0 0 0* 0
0 0 0* 19 0'
64 64 64 0' 64
0 0* 0' 19 0
0* 0' 0 18 0
In this situation you will added the 9 elements in bold on the path vector but its size is 5 resulting in a segmentation fault.
Cheers!