Figure6:盖尔-夏普利算法 Gale-Shapley方法:M=男子的集合,W=女子的集合 function stableMatching Initialize all m∈M and w∈V to free while 3 free man m who still has a woman w to propose to w=m's highest ranked such woman to whom he has not yet proposed if w is free (m,w)become engaged else some pair (m',w)already exists if w prefers m to m' (m,w)become engaged m'becomes free else (m',w)remain engaged } 6Figure 6: ❳✏-❣✃⑤➂④ Gale-Shapley➄④: M=■❢✛✽Ü➜W=å❢✛✽Ü function stableMatching { Initialize all m ∈ M and w ∈ W to free while ∃ free man m who still has a woman w to propose to { w = m0 s highest ranked such woman to whom he has not yet proposed if w is free (m, w) become engaged else some pair (m0 , w) already exists if w prefers m to m0 (m, w) become engaged m0 becomes free else (m0 , w) remain engaged } } 6