X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fhungarian.c;h=7d08c437ea65ce3f393c6f8dcd24cd9987d44a89;hb=0decb677fb069c9d47f5285f12fdb983dca7fdae;hp=bbb8590498d09d79217d43e30042659889de065e;hpb=ff7766fa12750305f3eb293cfcef2f3de63aeb01;p=libfirm diff --git a/ir/adt/hungarian.c b/ir/adt/hungarian.c index bbb859049..7d08c437e 100644 --- a/ir/adt/hungarian.c +++ b/ir/adt/hungarian.c @@ -26,6 +26,10 @@ /* $Id$ */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include @@ -184,7 +188,7 @@ void hungarian_free(hungarian_problem_t* p) { /** * Do the assignment. */ -int hungarian_solve(hungarian_problem_t* p, int *assignment, int *final_cost) { +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; @@ -408,7 +412,10 @@ done: /* 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 */