You can apply Bipartite Matching algorithm of Graph Theory. All you have to do is:
Thanks for asking this question. Finally I have found a real life problem which can be solved by what Prof Panda has been teaching us for 2-3 years.
P.S. I can provide you code for both weighted and unweighted maximum bipartite matching which I made for my project.
- Put all girls as vertices (a's) in Part A, and boys as vertices (b's) in Part B.
- Draw an edge between vertex a to vertex b if a likes b.
- It will be a bipartite graph (there are no edges within vertices of Part A, and same for Part B) unless your friends are not straight.
- Then find maximum matching for this bipartite graph. (refer this linkMaximum Bipartite Matching - GeeksforGeeks)
- You will get maximum matching as output and the matched edges will be the pairs who should be together.
- You can apply weighted bipartite matching algorithm if you know how much they love/like each other. In that case, assign weights according to their amount of love. and repeat step 4 and 5.
Thanks for asking this question. Finally I have found a real life problem which can be solved by what Prof Panda has been teaching us for 2-3 years.
P.S. I can provide you code for both weighted and unweighted maximum bipartite matching which I made for my project.