Hungarian algorithm: Difference between revisions

Content deleted Content added
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 148:
*/
 
#includeimport <cassert>;
 
import std;
 
template <typename T, typename U>
using Pair = std::pair;
using VectorPair = std::vectorpair<T, U>;
template <typename T>
using PairVector = std::pairvector<T>;
 
template <typename T>
Line 568 ⟶ 570:
If the number of starred zeros is {{mvar|n}} (or in the general case <math>min(n,m)</math>, where {{mvar|n}} is the number of people and {{mvar|m}} is the number of jobs), the algorithm terminates. See the [[#Result|Result]] subsection below on how to interpret the results.
 
Otherwise, find the lowest uncovered value. Subtract this from every unmarkeduncovered element and add it to every element covered by two lines. Go back to step 4.
 
This is equivalent to subtracting a number from all rows which are not covered and adding the same number to all columns which are covered. These operations do not change optimal assignments.