3

Suppose I have a graph with node weights, where a weight is either -1 or a positive integer. For example:

A graph

If a node has weight -1, it is "happy", and cannot be kicked out of the graph.
If a node has positive weight, it is "unhappy", and can be kicked out of the graph.

How do I efficiently calculate which unhappy nodes I should kick out of the graph in order to minimize unhappiness, i.e., the total weight of all unhappy nodes, while making sure that the graph remains connected?

For instance, in this case, I can't get rid of more than three unhappy nodes, since that would disconnect the graph. Out of the possible sets of three unhappy nodes, {10, 10, 8} disconnects the graph as well. Thus the optimal solution is removing the three unhappy nodes at bottom, so that only the two unhappy nodes at top remain. The unhappiness of the graph becomes 2 + 10 = 12, which is the minimum.

(Motivation: I was wondering how many unhappy counties can secede from a U.S. state without breaking the state into disconnected components, and got this graph problem that I can't figure out.)

416E64726577
  • 133
  • 5

1 Answers1

5

The problem is equivalent to the node-weighted version of the Steiner tree problem. Happy nodes correspond to terminals, and non-removed unhappy nodes correspond to Steiner vertices.

This problem is NP-hard even for planar graphs. The NP-hardness can be proven by reducing the edge-weighted Steiner tree problem: insert one vertex in the middle of each edge.

The Dreyfus-Wagner algorithm can be used for the node-weighted version as well, and runs in $O(3^k \mathrm{poly}(n))$ time where $k$ is the number of terminal nodes. If $n - k$ is small compared to $k$, bruteforcing Steiner vertices gives $O(2^{n-k} \mathrm{poly}(n))$ time bound.

pcpthm
  • 2,962
  • 6
  • 16