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

  1. Scale the costs: work with phases, in phase using .
  2. Maintain -optimality via dual prices : every edge satisfies .
  3. In each phase, halve and repair the matching using Hopcroft-Karp-style phases of vertex-disjoint augmenting paths, which is where the comes from.
  4. When , integrality forces exact optimality.

Complexity

versus:

AlgorithmTime
Brute force over permutations
Bitmask DP — best for
Hungarianthe 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