I have a matching problem, which I think is np-hard:
We need to arrange a dinner for a group of n people, some of the people are friends with eachother, some are not. We need to sit everyone at a table, but they should never sit with someone that they are not friends with. There are *k* tables K = r1+r2+···+rk=n.
**Input**
input is formatted as one first line k, then follow one line of k numbers, where each number represents a table and it's capacity. Then comes n lines of people, where we can see friendships of person i. All friendships are mutual.
**Output**
Output the formations of people that can be seated together, without having to sit with someone that they are not friends with
example:
Input:
2
3, 3
Alice: Bob, Claire, Eric, Juliet, Romeo
Bob: Alice, Claire, Juliet, Romeo
Claire: Alice, Bob, Juliet
Eric: Alice, Romeo
Juliet: Alice, Bob, Claire
Romeo: Alice, Bob, Eric
Output:
Romeo, Eric, Alice
Bob, Claire, Juliet
Im fairly certain that this problem is np-complete, but I am having some problems finding a proper reduction.
The example corresponds to the following (badly drawn)graph:
I have a loose idea around using a complimentary graph to reduce to independent set. but i would be very gratefull for any ideas for solutions
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…