Video 6-6: LP-Based Kernelization
CS 627 – Advanced Algorithms (Winter 2026-27) · unit page
· YouTube
2026-11-19, 26:32
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:01 In this next section, we'll look at an application of linear programs to our our favorite problem, vertex cover, and to produce a better kernel. And so, um, what this will look like is that we use an LP as a blackbox solver, uh, and from the outcome, we'll then do some, um, pre-processing if you like on the problem instance.
0:26 Okay, we most of the time looked at the decision version. And here we really mean the optimization version of vertex cover given a graph. What's the smallest vertex cover that we can find and we can formulate this as in integer linear program as we've had it on on the slides before I think. Well, maybe just in the animation. Uh so every vertex gets a variable. It's either part of the vertex cover or not. You try to minimize the overall uh number of vertices. So the sum of the variables for every edge you have a constraint that one of the endpoint needs to be in the vertex cover or maybe both is also fine. So it's an inequality and uh we should have um integral variables for the exact version.
1:11 Uh you can relax that so that you just drop this constraint to be exactly 01 to be any real number between zero and one. And here it turns out if you look at the um the LP what you do what you get for optimal solutions this lesser equal one is kind of never needed. You could also just have written x greater equal 0 xv greater equal z uh an optimal solution will never pick a larger value because you can always satisfy the constraints with uh putting any xv to at most one. Now the trick here will be the following. we'll apply an LP solver to this relaxed version of the vertex cover linear program and then um we'll get even like if even if we drop this constraint here we'll always get that the solution um of an op the optimal solution will have values only between zero and one and here we split the vertices into three classes depending on what their uh value in the optimal LP solution is we'll give special credit to the ones that end up being exactly 1/2 and the others uh we group in a different uh partition.
2:33 Uh before we um maybe think about what this means uh but I think I want to show you an example of this first. So again in in the way that you can also play with it here's um this implementation on collab that's the ILP we'll look at and it uses the same um uh this math op library that we've seen last time for just solving uh any any LP and it uses network X to represent the graph. So let me maybe first go to the example input.
3:14 uh network X is maybe not the fastest of all libraries to deal with graphs but it's convenient because you can just write things down in a human readable format for example you can say g my graph shall be object graph and I give the list of edges and the vertices here are implicitly defined it's all that occur and these are just named by this one character and there a convenient function to show the graph and then this is what it looks Okay, the dreaded life demo. Now, something is rather slow.
3:51 Not clear why, but you see the picture that hopefully would have come out as well. Never mind. Okay, so it's it's drawing this this graph. Um, then uh we also want to solve this integer this this relaxed LP. Forget about the ILP version. And this is we can do this for comparison. I want to focus on the LP again because that is the part where you can rely on a fast solver. Um same as last time you start formulating an LP by defining this model and then you add the variables and you add the constraints. Um here it turns out you want to work with the result that the LP spits out. And so a convenient idiom is to uh store the variables as as dicts as as mappings between the objects they represent in this case the vertices in the graph. So this overall thing is a you know list comprehension dictionary over the vertices in our graph and every vertex is mapped to the corresponding variable in the LP. So for each of these we add the variable with lower and upper bounds and with the name telling us which vertex it came from.
5:07 Then we also need the constraints for all the edges in the graph. And again networks or Python makes this almost uh feel like pseudo code right all the edges in the graph you add this linear constraint that the sum of the variables should be greater equal one. And here you see how it's convenient to have x as a dictionary. So you can write I want the variable corresponding to vertex X which is what I have in my graph and the variable corresponding to vertex V which I have in my graph. I want the sum of those to be greater or equal one. Then we call um okay the optimization function is missing. It's the sum of the x values and then you call your solver. Uh, one feature I didn't mention last time, Math Opt is rather makes it very easy to swap out the solver, so you can try out different ones and time them.
6:01 There's also another library that is is popular for specifying LPS, maybe with an even more intuitive syntax. It's called pulp, pullp. Uh, aha, cool. So, this doesn't work. Maybe then it'll have to be the static demo. Um, I can try again. Alp has the problem that in collab it has an issue that it doesn't install the solver automatically. It's not as convenient to use. This is more of a collab problem.
6:36 Okay. Now, well, let's let's pretend that this would work live, but you've seen the graph. Now I can call this function to solve on this specific graph and what you get back is is this dictionary of values for the vertices. Okay, a gets val gets gets.5 in the optimal solution 5.5 1.00 Huh. Isn't that curious? All the values that occur are just zero half and one precisely.
7:15 And so we can um also implement this partition function that splits the vertices according to the values just as on the slides. And this is no coincidence. You can try this with any graph you like. Um if you use a solver that uses a simplex implementation, which means the optimal solution is a vertex of the uh polyhedron. uh then for for this vertex cover LP you'll always get half integral solutions meaning precisely 0 1/2 and one are the only values in a vertex of this polytope that's something you can prove but we'll not do that um you can also sidestep solving an LP in this case if you care for an implementation but I think um here what my point is is rather it makes it very convenient to just use the LP as a blackbox and we don't need this extra knowledge to move forward. Uh but in principle you can uh do this for any graph and just find out that uh it happens to have this curious property.
8:19 Okay, Collab doesn't like me. So let's move on. Uh what shall we do with these vertices? If you think about it, uh the vertices that have a value strictly less than 1/2 is almost as good as not using those because for those clearly the other vertex will have value larger than 1/2 if they're connected to any other vertex by an edge. That edge needs to be covered. So all the neighbors of these I0 vertices need to have a high value. For the ones with precisely 1/2, looking at an edge where two end points have both 1/2, we're completely undecided. But for the others um where the value is is not 1/2, we have a a strict suggestion from the LP solution which vortex to take. So I think it's rather natural to say let's try to take all those that are larger than 1/2 and never any of these small ones and for these well we'll have to think about more again and knowing that essentially what comes out is these will in an optimal solution that's a vertex always be precisely zero and these will be precisely one that is very natural indeed this idea is is a known as the nimhaser TRA kernel for vertex cover.
9:45 Uh formally you take uh any graph and your your threshold. Uh again a kernelization needs a needs um a parameter right. Um then you look at the optimal solution of your relaxed vertex ILP and you define these vertex classes as before. Then first of all it cla the claim is that there is always a an optimal vertex cover of this graph that indeed uses uh all of the vertices with value one none of the vertices with value zero or strictly 1/2 and um furthermore we can turn the induced graph if I only look at the vertices where we've been undecided and reduce the parameter accordingly then uh this is equivalent. So I can I can uh pre-process my graph into a much potentially much smaller graph um at least if there's uh any hope to satisfy this. Uh in principle you could have a no instance uh that you can detect right away. Um but the usual case is you can look at this induced subgraph on on the one half vertices and then this reduced instance is equivalent to the original instance.
11:06 But of course it has um fewer vertices because uh well the total solution value here should be this this set star should be at most k otherwise we know it's it's impossible and then uh I can only have two * k vertices that get this value 1/2 right okay let's uh see a few more examples uh you can click through those on collab in principle but I think I cannot somehow it doesn't work anymore that's let's ignore that it was good to have this prepared you can look at various graphs and for um all of these the red is a vertex in C1 and all of these have precisely value one uh the I the green ones are zero and these whatever that color is gold. Um they have value 1/2 the undecided ones. Uh for these kind of symmetric constructed graphs you often don't lose much. So some graphs don't get smaller at all. Other graphs get completely solved. There's no kernel left. You can immediately out output whether the graph is solvable or not with a certain vertex cover size. And maybe the more typical case of I don't know some this is from these uh graph benchmarks the social network of some karate club where people where they ask people who they are friend with and there you see there's a small cluster that you need to look at more but the rest is all all kind of reduced away.
12:57 Let's prove that this is indeed um a kernel as claimed. So two things to show first of all that there is indeed um an optimal solution of this special type respecting the advice from the LP and uh that it's it's equivalent the yes no instance is decided on this kernel on the small induced subgraph.
13:18 Uh for the first part suppose we have any optimal vertex cover then we can define of course a new set of vertices where we row out all the vertices that sar might have used from the uh the zero vertices and we include all of the one vertices in case it didn't have all of them yet. And as notation, let's denote. So this original set is this oval thing, this ellipse. It may contain vertices from any of the three classes. Our new set of vertices includes all of C C0. So what we add is the vertices in this set sc bar, those that used not to be part of um our vertx cover. And we remove the vertices in SI, the ones that are in in SAR. And the claim is that this is also an optimal vertex cover.
14:19 Well, uh this this part of course is by by construction. What we have to show is that it is indeed a vertex cover and that it is minimal. To see that it's a vertex cover. Well, suppose um it was not. Then somehow one edge would have lost its cover, which means uh there was a vertex in SAR that we now removed. But we only remove vertices that are in this i class. Which means if you look at such an edge, uh the vertex that we now potentially removed has value less than 1/2, strictly less. But the constraint says we need to have one in total. So the other vertex must have weight strictly greater 1/2 and so it's definitely included in our set. Right? All the other edges because S star was a vertex cover. All the other edges are already covered. I can only destroy those where I take away a vertex. The second part um it's just as good as SAR which was optimal.
15:20 So um we take some uh vertices away and we add some vertices. So the sizes are obviously given by whatever the previous had then what we take away is subtracting. What we add we add. Obvious enough. So what we have to show is that these uh vertices here this sc bars is smaller than this si and for that we have to use um at some point we have to use that we're solving in LP. Uh so far I could have essentially used um some assignment of numbers that respects these constraints. Um I've not really used that it is an optimal solution to the LP.
16:07 So what we'll do is we'll modify the solution a tiny bit. We uh look at conceptually we take all the variables uh in our optimal solution and we make them a little bit bigger if the vertex is in our set si the ones with the small small value and we reduce the value of those vertices that are in the the set with the large value. uh for the for the others um the ones that are at one half we don't change it and we reduce it. So you you should think of I mean this is the definition of the largest value but you can think of um gradually moving uh a little bit of weight. You add a little bit of weight to these vertices and you take away a little bit of weight for the other vertices and you do this with an infinite decimal small amount so that you don't violate any constraints.
17:05 Now um strictly speaking you're just taking this um epsilon so that one of these um small uh of the large value vertices reaches 1/2 by subtracting here. Now um in this new set of variables everything's in one greater than 1/2 for these C vertices and strictly less than one for all of these in in SI. I mean they were Let's think about it. Okay, first of all, um we have to show that this x prime is also a feasible solution for the LP. Uh where could that violate feasibility? Well, we could make any of the variable negative, but that we don't do by definition. So, the only constraints that could be violated are that some edges aren't covered. So um suppose uh that happens it can only happen where we decrease a variable because the constraints are greater equal. So it must involve some vertex u in in our sc prime c bar. So say there is some edge u vw where one vertex is in our sc bar.
18:48 Well then let's look at where this other endpoint is. If the other endpoint is in the small value vertices, then that's a problem. It's it's in in the small value vertices but not in SAR. Well, then neither of the two are in in SAR because U in sorry V in SC bar means it was not in S in SAR.
19:20 That's a contradiction to Sar being a vertex cover. So that can't happen. If our other endpoint is in SI um the ones that we remove then um their value together is unchanged and because previously it was greater equal one and XAR was a valid solution. So also the new variable values are fulfilling that constraint. So they're happy.
19:52 And if the other endpoint is not in this small value set then it must have value at least 1/2 and our XV in SC bar also. So then the constraint is also satisfied.
20:23 So um why does that help us to construct this new x x prime? Well, the fact that uh xar is an optimal solution for the LP that's where we finally use this and that these are both feasible solutions means that xar must be at least as good as x prime. So the objective function here was just summing up the variables. So xar summed up must be less or equal x prime summed up. But we can rewrite what that is by just using the definition. And so we add epsilon as often as we have a vertex in si and we subtract it as often as we have vertices in sar c bar. So um to make that equality work we have to have that this is greater equal zero and hence uh because epsilon is never negative it means that this uh se bar can be at most si. So long long-winded story we've shown we can always take a vertex cover an optimal vertex cover and modify it into another vertex cover that is again optimal.
21:38 So that first part of the theorem is proven that we kind of don't lose anything by fixing the decision given by the LP hint. Uh the second part is that uh what's left if we focus on this induced subgraph on just the vertices with value 1/2 gives us an equivalent instance for vertex cover.
22:02 Um let's first look at the the case that there is no vertex cover of that size. So every vertex cover um s that we pick in in our in our graph gives us some feasible solution for the LP.
22:19 um that means the the optimal objective value is at least as good as this as this set gives us as the size of this set and uh if if that set star is however greater than k I can continue that that uh inequality and it means that every vertex cover needs at least k vertices that's the the first part proving that if uh stopping on this condition, we're not doing anything wrong. We produce a trivial no instance. Uh in the other case, so this is the case where set star is less or equal k.
23:05 Uh we want to show that these two are equivalent instances. Uh so look at an edge inside completely inside the vertices with small weight or between the ones with small weight and 1/2. So for these we would have the situation that in our optimal solution we add up to things that don't add up to one. That can't happen. So um we can't have edges uh in the original graph when we have some optimal solution where really an edges entirely between these these G vertices with small values or even between I and B. We can't have these. So every edge in the graph is either entirely inside our induced subgraph in the kernel we look at or it touches some vertex that we now pick. So it's covered.
23:59 Okay. Now with this first part we know that there is some minimal vertex cover that has our our property. It includes all of these and none of the I1's. So in particular um if if I look at uh what's left if I only focus on the vertices in my induced subg graph this must be still a vertex cover and um how many vertices does it have? Well I only leave out those in C 0. So that's that's the bound that we give here.
24:44 I think this is written the other way around, right? This was the direction. Well, for the other direction, assume that this has a a vertex cover t and of the size k minus zero. That is a bit the symbol is the wrong way around. Don't worry about it though. Um, we know all other edges in our original graph must touch uh that are not yet covered by by t itself. They must uh touch some vertex in c 0. So um if we throw these in they're all covered and of course the size is at most K. Then that proves the kernel P kernel part. Now what's left is the size that's uh the remark from before because the objective value is at most k and we only keep the vertices that have value exactly 1/2. There's at most 2k of them. And of course we can compute all of this in polomial time because we can solve LPS in polomial time. So we now have a a very tight kernel for vertex cover only linear in the the parameter.
26:04 Maybe you remember we had kernelizations for vertex cover before. This simple trick buses kernel that looks at highderee vertices and so on. Um that only got it down to k^ squ.
26:21 It turns out that this is precisely the ingredient you need in the upcoming exercise sheet to make a subexponential time algorithm for vertex cover work.
← Video 6-5: Integer Linear ProgramsVideo 6-7: Subexponential Algorithms and ETH →