Content deleted Content added
→Analysis: +teh |
→Algorithm: separate out alternating path description into a new section |
||
Line 12:
* Symmetric difference <math>M'=M\oplus P</math> has all edges of M and P except shared edges <math>M\cap P</math>
==Alternating paths==
==Algorithm==▼
The basic concept that the algorithm relies on is that
Conversely, suppose that a matching ''M'' is not optimal, and let ''P'' be the symmetric difference ''M'' ⊕ ''M''* where ''M''* is an optimal matching. Then ''P'' must form a collection of disjoint cycles and alternating paths; the difference in size between ''M'' and ''M''* is the number of paths in ''P''. Thus, if no alternating path can be found, an algorithm may safely terminate, since in this case ''M'' must be optimal.
▲==Algorithm==
Let ''U'' and ''V'' be the two sets in the bipartition of ''G'', and let the matching from ''U'' to ''V'' at any time be represented as the set ''M''.
The algorithm is run in phases. Each phase consists of the following steps.
* A [[breadth first search]] is run from the free vertices in ''U''.
* Collect ''all'' free vertices in ''V'' at layer ''k'' and put them in the set ''F''. That is, a vertex ''v'' is put into F if and only if it ends a shortest augmenting path.
* Find a maximal set of ''vertex disjoint'' augmenting paths of length ''k''. This is set may be computed by [[depth first search]] from ''F'' to the free vertices in ''U'', using the breadth first layering to guide the search: the depth first search is only allowed to follow edges that lead to an unused vertex in the previous layer. Once an augmenting path is found that involves one of the vertices in ''F'', the depth first search is continued from the next starting vertex.
* Every one of the paths found in this way is used to enlarge ''M''.
|