Neeldhara
  • About
  • Research
    • Overview
    • People
    • Publications
    • Surveys
  • Teaching
    • Courses
    • Materials
  • Lists
    • Puzzles
    • Bookmarks
  • Exposition
    • Talks
    • Videos
  • Events
  • Blog

5. Maximum Independent Set on Trees

  • Advanced Algorithms
    • Flows
    • Intractability
    • Approximation Algorithms
    • Randomized Algorithms
    • Greedy Algorithms
      • 1. Storing Files on a Tape
      • 2. A Scheduling Problem
      • 3. Stable Matchings
    • Matroids
      • 1. The Motivation
      • 2. The Definition
      • 3. Greedy Works!
      • 4. Scheduling with Deadlines
    • Dynamic Programming
      • 1. Longest Increasing Subsequence
      • 2. Subset Sum
      • 3. Set Cover
      • 4. Optimal BSTs
      • 5. Maximum Independent Set on Trees

On this page

  • The Problem
  • The Solution

5. Maximum Independent Set on Trees

algonotes
lecturenotes
Published

May 16, 2023

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 eee has an amount f(e)⩾0f(e) \geqslant 0f(e)⩾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)f(e) over all invited employees eee. 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)G=(V,E) that is a rooted tree on nnn vertices with a weight function w:V⟶Nw: V \longrightarrow \mathbb{N}w:V⟶N and root rrr.
  • We want to output the weight of a max-weight independent set in GGG.

The Solution

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

For v∈Vv \in Vv∈V, let T[v]T[v]T[v] denote the weight of a max-weight independent set in GvG_vGv​, which is the subtree of GGG rooted at vvv.

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

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

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

If vvv is a leaf node, then T[v]=w(v)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 SSS of GvG_vGv​. We have to wonder: does SSS contain vvv?

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

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

T⁡(v)=max⁡{∑w↓vT⁡(w),1+∑w↓v∑x↓wT⁡(x)},\operatorname{T}(v)=\max \left\{\sum_{w \downarrow v} \operatorname{T}(w), 1+\sum_{w \downarrow v} \sum_{x \downarrow w} \operatorname{T}(x)\right\},T(v)=max⎩⎨⎧​w↓v∑​T(w),1+w↓v∑​x↓w∑​T(x)⎭⎬⎫​,

where the notation w↓vw \downarrow vw↓v means “w is a child of v”.

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.


© 2022 • Neeldhara Misra • Credits •

 

Corrections? Please leave a comment here or a PR in this repository, thanks!

I’d rather be a failure at something I love than a success at something I hate.

George Burns

You live and you learn — at any rate, you live.

Douglas Adams

A problem worthy of attack proves its worth by fighting back.

Paul Erdos

×