forked from whuang08/TreeScaper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hungarian.h
78 lines (61 loc) · 2.1 KB
/
hungarian.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/********************************************************************
********************************************************************
**
** libhungarian by Cyrill Stachniss, 2004
**
**
** Solving the Minimum Assignment Problem using the
** Hungarian Method.
**
** ** This file may be freely copied and distributed! **
**
** Parts of the used code was originally provided by the
** "Stanford GraphGase", but I made changes to this code.
** As asked by the copyright node of the "Stanford GraphGase",
** I hereby proclaim that this file are *NOT* part of the
** "Stanford GraphGase" distrubition!
**
** This file is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
** PURPOSE.
**
********************************************************************
********************************************************************/
#ifndef HUNGARIAN_H
#define HUNGARIAN_H
#ifdef __cplusplus
extern "C" {
#endif
#define HUNGARIAN_NOT_ASSIGNED 0
#define HUNGARIAN_ASSIGNED 1
#define HUNGARIAN_MODE_MINIMIZE_COST 0
#define HUNGARIAN_MODE_MAXIMIZE_UTIL 1
typedef struct {
int num_rows;
int num_cols;
int** cost;
int** assignment;
} hungarian_problem_t;
/** This method initialize the hungarian_problem structure and init
* the cost matrices (missing lines or columns are filled with 0).
* It returns the size of the quadratic(!) assignment matrix. **/
int hungarian_init(hungarian_problem_t* p,
int** cost_matrix,
int rows,
int cols,
int mode);
/** Free the memory allocated by init. **/
void hungarian_free(hungarian_problem_t* p);
/** This method computes the optimal assignment. **/
int hungarian_solve(hungarian_problem_t* p);
/** Print the computed optimal assignment. **/
void hungarian_print_assignment(hungarian_problem_t* p);
/** Print the cost matrix. **/
void hungarian_print_costmatrix(hungarian_problem_t* p);
/** Print cost matrix and assignment matrix. **/
void hungarian_print_status(hungarian_problem_t* p);
#ifdef __cplusplus
}
#endif
#endif