changed solve function, return now 0 or negative on number, cost are pointer param
authorChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Wed, 20 Sep 2006 14:59:21 +0000 (14:59 +0000)
committerChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Wed, 20 Sep 2006 14:59:21 +0000 (14:59 +0000)
[r8279]

ir/adt/hungarian.c
ir/adt/hungarian.h

index 5be8b71..bbb8590 100644 (file)
@@ -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;
 }
index 0fe7d9e..2ac922d 100644 (file)
@@ -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.