Allocation problems and bipartite graphs
Learn how to match people to jobs in the best possible way in Year 12 General Mathematics for Queensland (QCAA). A surf club rostering lifeguards to beaches, a council sending crews to roadworks or a coach choosing relay legs all face the same puzzle: each person does one job, and the total time or cost should be as low as it can be.
You will show these problems as a bipartite graph, a table and a matrix, move between the three forms, and handle pairings that are not allowed. For small problems you will list every allocation and pick the minimum or maximum total, and see why grabbing the cheapest pairing first can fail, which sets up the Hungarian algorithm for larger problems.
Theory
Who should do which job? This Year 12 General Mathematics guide for Queensland students shows how to set up an allocation problem as a bipartite graph, a table or a matrix, and how to find the minimum-cost or maximum-profit allocation of a small problem by listing every allocation and comparing the totals.
An allocation problem (also called an assignment problem) matches a group of workers to a group of tasks, one task each, so that the total cost, time or distance is as small as possible, or the total profit or score is as large as possible. Each way of matching them is called an allocation and is written as pairs, such as \(A\)–\(Z\), \(B\)–\(Y\), \(C\)–\(X\).
A bipartite graph shows the problem. Its vertices are split into two groups, workers on one side and tasks on the other, and every edge joins a worker to a task. An edge means that worker can do that task, and its weight is the cost (or profit) of that pairing. A missing edge means the pairing is not possible.
The same information can be written as a table or a matrix, with one row for each worker and one column for each task, in a stated order. A dash marks a pairing that cannot happen. With \(n\) workers and \(n\) tasks there are \(n \times (n - 1) \times \dots \times 1\) allocations, so a \(3 \times 3\) problem has \(6\), few enough to check by inspection.
The same problem as a table (rows = workers \(A, B, C\); columns = tasks \(X, Y, Z\)) and as a matrix:
| X | Y | Z | |
|---|---|---|---|
| A | 5 | 8 | 6 |
| B | 7 | 4 | 9 |
| C | 6 | 7 | 8 |
Number of possible allocations for \(n\) workers and \(n\) tasks (no pairings ruled out):
Total of an allocation:
Drawing the bipartite graph from a table
- Put the workers in a column on the left and the tasks in a column on the right.
- For each entry in the table that is not a dash, join that worker to that task and write the number on the edge.
- Check that no edge joins two workers or two tasks.
Finding the best allocation by inspection
- List every allocation. Fix the first worker’s task, then go through the ways of giving out the rest. Skip any pairing marked with a dash.
- Total each allocation using the table, one line each.
- Choose the optimum: the smallest total for cost, time or distance, the largest for profit or score.
- State the allocation as worker–task pairs and give the total with units.
| X | Y | Z | |
|---|---|---|---|
| K | ✓ | ✓ | – |
| L | ✓ | – | ✓ |
| M | – | ✓ | ✓ |
Join each volunteer to each stall with a tick. Then try each stall for \(K\).
| \(K\text{–}X\) | \(:\) | \(L \text{ must take } Z,\ M \text{ takes } Y\) |
| \(K\text{–}Y\) | \(:\) | \(M \text{ must take } Z,\ L \text{ takes } X\) |
(i) The graph has six edges, one for each tick. (ii) There are only two allocations: \(K–X, L–Z, M–Y\) and \(K–Y, L–X, M–Z\). The dashes rule out the other four.
A \(3 \times 3\) problem has \(6\) allocations. List and total them all.
| Allocation | Total |
|---|---|
| P–1, Q–2, R–3 | \(14 + 13 + 16 = 43\) |
| P–1, Q–3, R–2 | \(14 + 8 + 15 = 37\) |
| P–2, Q–1, R–3 | \(9 + 11 + 16 = 36\) |
| P–2, Q–3, R–1 | \(9 + 8 + 10 = 27\) |
| P–3, Q–1, R–2 | \(12 + 11 + 15 = 38\) |
| P–3, Q–2, R–1 | \(12 + 13 + 10 = 35\) |
The smallest total is 27 km, from \(P–2, Q–3, R–1\). Notice that \(R\) takes route \(1\) even though \(R\)–\(1\) is not the smallest number in the table.
| X | Y | Z | |
|---|---|---|---|
| D | 7 | 5 | 9 |
| E | 6 | 8 | 4 |
| F | 9 | 7 | 6 |
This time choose the largest total.
| Allocation | Total |
|---|---|
| D–X, E–Y, F–Z | \(7 + 8 + 6 = 21\) |
| D–X, E–Z, F–Y | \(7 + 4 + 7 = 18\) |
| D–Y, E–X, F–Z | \(5 + 6 + 6 = 17\) |
| D–Y, E–Z, F–X | \(5 + 4 + 9 = 18\) |
| D–Z, E–X, F–Y | \(9 + 6 + 7 = 22\) |
| D–Z, E–Y, F–X | \(9 + 8 + 9 = 26\) |
The largest total is \(26\) hundred dollars, from \(D–Z, E–Y, F–X\). Expected sales are $2600. (The smallest total, \(17\), would be the worst choice here.)
(i) Take the smallest entry, cross out its row and column, and repeat.
| \(\text{smallest left}\) | \(:\) | \(P\text{–}X = 3\) |
| \(\text{smallest left}\) | \(:\) | \(R\text{–}Y = 7\) |
| \(\text{smallest left}\) | \(:\) | \(Q\text{–}Z = 14\) |
| \(\text{total}\) | \(=\) | \(3 + 7 + 14\) |
| \(\) | \(=\) | \(24\ \text{min}\) |
(ii) Now check all six allocations:
| Allocation | Total |
|---|---|
| P–X, Q–Y, R–Z | \(3 + 10 + 12 = 25\) |
| P–X, Q–Z, R–Y | \(3 + 14 + 7 = 24\) |
| P–Y, Q–X, R–Z | \(6 + 4 + 12 = 22\) |
| P–Y, Q–Z, R–X | \(6 + 14 + 8 = 28\) |
| P–Z, Q–X, R–Y | \(9 + 4 + 7 = 20\) |
| P–Z, Q–Y, R–X | \(9 + 10 + 8 = 27\) |
(i) Cheapest-first gives \(24\) minutes. (ii) The minimum is 20 minutes, from \(P–Z, Q–X, R–Y\). Grabbing the \(3\) first forced \(Q\) into the \(14\)-minute job.
Common pitfalls
Frequently asked questions
What is a bipartite graph?
It is a graph whose vertices split into two groups so that every edge joins a vertex in one group to a vertex in the other. In allocation problems one group is the workers and the other is the tasks.
What is an allocation or assignment problem?
It is the problem of matching each worker to exactly one task so that the total cost or time is as small as possible, or the total profit is as large as possible.
How many allocations are there for 3 workers and 3 tasks?
There are 3 x 2 x 1 = 6. The first worker has 3 choices, the second has 2 left and the last has 1. For 2 workers and 2 tasks there are only 2.
What does a dash mean in an allocation table?
It means that worker cannot do that task, so there is no edge between them in the bipartite graph and any allocation using that pairing is not allowed.
How do you find the optimum allocation by inspection?
List every possible allocation, add up the entries for each one, then choose the smallest total for costs or the largest total for profits.
What if two allocations give the same best total?
Then both are optimal and either one can be used. State both if the question asks for every optimum allocation.