Purpose: Solve the assignment problem (minimum-cost perfect matching in a bipartite graph) in using cost scaling — faster than the Hungarian algorithm when costs are moderate.
Gabow and Tarjan also produced a well-known linear-time special case of union-find, described below.
Assignment by cost scaling
Algorithm
- Scale the costs: work with phases, in phase using .
- Maintain -optimality via dual prices : every edge satisfies .
- In each phase, halve and repair the matching using Hopcroft-Karp-style phases of vertex-disjoint augmenting paths, which is where the comes from.
- When , integrality forces exact optimality.
Complexity
versus:
| Algorithm | Time |
|---|---|
| Brute force over permutations | |
| Bitmask DP | — best for |
| Hungarian | — the contest default |
| MCMF with potentials | |
| Gabow-Tarjan |
What to write
Hungarian, . For it runs in well under a second, and the implementation is ~40 lines. Use bitmask DP instead when and the cost structure is irregular.
Gabow-Tarjan union-find
A separate famous result: union-find in time, not , for the special case where the sequence of unions is known to follow a fixed tree structure given in advance.
The trick is a two-level micro/macro decomposition: split the tree into micro-trees of vertices, solve each by table lookup (four Russians), and run ordinary union-find on the macro nodes. The factor applies only to the tiny macro instance, where it is absorbed.
This is exactly what makes Tarjan’s offline LCA genuinely linear rather than , and it underlies linear-time algorithms for verifying minimum spanning trees.
Variants / Use Cases
- Hungarian algorithm — the practical assignment solver
- Gabow-Edmonds scaling — the general scaling framework
- DSU — the structure the linear-time result refines
- Assignment Problem — the problem page