Supply Chain Lab Assignment & the Hungarian Method Lab Home
Network & Optimisation

Assignment & the Hungarian Method

Five drivers, five routes, one each - who goes where? Greedy picks the cheapest cell and regrets it later. Kuhn’s Hungarian method manufactures zeros until the answer is forced, in O(n³) instead of n!. Step it one move at a time and watch the optimum appear.

How to use it

Drivers → routes

Problem

Algorithm

Assignment

-
–
Covering lines vs n
–
vs greedy
–
vs all n! options

Working matrix. Green = the chosen assignment. Pale cells are zeros the algorithm created; red bars are the covering lines.

The same answer as a bipartite matching - each driver to exactly one route, each route to exactly one driver.

Try these experiments

  1. Compare with greedy (always take the cheapest remaining cell): greedy is frequently worse, because a cheap first pick can strand an expensive last one.
  2. Add a constant to an entire row: the optimal assignment does not change. That invariance is exactly why row reduction is legal.
  3. Switch to Maximise (think profit, not cost) - same algorithm, costs negated. n! grows brutally: n=7 is 5,040 options; n=15 would be a trillion.

About this tool

The concept

The assignment problem: pair n agents with n tasks, one each, at least total cost. It is the purest matching problem in operations research.

How it works

Kuhn’s Hungarian method (1955), O(n³): subtracting a constant from any row or column leaves the optimal assignment unchanged, so you can manufacture zeros until n independent ones exist.

Winning strategy

Never assign greedily. And note the transportation tool solves this too - assignment is just transportation with all supplies and demands equal to 1.

Background: Hungarian algorithm · Assignment problem · Kuhn (1955)