libFirm 1.20
|
00001 /******************************************************************** 00002 ******************************************************************** 00003 ** 00004 ** libhungarian by Cyrill Stachniss, 2004 00005 ** 00006 ** Added to libFirm by Christian Wuerdig, 2006 00007 ** Added several options for not-perfect matchings. 00008 ** 00009 ** Solving the Minimum Assignment Problem using the 00010 ** Hungarian Method. 00011 ** 00012 ** ** This file may be freely copied and distributed! ** 00013 ** 00014 ** Parts of the used code was originally provided by the 00015 ** "Stanford GraphGase", but I made changes to this code. 00016 ** As asked by the copyright node of the "Stanford GraphGase", 00017 ** I hereby proclaim that this file are *NOT* part of the 00018 ** "Stanford GraphGase" distribution! 00019 ** 00020 ** This file is distributed in the hope that it will be useful, 00021 ** but WITHOUT ANY WARRANTY; without even the implied 00022 ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00023 ** PURPOSE. 00024 ** 00025 ******************************************************************** 00026 ********************************************************************/ 00027 00032 #ifndef FIRM_ADT_HUNGARIAN_H 00033 #define FIRM_ADT_HUNGARIAN_H 00034 00035 #include "../begin.h" 00036 00045 typedef enum match_type_t { 00046 HUNGARIAN_MATCH_NORMAL, 00047 HUNGARIAN_MATCH_PERFECT 00049 } match_type_t; 00050 00052 typedef enum hungarian_mode_t { 00053 HUNGARIAN_MODE_MINIMIZE_COST, 00054 HUNGARIAN_MODE_MAXIMIZE_UTIL 00055 } hungarian_mode_t; 00056 00060 typedef struct hungarian_problem_t hungarian_problem_t; 00061 00071 FIRM_API hungarian_problem_t *hungarian_new(unsigned num_rows, 00072 unsigned num_cols, 00073 match_type_t match_type); 00074 00078 FIRM_API void hungarian_add(hungarian_problem_t *p, unsigned left, 00079 unsigned right, unsigned cost); 00080 00084 FIRM_API void hungarian_remove(hungarian_problem_t *p, unsigned left, 00085 unsigned right); 00086 00093 FIRM_API void hungarian_prepare_cost_matrix(hungarian_problem_t *p, 00094 hungarian_mode_t mode); 00095 00099 FIRM_API void hungarian_free(hungarian_problem_t *p); 00100 00109 FIRM_API int hungarian_solve(hungarian_problem_t *p, unsigned *assignment, 00110 unsigned *final_cost, unsigned cost_threshold); 00111 00117 FIRM_API void hungarian_print_cost_matrix(hungarian_problem_t *p, 00118 int cost_width); 00119 00122 #include "../end.h" 00123 00124 #endif