+/EE360C
algorithms
git clone https://git.julia.blue/+/EE360C
15a3727
master
1public abstract class AbstractProgram1 { 2public abstract boolean isStableMatching (Matching marriage ); 3 4/** 5* Brute force solution to the Stable Marriage problem. Relies on the 6* function isStableMatching(Matching) to determine whether a candidate 7* Matching is stable. 8* 9* @return A stable Matching. 10*/ 11public Matching stableMarriageBruteForce (Matching marriage ) { 12int n =marriage .getStudentCount (); 13int slots =marriage .totalInternshipSlots (); 14 15Permutation p =new Permutation (n ,slots ); 16Matching matching ; 17while ((matching =p .getNextMatching (marriage )) !=null ) { 18if (isStableMatching (matching )) { 19return matching ; 20 } 21 } 22 23return new Matching (marriage ); 24 } 25 26public abstract Matching 27stableMarriageBruteForce_studentoptimal (Matching marriage ); 28 29public abstract Matching 30stableMarriageGaleShapley_studentoptimal (Matching marriage ); 31}