Traditional marriage algorithm implementation