Minimum Cost Perfect Matching
Abstract
This is pseudocode for the Hungarian Algorithm for Minimum Cost Perfect Matching in Bipartite Graphs, adapted from the paperback edition of A Gentle Introduction to Optimization, B. Guerin et al. This finds subgraphs of the original bipartite graph (which is often a complete bipartite graph), and uses the Perfect Matching algorithm as a subroutine to figure out if there is a perfect matching, in which case we are done.
.5
is the set of neighbors of the set on the graph . One thing I do not like about this particular pseudocode is that the interface with the perfect matching subroutine is imprecise, and this algorithm depends on side effects from that subroutine. The subroutine might return (a) a new (larger) matching , (b) a new (larger) tree , or (c) a deficient set for that particular graph .
{ } \SetAlgoNoEnd\SetAlgoNoLine
InputInput\SetKwInOutOutputOutput\SetKwRepeatDodoWhile\InputBipartite graph with bipartition where
\OutputA minimum cost perfect matching or a deficient set
where is any -exposed vertex
(1)
Construct graph (a subset of the original graph )
with vertices and edges { : = +
Invoke the subroutine (Algo. 3.4) with ,, and
outcome (a) of subroutine occurs
\uIf is a perfect matching of
stop ( is minimum cost perfect matching of )
\ElseIfoutcome (c) of subroutine occurs
Let
\lIfall edges of with an endpoint in have an endpoint in
stop ( has no perfect matching)
Otherwise, adjust the costs to create a new
zero, and loop
(1) |
outcome (b) of subroutine occurs Just loop again with augmented path