projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- renamed access offset functions\n- renamed entity -> ir_entity
[libfirm]
/
ir
/
adt
/
hungarian.c
diff --git
a/ir/adt/hungarian.c
b/ir/adt/hungarian.c
index
953cf7d
..
7d08c43
100644
(file)
--- a/
ir/adt/hungarian.c
+++ b/
ir/adt/hungarian.c
@@
-26,6
+26,10
@@
/* $Id$ */
/* $Id$ */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@
-82,7
+86,6
@@
void hungarian_print_costmatrix(hungarian_problem_t *p) {
*/
hungarian_problem_t *hungarian_new(int rows, int cols, int width, int match_type) {
int i;
*/
hungarian_problem_t *hungarian_new(int rows, int cols, int width, int match_type) {
int i;
- int max_cost = 0;
hungarian_problem_t *p = xmalloc(sizeof(*p));
memset(p, 0, sizeof(p));
hungarian_problem_t *p = xmalloc(sizeof(*p));
memset(p, 0, sizeof(p));
@@
-185,7
+188,7
@@
void hungarian_free(hungarian_problem_t* p) {
/**
* Do the assignment.
*/
/**
* Do the assignment.
*/
-int hungarian_solve(hungarian_problem_t* p, int *assignment) {
+int hungarian_solve(hungarian_problem_t* p, int *assignment
, int *final_cost, int cost_threshold
) {
int i, j, m, n, k, l, s, t, q, unmatched, cost;
int *col_mate;
int *row_mate;
int i, j, m, n, k, l, s, t, q, unmatched, cost;
int *col_mate;
int *row_mate;
@@
-409,7
+412,10
@@
done:
/* collect the assigned values */
for (i = 0; i < m; ++i) {
/* collect the assigned values */
for (i = 0; i < m; ++i) {
- assignment[i] = col_mate[i];
+ if (cost_threshold > 0 && p->cost[i][col_mate[i]] >= cost_threshold)
+ assignment[i] = -1; /* remove matching having cost > threshold */
+ else
+ assignment[i] = col_mate[i];
}
/* In case of normal matching: remove impossible ones */
}
/* In case of normal matching: remove impossible ones */
@@
-443,5
+449,7
@@
done:
xfree(unchosen_row);
xfree(col_mate);
xfree(unchosen_row);
xfree(col_mate);
- return cost;
+ *final_cost = cost;
+
+ return 0;
}
}