How does the Hungarian algorithm assign tasks to workers so the total cost is the lowest possible, using row and column reduction?
Model an allocation problem with a cost matrix and a bipartite graph, apply the Hungarian algorithm using row reduction, column reduction and line covering to find the minimum-cost one-to-one allocation
A focused answer to the VCE General Mathematics Unit 4 Networks key-knowledge point on allocation. The cost matrix and bipartite model, row and column reduction, covering zeros with the fewest lines, the adjustment step, and reading off the minimum-cost assignment.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
VCAA wants you to solve an allocation (assignment) problem: matching workers to tasks one-to-one so the total cost or time is as small as possible. You set it up as a cost matrix (and recognise the underlying bipartite graph), then apply the Hungarian algorithm: reduce rows, reduce columns, cover the zeros with the fewest lines, adjust if needed, and read off the optimal assignment. This is the matching tool of the Networks module.
Setting up the cost matrix
Each row is a worker, each column a task, and each entry the cost (or time) of that worker doing that task. The bipartite graph has workers on one side and tasks on the other, with weighted edges. The goal is a perfect matching of least total weight. The matrix must be square; if it is not, a dummy row or column of zeros is added.
The Hungarian algorithm steps
- Row reduction: subtract the smallest entry in each row from every entry in that row.
- Column reduction: subtract the smallest entry in each column from every entry in that column.
- Cover the zeros: draw the fewest horizontal and vertical lines that cover all zeros.
- Test: if the number of lines equals the matrix size, an optimal assignment exists; jump to reading it off. Otherwise continue.
- Adjust: find the smallest uncovered entry, subtract it from every uncovered entry, and add it to every entry covered by two lines. Return to step 3.
Why the reductions preserve the optimal allocation
It is natural to wonder why subtracting a constant from a whole row or column does not change which allocation is best. The reason is that every valid one-to-one assignment uses exactly one entry from each row and one from each column. Subtracting a constant from a row therefore reduces the total of every possible assignment by the same constant, so the relative ordering of assignments is untouched and the cheapest assignment stays cheapest. The same holds for column reduction. This is why the algorithm can drive entries down to zeros and find the optimum among the zeros, then recover the true cost from the original matrix.
Handling unbalanced and maximising problems
Two variations appear in exams. If the cost matrix is not square (more tasks than workers, say), you add a dummy row or column of zeros to make it square; the dummy agent or task contributes zero cost and is ignored when reading the final allocation. If the problem asks to maximise rather than minimise (for example, maximising total profit or satisfaction), convert it to a minimisation by subtracting every entry from the largest entry in the matrix, then run the Hungarian algorithm as usual. Recognising which variation you face, and converting before reducing, is essential because the standard steps only minimise.
Reading off and verifying the final cost
Once the minimum number of covering lines equals the matrix size, an optimal assignment of zeros exists. Choose zeros so that there is exactly one in each row and each column, starting with any row or column that contains a single zero to avoid clashes. Then, and this is the step students most often miss, compute the total cost by adding the corresponding entries from the original cost matrix, not the reduced zeros. Stating the assignment in words (which worker does which task) and the original-matrix total gives the marker both the solution and its verifiable cost.
Why this matters for the exams
Allocation questions reward a disciplined run through the Hungarian steps and a final cost read from the original matrix. Markers check the reductions, the line-covering test, and a valid one-to-one assignment. The problem is the matching counterpart to maximum flow and critical path analysis, completing the decision-mathematics toolkit of the Networks module.
Exam-style practice questions
Practice questions written in the style of VCAA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
2023 VCAA1 marksFour employees are each assigned a different duty. The time taken, in minutes, is: Anthea (Duty 1 to 4) = 8, 7, 7, 8; Bob = 10, 8, 10, 9; Cho = 8, 9, 7, 10; Dario = 7, 7, 8, 9. The duties are allocated to minimise the total time taken. The minimum total time, in minutes, is A. 29 B. 30 C. 31 D. 32 E. 33Show worked answer →
This is a minimum-cost allocation. Use the Hungarian algorithm, or test sensible one-to-one assignments.
The optimal allocation is Anthea to Duty 2 (7), Bob to Duty 4 (9), Cho to Duty 3 (7) and Dario to Duty 1 (7).
total time = 7 + 9 + 7 + 7 = 30 minutes.
No other one-to-one assignment beats this, so the minimum total time is 30 minutes, option B.
2025 VCAA1 marksThe cost, in dollars, for four contractors P, Q, R, S to complete work at four sites is: P (Site 1 to 4) = 15 400, 9600, 22 750, 18 300; Q = 14 500, 10 000, 25 000, 19 450; R = 21 000, 12 400, 29 300, 24 600; S = 19 438, 9000, 23 150, 18 000. Using the Hungarian algorithm, Martha first subtracts the minimum entry in each row from each element in that row, then, using this new table, subtracts the minimum entry in each column from each element in that column. Which one of the following tables correctly displays the results after these two steps are completed?Show worked answer →
Step 1, row reduction. Subtract each row's smallest cost. Row minimums are P 9600, Q 10 000, R 12 400, S 9000, giving rows P: 5800, 0, 13 150, 8700; Q: 4500, 0, 15 000, 9450; R: 8600, 0, 16 900, 12 200; S: 10 438, 0, 14 150, 9000.
Step 2, column reduction on that table. Column minimums are 4500, 0, 13 150, 8700.
The result is P: 1300, 0, 0, 0; Q: 0, 0, 1850, 750; R: 4100, 0, 3750, 3500; S: 5938, 0, 1000, 300, which matches option B.
