Optimal Party Grouping
Goal
You have friends and want to invite friends for a party. You want to find such a -group such that these friends, when getting together, feel least embarrassed.
I found this problem interesting and practical in my daily life. There are several views for solving the problem:
- Social network view: if you know the social connections between your friends, you can minimize the embarrassment by forming a group such that the friends in the group are most familiar with others, which corresponds to a densest subgraph problem;
- Embedding view: if you know the embeddings (e.g., interests, identities) of your friends, you can minimize the embarrassment by forming a group with most common features, which can be transformed into a distance minimization problem.
Solution based on social networks
We can formalize the problem as: given a graph with a root vertex such that every other vertex is connected to , find a subset such that and such that the density of the subgraph induced by is maximized. The density of a subgraph is defined as , where is the set of edges in the subgraph induced by .
There is a simple greedy solution using time: each round we locate the vertex with minimum degree and remove it from the graph until only vertices are left. Note that will not be removed since it has the largest degree. It is straightforward to verify the correctness of the solution.
UPD: The above greedy solution is wrong. A counterexample can be constructed by conneting with a -clique and a large-enough complete bipartite graph. Then the clique will be incorrectly pruned.
We can prove this problem is NP-hard by reducing from size- densest subgraph problem, which aims to find a densest subgraph with exactly vertices.
Let be the target graph of the size- densest subgraph problem, which is known to be NP-hard. We construct by adding a vertex connecting every vertex in . Therefore, solving our version of problem, and then removing , gives the result for size- densest subgraph problem.
Solution based on embeddings
This is the way I prefer more. I don’t want to invite a group of friends that are already very familiar with each other, or in the same community. For example, using the above approach for my friends will result in a group of all my lab colleagues. However, how to make your friends “least embarrassed” if they are not familiar with each other? Maximizing their common interests can help.
Let’s say a friend can be represented by a -dimensional vector. Each dimension is within representing an interest. For example, let the first dimension be interests on K-pop. Then represents the friend is not interested in K-pop, while represents the friend is interested in K-pop. Then we can formalize the problem as:
- Given a set of vectors , find a subset such that such that the sum of square distances between the vectors in is minimized. More formally:
Here means not inviting the -th friend, while means inviting the -th friend. is an auxiliary variable indicating whether both the -th and -th friends are invited. The above problem can be solved by integer programming solvers such as Gurobi.