CS 627 – Advanced Algorithms (Winter 2026-27) · unit page · YouTube
2026-11-23, 21:06

← Video 6-9: Treewidth PropertiesVideo 7-1: Randomization, Selection Lower Bounds →

Click any sentence to play from there.

The transcript was generated automatically by YouTube's speech recognition and is offered as is. It may contain errors, in particular concerning technical terms, names and formulas.

0:02 The key point I wanted to get to is is the following bit. We can use tree width or tree decompositions rather uh to make nice dynamic programming algorithms for these um optimization problems we've seen like independent set. And it generalizes to uh a whole bunch of other graph problems, vertex cover and coloring and so on. Um all are based on this observation we had before in the special case of a of a tree as the input graph that when you um remove a separator these problems essentially fall into independent subproblems, partitioned independent subproblems that you can solve uh separately and then recombine just at the separator. So we'll do that here too. Uh for that um we'll use our tree decomposition and root it at some arbitrary bag. Uh doesn't make make a difference where you do that. Now if you pick any um any bag and look at its subtree then uh all the vertices that occur in this subtree they induce an in subgraph of the original graph. Let's call that GT.

1:22 And then we'll look now specifically for independent set here. That's the description and we can think about generalizing later. Uh let's pick every possible contribution of this bag itself to an optimal independent set. That can be any subset of its vertices. So and if you if you hear uh iterating over all subsets that should always ring a bit of an alarm because that's exponential. But exponential in what? Well the number of vertices in this single bag. And the twin width bounds precisely the size of the bags. So the hope is that this exponential in the size of the bag is too bad for your spe- specific input graph. So for each such independent set contribution that this vertex could have or this bag could have um we keep track of what's the best that we could find uh in the subtree. So we take the largest value. This was the weighted independent set problem to make it even a bit more spicy in general.

2:24 Uh let's take the the sum of the weights of the vertices in this independent set and we restrict this to the subtree that we look at. Uh and we enforce that the contribution of our bag is precisely this subset S that we selected. If you think about it, if we know S and uh the best solution in the subtree, then we know everything of how to combine it with the rest of the graph because all the interactions between solutions for the rest of the graph and the subgraph in the subtree here are mediated through the vertices in BT. So if once I've fixed how what subset of BT I'm including in my solution set for this subtree, everyone else knows well uh these are fairly use. Any of their neighbors are off limits and you find the best solution to continue from there. And the root in the end contains the optimal solution where you still have to iterate over all the possible choices of sets there.

3:28 Okay. Um the size of this dynamic programming table is T for like all the bags. But you'll see that um the number of bags will be will be somewhat reasonable just by enumerating. There's not too many subsets of size W that you can have in principle. And we even we need to have a few less in most cases because uh they can't really all be connected. I guess what's the largest tree number of nodes in the tree decomposition. Um.

4:08 I think you can bound this way better than n to the w, but okay. Uh, for each of these, the number of sets of courses is two to the width with plus one. That's the expensive part.

4:25 Now, okay, the the intuition is that's the once we fix the size S on a subtree, then um we can recursively compute the best possible solution for independent set. Um, I'm including for sure the weight of the fixed set of vertices that I committed now to use. And then I may have subtrees, right? These are the the children here of of our bag in this subtree. For those, I have to pick again the the right um optimal solution. I've precomputed these bottom up or I'm using the recursion here. So there'll be in the subtree only, and they'll only use a fixed set of vertices in the root bag of that subtree. Well, and which set should that be? It should be the intersection of what I've chosen with S. So um if I take the intersection of S and the bag in TI, that gives me my intersection I'm aiming for and um these should just be the same same vertices. I think I have to um that's again S prime needs to include everything that's included in S, but maybe more. I have to go through all possible options of fixing vertices in this um in this root bag of the subtree.

5:55 This I add up for all the children, but the children themselves are again independently optimized. Okay, why Why that correct? Um If a vertex is in two different children, then it must also be in the root because it's a connected component. And so um once I take out the um root component, the subtree uh vertex sets are disjoint. I can also not have edges between these disjoint sets because uh an edge needs to be in some bag and uh separated that.

6:42 the weight in total, I didn't talk about that contribution here. Uh we're adding the weight of the vertices we include in S and then we have to subtract those that we double counted because S prime may need to contain a few vertices of S again. These I would have counted twice. I don't know outside of the sum which ones these are, so I have to do it inside the maximum. So these we subtract again. But that's that's really all. I mean the the bookkeeping isn't too bad and you can write this as as a bottom-up DP algorithm. That's the standard part. There's not much uh special going on. Um the the total time depends on the number of nodes in your tree decomposition because you have to go through these in uh the outer loop. It depends on um the tree width in a in a bad way where the the one exponential factor is obvious from going through all the subsets in a vertex.

7:43 Um but you have to check for every set S in your tree, you have to compute from your children and uh these also contribute a subset of their bag. So in total you may get the square of that, 4 to the W.

8:30 >> Okay, let me let me try to show you the algorithm in action as well. The tree decomposition here is brought into a specific normal form that makes makes it a bit more convenient to implement the algorithm.

8:47 It's brought into the normal form that every edge of the of the tree decomposition here adds a vertex. Like here I add from three I add the two and then I add the zero as you read this bottom up. There's the leaves are always just empty bags. Then I'm adding vertices one at a time. I'm adding zero, I'm adding four, I'm adding five. Then I might also remove vertices again along an edge.

9:17 So here the four is gone, then I add another vertex, remove another vertex. That's all I can do linearly changing the the bags. And you can you can take any of our previous tree decompositions and if there's a different distance between two bags, you just walk through them one step at a time, making sure that you first remove and then add, right? So that you don't increase the size by much.

9:44 And the other option you can have is that you have two bags here that are the same and you join the paths. So here this is all of these bags are really identical. It makes it a bit easier to separate this out in in practice to implement the algorithm a bit more efficiently then you don't have as many cases for how these sets overlap.

10:11 So you start in a bottom-up traversal along the tree decomposition for computing your your uh weight of the independent set. Of course, the empty sets gets gets weight zero. Um if the next node introduces a vertex that wasn't in the child, then you have two options for your set. You can either include this or not include this. That's shown in this table here. And the weight is the maximal weight of an independent set you can get with that choice in that vertex fixed and the subtree solved optimally accordingly.

10:47 And what is that choice if you add another vertex um for your your given set S, it's uh you either add that vertex or you don't. So you can uh in the recursive child you can either leave that vertex out. Um so it's forbidden and use it here. Or um you keep it in the child and don't you don't add the vertex and you keep the weight from the child. So here um the child has no vertices. So all we can do is the best choice we have is add the vertex, but we have to keep both of these options for now. If we add another vertex in the next backup, now we have four options of what to do with these two vertices. We can include both or either or none. And from the children again um that gives us uh only that uh including the one has value three. Uh but note that including both is actually not a not an option here because they're adjacent in the graph.

12:00 So we can't use them as an independent set. Uh okay, one more step um before something interesting happens. So the five is five is the same. We add a more vertex. This this just grows.

12:18 Now we remove a vertex. In this case, from the child, we just keep the best option for this vertex that we removed. Therefore, we can either use or not use. And so in each case, if I'm using the five, not using the one, say as one option, then I can pick the best of the two options of using or not using the four. In this case, using four and five is not valid. It's not an independent set, so here you would use just the five. The other case, you use the zero and not the five um is yeah, it's the same. Whereas if I don't use either, then I might use the four and get at least value two out of it. Okay.

13:09 The only other interesting case is when two leaves join. At this point, um you have these these two children and you go through all the options. If you say in the if you decide you want to pick the two and not the zero and the three um you can combine from the children what you get for that.

13:41 So I'm I'm fixing the same vertices. I'm fixing the two in both of the children but I have to subtract that I'm adding the same same contribution here twice.

14:03 And the weight of vertex two is four. So a double count the four, so the six comes from the four and what's the other vertex? The vertex two and four. So vertex two has weight two, vertex two has weight four. Not a good example. So here with the six plus six I'm double counting the vertex four so I have to subtract the vertex two of weight four so I'm subtracting the four again to get weight eight. All right.

14:50 Okay, we're we're almost done with the the tree decomposition part. Maybe let me first point it. Uh we've talked about where tree decompositions come from. The easiest is to go via elimination orders if you manually construct them anyways. Uh it turns out the exact problem is NP-hard so finding the exact tree width of a graph is unfortunately not not easily doable. Um there's an FPT algorithm to decide if a graph has at most tree width K and you can also find a decomposition.

15:28 but it it gets more and more expensive in K. Uh maybe the practically most useful result is that you can do an approximation so you can if a graph has tree width tree width K you'll find a a decomposition of uh uh at most two times K width and you find that in in kind of FPT time but a bit more reasonable than this K cubed in the exponent which is a bit scary. Um yeah for practical purposes the heuristics often work work reasonably well and maybe this is already too slow but you're you're paying something of this order two to the something in K for the dynamic programming so you're not completely getting away from that. Okay.

16:18 So from just the algorithm I've shown you even the abstract one, uh you find that you can solve weighted independent sets in uh parameterized in the tree width in FPT time, namely this just from the algorithm we've seen, the dynamic programming filling tables.

16:36 Um which also implies say for planar graphs you can solve independent set in this two to the square root n time, whether or not that's good is of course a different question. Okay.

16:56 Uh one last um yeah the same um because this dynamic program or this this part I didn't stress anymore. The dynamic programming idea if you think about what we've used in a separators all over again and that the optimal solutions or the constraints for these problems um all have the same property if you take this part of the solution on the separator as fixed, then the rest of the graph can be solved independently.

17:24 Um for some problems more obvious than for others. I think all all of the local constraint problems, this is easy to see. Hamiltonianity um that needs an argument. Um so you can you can generalize this dynamic programming to to many other problems. Uh of course you only need to know the ones that I have showed you. And one last outlook is um if you see all these kind of problems solved in roughly the same way, maybe there's a unifying way to do it. And that's what people uh termed algorithmic meta theorems. It turns out you can describe uh many of these graph properties that we're trying to check for here as a certain logic formula. And again this uh I wanted to write not in the exam.

18:21 And this is just for for a context. Um if it feels to you like this should be unified in some way, if several problems can be solved in the same way, that's indeed the case. And there's uh this is where logic is is strong. You can formulate a specific logic where you can quantify over over sets of vertices and and vertices. And then many properties can be expressed in this language of of logic. And you can show once and for all that you can decide whether a graph satisfies such a formula in in FPT time in the parameter tree width. And that was um that's this uh result, this first result. You can generalize then on the type of graphs that you can solve this for. So there's two other more more modern uh stronger versions of of width parameters. So they're smaller on the same graphs. Uh tree width is is kind of the weakest version and then you can climb up the ladder there for slightly uh weaker forms of logic, but more graphs you can get the same result.

19:30 Again um for for context uh to show that this um has been a fruitful area. The FPT time here is as bad as it can get. It usually is in the length of the formula extremely expensive. But this is maybe besides the point for many graph properties. These formulas aren't so big, so maybe this is uh is not so much of a worry, but it's an example of where FPT time gets a bit shaky because it's not just an exponential or so. It's really really bad. Okay.

20:11 Summary of the whole unit. We've seen linear programs for a long part and the that culminated in this um kernel for vertex cover, a much smaller kernel than we've seen before. And there you see in the tutorials or have already done in the tutorials um you can now turn such a kernel into an a sub exponential algorithm for vertex cover. And as an example of what other parameters make sense or what other parameters do people look at, we've seen tree width with uh a bit of a a sweepingly wide tour of results. Um the key one that you should keep in mind is tree width as a concept, the definition of tree decompositions and then the dynamic programming on it. I think these are the the jewels and the rest are blossoms around it that we only need for context.