[869] | 1 | //Source: https://github.com/mcximing/hungarian-algorithm-cpp/blob/master/Hungarian.h
|
---|
| 2 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 3 | // Hungarian.h: Header file for Class HungarianAlgorithm.
|
---|
| 4 | //
|
---|
| 5 | // This is a C++ wrapper with slight modification of a hungarian algorithm implementation by Markus Buehren.
|
---|
| 6 | // The original implementation is a few mex-functions for use in MATLAB, found here:
|
---|
| 7 | // http://www.mathworks.com/matlabcentral/fileexchange/6543-functions-for-the-rectangular-assignment-problem
|
---|
| 8 | //
|
---|
| 9 | // Both this code and the orignal code are published under the BSD license.
|
---|
| 10 | // by Cong Ma, 2016
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | #ifndef HUNGARIAN_H
|
---|
| 14 | #define HUNGARIAN_H
|
---|
| 15 |
|
---|
| 16 | class HungarianAlgorithm
|
---|
| 17 | {
|
---|
| 18 | public:
|
---|
| 19 | HungarianAlgorithm();
|
---|
| 20 | ~HungarianAlgorithm();
|
---|
| 21 | double Solve(double *&distMatrixIn, int *&assignment, int nRows, int nCols);
|
---|
| 22 |
|
---|
| 23 | private:
|
---|
| 24 | void assignmentoptimal(int *assignment, double *cost, double *distMatrix, int nOfRows, int nOfColumns);
|
---|
| 25 | void buildassignmentvector(int *assignment, bool *starMatrix, int nOfRows, int nOfColumns);
|
---|
| 26 | void computeassignmentcost(int *assignment, double *cost, double *distMatrix, int nOfRows);
|
---|
| 27 | void step2a(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim);
|
---|
| 28 | void step2b(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim);
|
---|
| 29 | void step3(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim);
|
---|
| 30 | void step4(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim, int row, int col);
|
---|
| 31 | void step5(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim);
|
---|
| 32 | };
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | #endif
|
---|