From ff7766fa12750305f3eb293cfcef2f3de63aeb01 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Wed, 20 Sep 2006 14:59:21 +0000 Subject: [PATCH] changed solve function, return now 0 or negative on number, cost are pointer param [r8279] --- ir/adt/hungarian.c | 6 ++++-- ir/adt/hungarian.h | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ir/adt/hungarian.c b/ir/adt/hungarian.c index 5be8b71e4..bbb859049 100644 --- a/ir/adt/hungarian.c +++ b/ir/adt/hungarian.c @@ -184,7 +184,7 @@ void hungarian_free(hungarian_problem_t* p) { /** * 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 i, j, m, n, k, l, s, t, q, unmatched, cost; int *col_mate; int *row_mate; @@ -442,5 +442,7 @@ done: xfree(unchosen_row); xfree(col_mate); - return cost; + *final_cost = cost; + + return 0; } diff --git a/ir/adt/hungarian.h b/ir/adt/hungarian.h index 0fe7d9eb3..2ac922d10 100644 --- a/ir/adt/hungarian.h +++ b/ir/adt/hungarian.h @@ -76,9 +76,10 @@ void hungarian_free(hungarian_problem_t *p); * This method computes the optimal assignment. * @param p The hungarian object * @param assignment The final assignment - * @return The resulting cost or a negative value if matching is invalid. + * @param final_cost The final costs + * @return 0 on success, negative number otherwise */ -int hungarian_solve(hungarian_problem_t *p, int *assignment); +int hungarian_solve(hungarian_problem_t *p, int *assignment, int *final_cost); /** * Print the cost matrix. -- 2.20.1