Teaching / Algorithm Design / Network Flow III

Interactive lesson · Chapter 7 · Network Flow

Network Flow III: the assignment problem

Matching asks whether everyone can be paired. The assignment problem asks for the cheapest pairing. The idea that solves it is beautiful: put a price on every node, so that finding the next best change becomes a shortest-path problem with no negative edges.

For Algorithm Design (FTU, undergraduate). This page goes with the lecture slides 07 Network Flow III by Kevin Wayne. It builds on Part II (bipartite matching and alternating paths).

Sections: 1 The problem · 2 Prices change nothing · 3 Successive shortest paths · 4 Summary

1 · The problem (slides 3–9)

Pick the cheapest assignment

Given n workers X, n jobs Y, and a cost c(x, y) for giving job y to worker x, find a perfect matching of minimum total cost. Pick exactly one cell in every row and every column below. Can you beat every other assignment? There are n! of them.

2 · The key idea (slides 14–17)

Prices change nothing

Add a constant p(x) to every cost in row x. Every perfect matching uses exactly one cell of that row, so every matching gets p(x) more expensive: the best matching does not change. The same holds for subtracting a constant p(y) from a column. The reduced cost is cp(x,y) = p(x) + c(x,y) − p(y). Change the prices below: the numbers move, the optimal cells (outlined) never do. Prices are compatible with a matching M when cp ≥ 0 everywhere and = 0 on M: then M has cost 0 under cp, and nothing can be cheaper, so M is optimal.

3 · The algorithm (slides 12–34)

Successive shortest paths

Start with an empty matching and all prices 0. Repeat n times: find the cheapest alternating path from an unmatched x to an unmatched y, augment along it, then add each node’s distance to its price. Because the prices stay compatible, every edge has a non-negative reduced cost, so plain Dijkstra finds the path. The table on the right shows the reduced costs cp; the small grey number is the original cost. Edges with reduced cost 0 (tight) are free to use. It uses the problem you chose above.

Bipartite graph p = price · d = distance from the unmatched x

Reduced costs cp small grey = original c

matched edgeaugmenting path (dashed = matched edge removed)tight edge, cp = 0

4 · Summary (slides 34–40)

What to remember

Questions to explore

  1. Greedy. In section 1, always take the cheapest available cell row by row. Is it optimal? Use the lecture example.
  2. Equal costs. Make every cost 0 except a few. What does the algorithm do, and how does it relate to bipartite matching?
  3. Tight edges. After each iteration, which edges are tight? Why is every matched edge tight?
  4. Re-matching. Find an iteration whose path has a dashed (removed) edge. Why can a later worker take a job from an earlier one?