Skip to main content
. 2021 Feb 10;21(4):1260. doi: 10.3390/s21041260
Algorithm 1. Pseudocode for the Hungarian algorithm Function Hungarian-Algorithm (G).
% initial vertex feasible labeling l1
i=1,j=1
xX,l1(x)=minxX{w(exy)}
yY,l1(y)=0
M1 initial matching 
while Mi<X
   % find the maximum matching M
   Mij=Mi
   do
    Fij+1alternating forest of Mij rooted at the unmatched vertices xX
    Pij+1 a path of Fij+1 which contain another unmatched vertex yY
    Mij+1=MijE(Pij+1)
    Qj+1=[XV(Fij+1)][YV(Fij+1)]
    j=j+1
   while MijQij
   Mi=Mij
   % update the feasible vertex labeling
   Fialternating forest of Mi rooted at the unmatched vertices xX
   S=V(Fi)X
   T=V(Fi)Y
   α=minxS,yT{w(exy)li(x)li(y)}
   li+1(v)=li(v)+αli(v)αli(v)if vSif vTotherwise
   i=i+1
done