Perfect Matching

Abstract

This is pseudocode for Perfect Matching in Bipartite Graphs, adapted from the paperback edition of A Gentle Introduction to Optimization, B. Guerin et al. This is used as a subroutine to find any perfect matching on a subgraph of the larger bipartite graph in the Hungarian Algorithm, whose goal is to find a minimum weight perfect matching.

The operator Δ is essentially an exclusive OR (XOR) of the two sets:

MΔP=(MP)(MP). (1)

Executed on an alternating paths of links included in versus excluded from the set and a second path including at leaast part of that first set, it has the behavior of flipping the ones included versus excluded.

I believe this algorithm as stated assumes that the input graph H is connected.

\SetAlgoCaptionSeparator

.4

{algorithm}

Perfect Matching

\AlgoDisplayBlockMarkers\AlgoDisplayGroupMarkers\SetAlgoBlockMarkers

{ } \SetAlgoNoEnd\SetAlgoNoLine

\SetKwInOut

InputInput\SetKwInOutOutputOutput \InputBipartite graph H=(V,E) with bipartition U,W where |U|=|W|1 \OutputA perfect matching M, or a deficient set B U. M:=
T:=({r},) where rU is any M-exposed vertex
\While(1) \uIf uv where u B(T) and vV(T) \uIfv is M-exposed P:=Tru{uv}
M:=MΔP
\lIfM is a perfect matchingstop T:=({r},) where r is any M-exposed vertex. \Else Let wV where vwM
T:=(V(T){v,w},E(T){uv,vw}) \Else stop B(T)U is a deficient set