"Note" stable marriage problem

One kind of graph theory problem.

For n n boys and girls.
For their hearts \ (n \) heterosexual has a favorability list.
Our demand is to find a perfect match.
For each non-matching two point \ (U, v \) , if they consider that other than their current \ (npy \) favorability is higher.
Then this marriage is unstable.
We ask that a stable marriage matching.

In order to follow the boys and girls do not shameless active principle.
Therefore, the algorithm flow is like this:
be \ (n \) iterations.
Each round of iteration, not all the boys off single to his confession is not currently the highest favorability girls confession.
If the girls boyfriend's current favorability favorability lower than the boys, then the girls will get rid of the current boyfriend, cheating to the new confession of the boys.
The final \ (n \) after iteration, all men and women friends can get married, can demonstrate that such marriages are stable marriage.

Examples have heard a.
2014 Tsinghua training matrix transformation
we put the line into left and right part and a digital point.
Favorability numbers of the line is the higher the ranking.
The line is to the favorability numbers are higher on the back.
So will overwrite the previous digital back.
After the stabilization program is to meet the fourth condition of the answer.

Guess you like

Origin www.cnblogs.com/Lrefrain/p/12373898.html