Skip to content

Commit 03dca79

Browse files
committed
test with g++
1 parent 09db4f7 commit 03dca79

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Hungarian.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// by Cong Ma, 2016
1010
//
1111

12+
#include <stdlib.h>
13+
#include <cfloat> // for DBL_MAX
14+
#include <cmath> // for fabs()
1215
#include "Hungarian.h"
1316

1417

@@ -19,7 +22,7 @@ HungarianAlgorithm::~HungarianAlgorithm(){}
1922
//********************************************************//
2023
// A single function wrapper for solving assignment problem.
2124
//********************************************************//
22-
double HungarianAlgorithm::Solve(vector<vector<double>>& DistMatrix, vector<int>& Assignment)
25+
double HungarianAlgorithm::Solve(vector <vector<double> >& DistMatrix, vector<int>& Assignment)
2326
{
2427
unsigned int nRows = DistMatrix.size();
2528
unsigned int nCols = DistMatrix[0].size();

Hungarian.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// by Cong Ma, 2016
1010
//
1111

12+
#ifndef HUNGARIAN_H
13+
#define HUNGARIAN_H
14+
1215
#include <iostream>
1316
#include <vector>
1417

@@ -20,7 +23,7 @@ class HungarianAlgorithm
2023
public:
2124
HungarianAlgorithm();
2225
~HungarianAlgorithm();
23-
double Solve(vector<vector<double>>& DistMatrix, vector<int>& Assignment);
26+
double Solve(vector <vector<double> >& DistMatrix, vector<int>& Assignment);
2427

2528
private:
2629
void assignmentoptimal(int *assignment, double *cost, double *distMatrix, int nOfRows, int nOfColumns);
@@ -32,3 +35,6 @@ class HungarianAlgorithm
3235
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);
3336
void step5(int *assignment, double *distMatrix, bool *starMatrix, bool *newStarMatrix, bool *primeMatrix, bool *coveredColumns, bool *coveredRows, int nOfRows, int nOfColumns, int minDim);
3437
};
38+
39+
40+
#endif

testMain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
int main(void)
66
{
7-
vector<vector<double>> costMatrix = { { 10, 19, 8, 15, 0 },
7+
// please use "-std=c++11" for this initialization of vector.
8+
vector< vector<double> > costMatrix = { { 10, 19, 8, 15, 0 },
89
{ 10, 18, 7, 17, 0 },
910
{ 13, 16, 9, 14, 0 },
1011
{ 12, 19, 8, 18, 0 } };

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