I am trying to make a system that will sort a list individuals and their preferred list of others. This may not make complete sense, but bear with me.
I have a list of people, each with their list of other people in the main list. The idea is to group the people in to g number of groups, with n number of people per group, while optimizing based on preferences for other people. If one person's preferences request a different person, the algorithm would have to weight the groups so that they are paired together (if possible). If two individuals request each other, it would need to weight that higher than if it was just one way.
Does anyone have any ideas on an algorithm to determine the optimal groupings? Pseudo-code, English description or sample code would all be very helpful.