Skip to main content

This site is currently under development.

5. Maximum Independent Set on Trees

Acknowledgements

Some of this material is borrowed from Jeff Erickson's chapters on Recursion, Backtracking, and Dynamic Programming. The fun factor at a party formulation can be found in an exercise of Erickson as well as these slides by Dàniel Marx. Thanks to Arya for pointing out a correction.

The Problem

You are planning a corporate party. Every employee ee has an amount f(e)⩾0f(e) \geqslant 0 of fun that they will bring to the party if invited. The total fun in the party is the sum of f(e)f(e) over all invited employees ee. You want your party to be very fun. In fact, as fun as possible. However, it turns out that if you invite a manager and their direct report together, the party will be absolutely no fun, not for anyone. What's the best you can do?

Concretely, the problem is the following.

  • We are given a graph G=(V,E)G = (V,E) that is a rooted tree on nn vertices with a weight function w:V⟶Nw: V \longrightarrow \mathbb{N} and root rr.

  • We want to output the weight of a max-weight independent set in GG.

The Solution

What are the fragments (AKA, what do we want to store)?

For v∈Vv \in V, let T[v]T[v] denote the weight of a max-weight independent set in GvG_v, which is the subtree of GG rooted at vv.

Are the fragments going to be useful (AKA, where is the final answer)?

Indeed, T[r]T[r] is what we want!

Do we have a kickstart (AKA, what are the base cases)?

If vv is a leaf node, then T[v]=w(v)T[v] = w(v).

How do the fragments come together (AKA, how do we compute the values that we have agreed to store)?

For the sake of analysis, fix a max-weight independent set SS of GvG_v. We have to wonder: does SS contain vv?

  • If the answer is no, then SS can be viewed as a union of optimal solutions in all the subtrees rooted at the children of vv.

  • If the answer is yes, then SS can be viewed as a union of optimal solutions in all the subtrees rooted at the grandchildren of vv (since the children are now forbidden), and the vertex vv itself.

As always, we take the best of both worlds when we pen down our recurrence:

T⁡(v)=max⁡(∑w↓vT⁡(w), w(v)+∑w↓v∑x↓wT⁡(x)),\operatorname{T}(v)=\max \left(\sum_{w \downarrow v} \operatorname{T}(w),\ w(v)+\sum_{w \downarrow v} \sum_{x \downarrow w} \operatorname{T}(x)\right),

where the notation w↓vw \downarrow v means "ww is a child of vv".

Can we put the pieces together without getting stuck (AKA, are the dependencies in step #4 acyclic)?

Proceed from the leaves of the tree upwards.