-/**
- * Do the 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 *parent_row;
- int *unchosen_row;
- int *row_dec;
- int *col_inc;
- int *slack;
- int *slack_row;
-
- cost = 0;
- m = p->num_rows;
- n = p->num_cols;
-
- col_mate = XMALLOCNZ(int, p->num_rows);
- unchosen_row = XMALLOCNZ(int, p->num_rows);
- row_dec = XMALLOCNZ(int, p->num_rows);
- slack_row = XMALLOCNZ(int, p->num_rows);
-
- row_mate = XMALLOCNZ(int, p->num_cols);
- parent_row = XMALLOCNZ(int, p->num_cols);
- col_inc = XMALLOCNZ(int, p->num_cols);
- slack = XMALLOCNZ(int, p->num_cols);
-
- memset(assignment, -1, m * sizeof(assignment[0]));
+int hungarian_solve(hungarian_problem_t* p, unsigned *assignment,
+ int *final_cost, int cost_threshold)
+{
+ int cost = 0;
+ unsigned num_rows = p->num_rows;
+ unsigned num_cols = p->num_cols;
+ unsigned *col_mate = XMALLOCNZ(unsigned, num_rows);
+ unsigned *row_mate = XMALLOCNZ(unsigned, num_cols);
+ unsigned *parent_row = XMALLOCNZ(unsigned, num_cols);
+ unsigned *unchosen_row = XMALLOCNZ(unsigned, num_rows);
+ int *row_dec = XMALLOCNZ(int, num_rows);
+ int *col_inc = XMALLOCNZ(int, num_cols);
+ int *slack = XMALLOCNZ(int, num_cols);
+ unsigned *slack_row = XMALLOCNZ(unsigned, num_rows);
+ unsigned r;
+ unsigned c;
+ unsigned t;
+ unsigned unmatched;
+
+ memset(assignment, -1, num_rows * sizeof(assignment[0]));