1 00:00:00,090 --> 00:00:02,500 The following content is provided under a Creative 2 00:00:02,500 --> 00:00:04,019 Commons license. 3 00:00:04,019 --> 00:00:06,360 Your support will help MIT OpenCourseWare 4 00:00:06,360 --> 00:00:10,730 continue to offer high-quality educational resources for free. 5 00:00:10,730 --> 00:00:13,340 To make a donation or view additional materials 6 00:00:13,340 --> 00:00:17,217 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:17,217 --> 00:00:17,842 at ocw.mit.edu. 8 00:00:22,570 --> 00:00:23,760 PROFESSOR: Morning everyone. 9 00:00:23,760 --> 00:00:28,130 I hope you all had a great spring break. 10 00:00:28,130 --> 00:00:33,540 And during which I hope you can have more of 6.046. 11 00:00:33,540 --> 00:00:37,484 Today we're going to look at network flow and two things 12 00:00:37,484 --> 00:00:38,150 in network flow. 13 00:00:44,360 --> 00:00:49,370 The first one is Edmonds-Karp algorithm, 14 00:00:49,370 --> 00:00:55,380 and after that, we're going to look at two applications. 15 00:00:55,380 --> 00:01:04,660 In particular, they are called bipartite matching and cover. 16 00:01:09,160 --> 00:01:10,010 OK. 17 00:01:10,010 --> 00:01:16,101 So we'll start with a simpler algorithm, 18 00:01:16,101 --> 00:01:17,100 which is Ford-Fulkerson. 19 00:01:24,810 --> 00:01:28,520 Can someone remind us what Ford-Fulkerson does? 20 00:01:40,970 --> 00:01:41,966 Go ahead. 21 00:01:41,966 --> 00:01:44,456 AUDIENCE: Every time you have a augmenting path, 22 00:01:44,456 --> 00:01:46,470 it gets rid of it. 23 00:01:46,470 --> 00:01:47,860 PROFESSOR: It gets rid of it? 24 00:01:47,860 --> 00:01:49,102 Yep. 25 00:01:49,102 --> 00:01:50,310 What's your name, by the way? 26 00:01:50,310 --> 00:01:51,298 AUDIENCE: Michelle. 27 00:01:51,298 --> 00:01:52,780 PROFESSOR: Michelle. 28 00:01:52,780 --> 00:01:53,610 OK. 29 00:01:53,610 --> 00:01:56,600 So, Michelle gave a very brief description. 30 00:01:56,600 --> 00:01:58,880 But let's be a little bit more detailed. 31 00:01:58,880 --> 00:02:02,780 So we have a graph network flow G, 32 00:02:02,780 --> 00:02:06,440 and the first thing it's going to do is that given the flow, 33 00:02:06,440 --> 00:02:10,660 it will transform G from a residual graph. 34 00:02:10,660 --> 00:02:12,510 Everyone remembers that? 35 00:02:12,510 --> 00:02:22,720 Then F-F algorithm will find a path going from source 36 00:02:22,720 --> 00:02:38,060 to sink in this residual graph, and then augment this path. 37 00:02:42,430 --> 00:02:46,360 Augmenting just means increasing the flow on that path. 38 00:02:46,360 --> 00:02:49,485 By how much? 39 00:02:49,485 --> 00:02:53,850 AUDIENCE: The minimum edge on the path [INAUDIBLE]. 40 00:02:53,850 --> 00:02:56,480 PROFESSOR: Yeah, the minimum edge on the path. 41 00:02:56,480 --> 00:02:59,980 Let me just define that to be the capacity of the path, which 42 00:02:59,980 --> 00:03:03,570 is the capacity of the weakest link. 43 00:03:03,570 --> 00:03:04,200 OK. 44 00:03:04,200 --> 00:03:08,060 Then what's the last step we're missing here? 45 00:03:16,230 --> 00:03:24,610 So after augmenting, our flow changed from f to f prime. 46 00:03:24,610 --> 00:03:28,260 And then we're going to look back. 47 00:03:28,260 --> 00:03:31,970 We have f prime, then Gf prime, find a path in Gf prime, 48 00:03:31,970 --> 00:03:34,445 then continue from there. 49 00:03:37,200 --> 00:03:39,900 So this algorithm, in some sense, 50 00:03:39,900 --> 00:03:42,190 is not even a very detailed algorithm, 51 00:03:42,190 --> 00:03:47,120 because it doesn't say how to find a path in the second step. 52 00:03:49,815 --> 00:03:51,440 And that's indeed a problem, because we 53 00:03:51,440 --> 00:04:06,300 have seen a pathologically bad case where each capacity is 54 00:04:06,300 --> 00:04:11,760 a billion, and the correct way to do it is simply augmenting 55 00:04:11,760 --> 00:04:13,540 this path and then that path-- oh sorry, 56 00:04:13,540 --> 00:04:16,790 there's edge one-- then we'll be done. 57 00:04:16,790 --> 00:04:20,980 But the pathologically bad case is we keep 58 00:04:20,980 --> 00:04:24,322 going through this middle edge. 59 00:04:24,322 --> 00:04:24,822 OK. 60 00:04:24,822 --> 00:04:29,560 So Edmonds-Karp is an improvement to this algorithm. 61 00:04:32,520 --> 00:04:33,716 Let me just write it here. 62 00:04:42,700 --> 00:04:44,850 Its first step, third, and fourth steps 63 00:04:44,850 --> 00:04:46,230 are actually exactly the same. 64 00:04:46,230 --> 00:04:48,980 No change from Ford-Fulkerson. 65 00:04:48,980 --> 00:04:54,610 The only thing it does is that it finds a special path. 66 00:04:54,610 --> 00:04:58,150 Did Srini cover this in the lecture? 67 00:04:58,150 --> 00:05:02,717 What path Edmonds-Karp finds? 68 00:05:02,717 --> 00:05:03,800 I see some people nodding. 69 00:05:03,800 --> 00:05:04,060 OK. 70 00:05:04,060 --> 00:05:04,560 Go ahead. 71 00:05:04,560 --> 00:05:08,300 AUDIENCE: He ran the first search from the source 72 00:05:08,300 --> 00:05:13,150 to the sink in Gf, take the shortest path. 73 00:05:13,150 --> 00:05:13,880 PROFESSOR: OK. 74 00:05:13,880 --> 00:05:16,690 Does everyone agree with that? 75 00:05:16,690 --> 00:05:19,190 So Edmonds-Karp finds the shortest path. 76 00:05:23,180 --> 00:05:29,670 From-- I guess, can you see that part? 77 00:05:29,670 --> 00:05:30,170 No? 78 00:05:30,170 --> 00:05:31,211 Oh, I'm sorry about that. 79 00:05:50,170 --> 00:05:53,000 Find the shortest path. 80 00:05:53,000 --> 00:05:56,440 Here, shortest just means least number of hops. 81 00:05:56,440 --> 00:05:59,274 Here, in this pathologically bad example, 82 00:05:59,274 --> 00:06:00,690 Edmonds-Karp would do much better, 83 00:06:00,690 --> 00:06:05,560 because it would find this path, instead of this weird path. 84 00:06:05,560 --> 00:06:08,560 Because that path, its distance is 2, 85 00:06:08,560 --> 00:06:11,090 and the one going across the middle is 3. 86 00:06:13,960 --> 00:06:14,460 OK. 87 00:06:14,460 --> 00:06:20,120 Now we're going to prove that this algorithm runs in order 88 00:06:20,120 --> 00:06:20,885 VE squared. 89 00:06:24,580 --> 00:06:25,420 So OK. 90 00:06:25,420 --> 00:06:26,670 So one step back. 91 00:06:26,670 --> 00:06:30,150 Do we have to prove that is correct? 92 00:06:30,150 --> 00:06:34,610 That it indeed finds the maximum flow? 93 00:06:40,759 --> 00:06:42,604 AUDIENCE: No, you don't. 94 00:06:42,604 --> 00:06:43,270 PROFESSOR: Yeah. 95 00:06:43,270 --> 00:06:45,145 I claim I don't have to do that, because it's 96 00:06:45,145 --> 00:06:46,900 the same thing as Ford-Fulkerson. 97 00:06:46,900 --> 00:06:49,380 You can find any path. 98 00:06:49,380 --> 00:06:55,280 Now, we want to show-- we want to bound this run time. 99 00:06:55,280 --> 00:06:59,170 So any idea, high-level idea, how we're going to do that? 100 00:06:59,170 --> 00:07:02,430 In which several steps? 101 00:07:34,800 --> 00:07:35,300 OK. 102 00:07:35,300 --> 00:07:39,396 So, OK, a simpler question. 103 00:07:39,396 --> 00:07:43,220 What's the complexity of this second step, find the shortest 104 00:07:43,220 --> 00:07:45,190 path from source to sink? 105 00:07:48,850 --> 00:07:49,810 Go ahead. 106 00:07:49,810 --> 00:07:51,240 AUDIENCE: OV plus E. 107 00:07:51,240 --> 00:07:54,280 PROFESSOR: OV plus E. And in this case, 108 00:07:54,280 --> 00:08:02,310 actually, V is always less than E, so I can simply say O of E. 109 00:08:02,310 --> 00:08:07,210 Now, how long does it take to augment that path, 110 00:08:07,210 --> 00:08:09,332 if we have found it? 111 00:08:09,332 --> 00:08:11,160 AUDIENCE: O of E. 112 00:08:11,160 --> 00:08:13,080 PROFESSOR: O of E. That's correct. 113 00:08:17,110 --> 00:08:23,650 But our claim, we can also say it's O of V, 114 00:08:23,650 --> 00:08:33,159 because the shortest path at most has three hops. 115 00:08:33,159 --> 00:08:37,319 And then, from f to f prime-- OK. 116 00:08:37,319 --> 00:08:40,140 So I think in some sense, these two are the same steps. 117 00:08:40,140 --> 00:08:43,210 Also O of V, and then updating the rescue graph 118 00:08:43,210 --> 00:08:47,580 is also O of V. So one of these iterations-- 119 00:08:47,580 --> 00:08:52,280 each iteration takes how long? 120 00:08:52,280 --> 00:08:53,279 AUDIENCE: O of E. 121 00:08:53,279 --> 00:08:54,320 PROFESSOR: O of E. Right. 122 00:08:54,320 --> 00:08:59,110 This is the most expensive step in one iteration. 123 00:08:59,110 --> 00:08:59,610 OK. 124 00:08:59,610 --> 00:09:02,452 So what else do we have to do to prove this bound? 125 00:09:02,452 --> 00:09:05,310 AUDIENCE: Number of iterations. 126 00:09:05,310 --> 00:09:08,470 PROFESSOR: We need to show that the number of iterations 127 00:09:08,470 --> 00:09:21,420 is O of V times E. If we can show that, 128 00:09:21,420 --> 00:09:24,480 then we are pretty much done. 129 00:09:24,480 --> 00:09:24,980 OK? 130 00:09:34,900 --> 00:09:35,410 OK. 131 00:09:35,410 --> 00:09:38,000 Now, to prove that bound, we first 132 00:09:38,000 --> 00:09:44,275 need a lemma, which we call monotonic. 133 00:09:48,380 --> 00:10:02,640 So let me define delta f v. This is the length of the shortest 134 00:10:02,640 --> 00:10:07,030 path from s, from the source, to v, 135 00:10:07,030 --> 00:10:12,580 which is a node in a graph, the length of that 136 00:10:12,580 --> 00:10:15,530 in rescue graph of f. 137 00:10:20,479 --> 00:10:21,520 Is that definition clear? 138 00:10:27,600 --> 00:10:38,530 And this lemma says delta f v, for any vertex v, 139 00:10:38,530 --> 00:10:39,500 does not decrease. 140 00:10:43,780 --> 00:10:48,245 So it can only monotonically increase. 141 00:10:51,396 --> 00:10:51,896 OK. 142 00:10:51,896 --> 00:10:53,020 We are going to prove that. 143 00:11:01,630 --> 00:11:04,180 So we'll prove by contradiction. 144 00:11:04,180 --> 00:11:05,760 Assume this is not a case. 145 00:11:09,310 --> 00:11:17,040 That means there is some v that in f prime, which 146 00:11:17,040 --> 00:11:23,520 is the new residual graph, its shortest 147 00:11:23,520 --> 00:11:26,450 path from the source in the new residual graph 148 00:11:26,450 --> 00:11:30,570 is less than the old one. 149 00:11:30,570 --> 00:11:31,070 Right? 150 00:11:36,910 --> 00:11:39,236 We are going to derive a contradiction to that. 151 00:11:48,590 --> 00:11:53,220 So there may be many such vertices that drop. 152 00:11:53,220 --> 00:12:00,830 But if there's any, I'm going to define v 153 00:12:00,830 --> 00:12:15,390 to be the one with smallest delta in f prime. 154 00:12:22,030 --> 00:12:22,560 OK. 155 00:12:22,560 --> 00:12:23,815 Any questions about this step? 156 00:12:30,750 --> 00:12:35,630 So there could be like v1, v2, v3-- that all make this happen. 157 00:12:35,630 --> 00:12:38,740 I'm going to choose the one among those 158 00:12:38,740 --> 00:12:42,260 that has the smallest distance from the source. 159 00:12:48,040 --> 00:12:48,540 OK? 160 00:12:51,865 --> 00:12:54,950 Now here is my source. 161 00:12:54,950 --> 00:13:03,475 We have a path to v in graph Gf prime. 162 00:13:07,600 --> 00:13:08,100 OK. 163 00:13:08,100 --> 00:13:09,070 So this is a path. 164 00:13:09,070 --> 00:13:13,150 Then I can always find a predecessor, 165 00:13:13,150 --> 00:13:14,155 which I'll call u here. 166 00:13:21,460 --> 00:13:23,960 If this is the shortest path to v, 167 00:13:23,960 --> 00:13:34,630 what can I say about delta of v and delta of u? 168 00:13:38,071 --> 00:13:39,820 What can I say about these two quantities? 169 00:13:47,925 --> 00:13:50,895 AUDIENCE: Can v decrease? 170 00:13:50,895 --> 00:13:54,152 Can v decrease one of them, at least? 171 00:13:54,152 --> 00:13:55,860 PROFESSOR: This one is greater than that? 172 00:13:55,860 --> 00:13:58,859 AUDIENCE: One of them must be-- 173 00:13:58,859 --> 00:14:00,900 PROFESSOR: One of them is greater than the other, 174 00:14:00,900 --> 00:14:01,890 and that's always true, right? 175 00:14:01,890 --> 00:14:02,390 For any two? 176 00:14:06,260 --> 00:14:08,967 AUDIENCE: v is u plus 1. 177 00:14:08,967 --> 00:14:09,550 PROFESSOR: OK. 178 00:14:09,550 --> 00:14:11,910 Michelle said v is u plus 1. 179 00:14:11,910 --> 00:14:13,285 Does that make sense to everyone? 180 00:14:21,800 --> 00:14:25,265 That's the shortest path to v. It goes through u. 181 00:14:30,110 --> 00:14:30,610 OK. 182 00:14:30,610 --> 00:14:31,235 That's correct. 183 00:14:36,220 --> 00:14:39,270 So OK, maybe I wasn't clear about that. 184 00:14:39,270 --> 00:14:44,120 I defined u to be v's predecessor on the shortest 185 00:14:44,120 --> 00:14:46,338 path. 186 00:14:46,338 --> 00:14:47,790 OK? 187 00:14:47,790 --> 00:14:56,180 Then definitely delta f prime of v is delta f prime u plus 1. 188 00:14:56,180 --> 00:14:59,500 Now, I'll use u to be my step stone 189 00:14:59,500 --> 00:15:02,890 back to the original graph, f. 190 00:15:02,890 --> 00:15:08,080 I want to say something about this quantity and delta 191 00:15:08,080 --> 00:15:10,357 u in graph f. 192 00:15:10,357 --> 00:15:11,440 What can I say about that? 193 00:15:34,340 --> 00:15:35,565 This is a tricky part. 194 00:15:35,565 --> 00:15:39,160 AUDIENCE: It's greater than v? 195 00:15:39,160 --> 00:15:41,740 PROFESSOR: This one is greater than that? 196 00:15:41,740 --> 00:15:43,564 Or the entire thing is greater than that? 197 00:15:47,500 --> 00:15:48,000 OK. 198 00:15:48,000 --> 00:15:55,270 I'm going to claim this one is greater than delta f u plus 1. 199 00:15:55,270 --> 00:16:01,030 By which I'm claiming this quantity is larger than that. 200 00:16:01,030 --> 00:16:05,350 Can anyone give a reason why I can claim that? 201 00:16:10,650 --> 00:16:21,824 So recall how I defined v. 202 00:16:21,824 --> 00:16:24,449 AUDIENCE: Can you repeat how you defined v? 203 00:16:24,449 --> 00:16:25,490 PROFESSOR: Good question. 204 00:16:25,490 --> 00:16:30,580 So v-- so there are several, probably several v's that 205 00:16:30,580 --> 00:16:34,360 have delta f prime less than delta f. 206 00:16:34,360 --> 00:16:43,160 I'm going to define v to be the one with smallest delta f. 207 00:16:43,160 --> 00:16:47,110 Among all those nodes that have a job in delta f, in delta. 208 00:16:51,990 --> 00:16:54,110 This is probably a tricky part. 209 00:16:54,110 --> 00:17:00,560 Then by definition, since delta f u is less than delta f v, 210 00:17:00,560 --> 00:17:07,210 right, and I defined v to be the one with the smallest 211 00:17:07,210 --> 00:17:09,490 delta that satisfies that. 212 00:17:09,490 --> 00:17:12,869 So all the u's-- so u is a predecessor of v, 213 00:17:12,869 --> 00:17:19,114 so u shouldn't be one of those nodes that have a drop 214 00:17:19,114 --> 00:17:21,175 in delta. 215 00:17:21,175 --> 00:17:24,722 So I know this is probably a tricky part. 216 00:17:24,722 --> 00:17:27,720 Yeah, I'll stop for questions and make 217 00:17:27,720 --> 00:17:30,430 sure we resolve this part before we move on. 218 00:17:35,480 --> 00:17:38,770 How many people get it? 219 00:17:38,770 --> 00:17:39,270 OK. 220 00:17:39,270 --> 00:17:39,794 Only two. 221 00:17:39,794 --> 00:17:40,460 That's not good. 222 00:17:40,460 --> 00:17:40,960 OK. 223 00:17:40,960 --> 00:17:42,815 AUDIENCE: I'm confused about how v 224 00:17:42,815 --> 00:17:46,115 can be the one with the smallest delta f 225 00:17:46,115 --> 00:17:50,075 if you have a predecessor with a smaller delta f. 226 00:17:53,527 --> 00:17:54,110 PROFESSOR: OK. 227 00:17:54,110 --> 00:18:00,520 So v to be the smallest-- the one with smallest 228 00:18:00,520 --> 00:18:08,595 f such that delta f prime is less than delta f. 229 00:18:08,595 --> 00:18:09,470 AUDIENCE: OK. 230 00:18:09,470 --> 00:18:13,180 PROFESSOR: OK, maybe, yeah, that's why I confused you guys. 231 00:18:13,180 --> 00:18:13,680 Yeah. 232 00:18:13,680 --> 00:18:15,550 Sorry about that. 233 00:18:15,550 --> 00:18:19,080 So we have a bunch of nodes who have a drop in delta, 234 00:18:19,080 --> 00:18:22,900 and I defined v to be the one among them that 235 00:18:22,900 --> 00:18:24,500 has the smallest delta f prime. 236 00:18:27,000 --> 00:18:27,500 Question? 237 00:18:27,500 --> 00:18:29,125 AUDIENCE: Sorry, I'm lost at what delta 238 00:18:29,125 --> 00:18:31,877 f prime is versus delta. 239 00:18:31,877 --> 00:18:32,460 PROFESSOR: OK. 240 00:18:32,460 --> 00:18:37,230 Delta f of a node is the shortest path 241 00:18:37,230 --> 00:18:41,440 from source to that node in G of f, 242 00:18:41,440 --> 00:18:44,650 which is the residual graph given a flow. 243 00:18:44,650 --> 00:18:49,140 So f is, well, some flow, and f prime 244 00:18:49,140 --> 00:18:53,870 is the flow after we augmenting a certain path. 245 00:18:53,870 --> 00:18:57,901 So f prime is one step after f. 246 00:18:57,901 --> 00:18:58,400 OK. 247 00:18:58,400 --> 00:19:01,780 How many people get that now? 248 00:19:01,780 --> 00:19:02,910 Still not everyone. 249 00:19:08,110 --> 00:19:08,610 OK. 250 00:19:08,610 --> 00:19:09,660 Any questions about that? 251 00:19:13,300 --> 00:19:16,200 How many people still haven't got that? 252 00:19:19,200 --> 00:19:23,270 OK, so some people-- it's like Schrodinger's cat. 253 00:19:23,270 --> 00:19:24,680 It's in the middle state. 254 00:19:34,920 --> 00:19:37,540 Well, then I'll have to move on, and I'll 255 00:19:37,540 --> 00:19:40,170 assume you all get that one. 256 00:19:44,570 --> 00:19:48,610 As the last step, so of course we will ask, 257 00:19:48,610 --> 00:19:53,530 what's the relation between this guy and delta f of v? 258 00:19:56,100 --> 00:19:59,280 Because in the end, we want to show a contradiction 259 00:19:59,280 --> 00:20:02,180 that delta f v is probably greater or equal 260 00:20:02,180 --> 00:20:07,524 to delta f of v. OK. 261 00:20:07,524 --> 00:20:08,690 This is another tricky part. 262 00:20:13,195 --> 00:20:16,580 So let me ask maybe a simpler question now. 263 00:20:16,580 --> 00:20:19,840 So that is our G of f prime. 264 00:20:19,840 --> 00:20:21,500 So we also have G of f. 265 00:20:21,500 --> 00:20:28,265 It has the source, some u here, v there, sink there. 266 00:20:31,630 --> 00:20:35,940 Does this edge exist in this graph? 267 00:20:38,470 --> 00:20:41,530 So I know if that edge exists, because I defined u 268 00:20:41,530 --> 00:20:45,555 to be the predecessor of v. But u, 269 00:20:45,555 --> 00:20:48,315 v is in that graph doesn't necessarily mean u, 270 00:20:48,315 --> 00:20:49,810 v is in the old graph. 271 00:20:53,410 --> 00:20:55,940 It could certainly exist, but is it possible 272 00:20:55,940 --> 00:20:59,550 that this edge didn't exist? 273 00:21:02,080 --> 00:21:07,410 How many people would say that edge definitely exists? 274 00:21:10,050 --> 00:21:13,045 How many people would say maybe it doesn't exist? 275 00:21:23,320 --> 00:21:23,830 OK. 276 00:21:23,830 --> 00:21:26,910 It doesn't matter, because we can prove both cases. 277 00:21:26,910 --> 00:21:35,480 So let's say case one, u, v is indeed 278 00:21:35,480 --> 00:21:38,402 in the original graph, G of f. 279 00:21:38,402 --> 00:21:38,901 OK. 280 00:21:38,901 --> 00:21:41,620 In that case, can I say something about that last step? 281 00:21:58,945 --> 00:22:03,430 AUDIENCE: It's greater or equal to delta f v. 282 00:22:03,430 --> 00:22:09,590 PROFESSOR: Greater or equal to delta v. OK. 283 00:22:09,590 --> 00:22:10,940 Why is that? 284 00:22:10,940 --> 00:22:17,417 AUDIENCE: Because v was on the shortest path. 285 00:22:17,417 --> 00:22:19,349 Well-- yeah. 286 00:22:19,349 --> 00:22:25,708 So the shortest path, either passed through-- yeah. 287 00:22:25,708 --> 00:22:28,850 The shortest path to v either passed through u or didn't. 288 00:22:28,850 --> 00:22:30,310 PROFESSOR: Correct. 289 00:22:30,310 --> 00:22:31,370 Does everyone get that? 290 00:22:31,370 --> 00:22:34,490 So the shortest path in this graph to v 291 00:22:34,490 --> 00:22:37,890 is not necessarily this one, right? 292 00:22:37,890 --> 00:22:41,430 But if it's some other one-- OK, so, in case one 293 00:22:41,430 --> 00:22:45,449 I'm assuming this edge exists, right? 294 00:22:45,449 --> 00:22:46,990 Then no matter what the shortest path 295 00:22:46,990 --> 00:22:51,430 is, it's definitely shorter than I first go to-- from s to u 296 00:22:51,430 --> 00:22:54,650 and then u to v. Right? 297 00:22:54,650 --> 00:22:58,580 The shortest path between s to v is definitely shorter 298 00:22:58,580 --> 00:23:06,180 than I first go from s to u and then u to v. Make sense? 299 00:23:06,180 --> 00:23:06,680 OK. 300 00:23:06,680 --> 00:23:12,310 So case one, then, is a contradiction, 301 00:23:12,310 --> 00:23:14,680 because we showed that delta f prime of v 302 00:23:14,680 --> 00:23:22,410 is greater or equal to delta f of v. Any questions about that? 303 00:23:27,180 --> 00:23:27,680 OK. 304 00:23:27,680 --> 00:23:37,230 Case two, u, v is not in Gf. 305 00:23:37,230 --> 00:23:41,070 OK, so, how can that even happen? 306 00:23:41,070 --> 00:23:48,760 Is it possible that this edge didn't exist? 307 00:23:55,662 --> 00:23:59,113 AUDIENCE: It could be a backwards-facing edge 308 00:23:59,113 --> 00:24:04,102 that you add [INAUDIBLE]. 309 00:24:04,102 --> 00:24:05,060 PROFESSOR: Great point. 310 00:24:05,060 --> 00:24:06,620 That's exactly right. 311 00:24:06,620 --> 00:24:12,470 So it is possible that this edge didn't exist, but only appeared 312 00:24:12,470 --> 00:24:15,360 after we go from f to f prime. 313 00:24:15,360 --> 00:24:16,870 How can that happen? 314 00:24:16,870 --> 00:24:21,240 That must mean we are augmenting a path that 315 00:24:21,240 --> 00:24:22,621 goes right through it. 316 00:24:22,621 --> 00:24:23,120 Right? 317 00:24:23,120 --> 00:24:26,080 But this edge doesn't exist, so we cannot be augmenting a path 318 00:24:26,080 --> 00:24:28,210 that crosses this way. 319 00:24:28,210 --> 00:24:35,990 We must be augmenting a path that goes like that. 320 00:24:35,990 --> 00:24:43,910 First from s to v, and then v to u, and then u to t. 321 00:24:43,910 --> 00:24:47,270 If we are augmenting such a path, 322 00:24:47,270 --> 00:24:52,460 then we're going to remove this edge from v to u, 323 00:24:52,460 --> 00:24:57,420 but we will add u to v to the next graph. 324 00:25:01,810 --> 00:25:02,310 OK? 325 00:25:08,563 --> 00:25:09,880 Did everyone get that? 326 00:25:22,510 --> 00:25:25,570 So now, here-- well, formally I'm 327 00:25:25,570 --> 00:25:29,540 going to claim if we assume u, v is not in G of f, 328 00:25:29,540 --> 00:25:35,640 and we also know u, v is in Gf prime. 329 00:25:35,640 --> 00:25:37,260 What does that mean? 330 00:25:37,260 --> 00:25:43,280 These two can only be caused by the fact 331 00:25:43,280 --> 00:25:49,500 that u, v is in G of f. 332 00:25:49,500 --> 00:25:56,060 Not only in that graph-- it must be on the path 333 00:25:56,060 --> 00:25:56,870 we are augmenting. 334 00:26:05,520 --> 00:26:06,020 Make sense? 335 00:26:16,700 --> 00:26:17,200 OK. 336 00:26:17,200 --> 00:26:22,130 So given that, can we say something about delta f 337 00:26:22,130 --> 00:26:24,040 of u and delta f of v? 338 00:26:33,520 --> 00:26:36,375 So here is our p. 339 00:26:36,375 --> 00:26:38,690 Right? 340 00:26:38,690 --> 00:26:39,660 This entire thing here. 341 00:26:48,180 --> 00:26:53,112 And p is the augmenting path. 342 00:26:53,112 --> 00:26:56,521 AUDIENCE: And f u is just f v plus 1. 343 00:26:56,521 --> 00:26:57,312 PROFESSOR: Correct. 344 00:26:57,312 --> 00:26:57,812 Right. 345 00:26:57,812 --> 00:27:02,300 So if that is the augmenting path in Edmonds-Karp, 346 00:27:02,300 --> 00:27:04,030 we are looking for the shortest path. 347 00:27:04,030 --> 00:27:05,640 Right? 348 00:27:05,640 --> 00:27:12,240 So v is the predecessor of u, then delta of u 349 00:27:12,240 --> 00:27:14,370 is delta of v plus 1. 350 00:27:14,370 --> 00:27:26,680 That means that quantity, here, is delta f of v plus 2. 351 00:27:31,110 --> 00:27:31,610 OK? 352 00:27:44,440 --> 00:27:49,320 So it's also a contradiction to what we assumed. 353 00:28:02,360 --> 00:28:02,860 OK. 354 00:28:02,860 --> 00:28:07,100 So that proves our lemma of every node's 355 00:28:07,100 --> 00:28:10,156 delta monotonically increases. 356 00:28:10,156 --> 00:28:15,740 Now here, I'm going to show that-- our final theorem, 357 00:28:15,740 --> 00:28:20,365 that we have at most VE number of iterations. 358 00:28:27,290 --> 00:28:35,595 So the way we're going to show that is we 359 00:28:35,595 --> 00:28:40,530 are going to define a capacity of the path. 360 00:28:40,530 --> 00:28:42,790 It must be the capacity of its weakest link. 361 00:28:42,790 --> 00:28:48,780 We're going to define its weakest link is u, v. OK? 362 00:28:48,780 --> 00:28:52,810 And we're going to show that u, v-- 363 00:28:52,810 --> 00:28:58,265 we'll call that critical edge-- we're going to show u, 364 00:28:58,265 --> 00:29:08,840 v can be critical only O of V times. 365 00:29:08,840 --> 00:29:11,710 If that holds for every edge, then I 366 00:29:11,710 --> 00:29:15,320 claim all the edges combined can only 367 00:29:15,320 --> 00:29:17,790 be augmented O of VE times. 368 00:29:28,580 --> 00:29:33,270 Now, how do we show that? 369 00:29:33,270 --> 00:29:39,975 So again, let's assume we are augmenting 370 00:29:39,975 --> 00:29:46,890 a path that goes through u to v. If we 371 00:29:46,890 --> 00:29:52,490 do that, by our algorithm, we will get rid of this path, 372 00:29:52,490 --> 00:29:57,570 and have an edge backwards. 373 00:29:57,570 --> 00:30:01,140 We go from f to some other f prime. 374 00:30:03,730 --> 00:30:07,140 Now, when can I augment u, v again? 375 00:30:10,490 --> 00:30:13,910 It can only happen if at some point, 376 00:30:13,910 --> 00:30:19,690 I come back to augment the path going from v to u, because that 377 00:30:19,690 --> 00:30:29,930 will eliminate this back edge, and and adds back 378 00:30:29,930 --> 00:30:34,710 our edge u, v. OK. 379 00:30:34,710 --> 00:30:36,815 Let's see what happens there. 380 00:30:40,840 --> 00:30:44,915 Now I'll call this graph f, this graph f prime. 381 00:30:50,100 --> 00:30:54,130 So in f prime, we know we are augmenting the path from v 382 00:30:54,130 --> 00:30:54,821 to u. 383 00:30:54,821 --> 00:30:55,320 Right. 384 00:30:55,320 --> 00:31:02,800 The same argument, delta u, is delta v plus 1 in f prime. 385 00:31:02,800 --> 00:31:03,300 Correct? 386 00:31:05,910 --> 00:31:08,980 And we know this one doesn't drop, right? 387 00:31:08,980 --> 00:31:16,050 So it's greater or equal than delta f of v plus 1. 388 00:31:16,050 --> 00:31:18,110 OK? 389 00:31:18,110 --> 00:31:22,210 And we also know in f, v is the predecessor of u. 390 00:31:24,820 --> 00:31:34,080 So this one is equal to delta f of u plus 2. 391 00:31:34,080 --> 00:31:35,100 What does that mean? 392 00:31:35,100 --> 00:31:45,550 It means in between two times u, v is augmented, delta of u 393 00:31:45,550 --> 00:31:47,200 must increase by at least 2. 394 00:31:53,210 --> 00:31:58,210 Then how large can delta of a certain node possibly be? 395 00:31:58,210 --> 00:32:02,240 It's definitely bounded by v. So then I 396 00:32:02,240 --> 00:32:06,080 claim this particular edge, u, v, can only be involved, 397 00:32:06,080 --> 00:32:10,030 can only be critical edge, O of V times. 398 00:32:10,030 --> 00:32:12,320 Actually, half of V times. 399 00:32:12,320 --> 00:32:13,860 Strictly. 400 00:32:13,860 --> 00:32:16,610 So then, every edge combined, there 401 00:32:16,610 --> 00:32:22,445 can only be half of V times E number of augmentations. 402 00:32:30,660 --> 00:32:31,160 OK. 403 00:32:31,160 --> 00:32:32,420 Any questions about that part? 404 00:32:32,420 --> 00:32:33,500 About the entire proof? 405 00:33:11,044 --> 00:33:11,960 If not, we'll move on. 406 00:33:19,490 --> 00:33:19,990 OK. 407 00:33:19,990 --> 00:33:22,780 This is not part of the required in the recitation, 408 00:33:22,780 --> 00:33:27,040 but I'll quickly say a few words about an even better algorithm, 409 00:33:27,040 --> 00:33:34,290 Dinic, which was in O of V squared times E. 410 00:33:34,290 --> 00:33:37,190 So this is an improvement to Edmonds-Karp, 411 00:33:37,190 --> 00:33:46,260 and its idea is that I'm going to find all the shortest 412 00:33:46,260 --> 00:33:50,050 paths in one go from s to t. 413 00:33:53,310 --> 00:33:57,320 I'm going to augment all of them at the same time. 414 00:34:00,150 --> 00:34:03,900 Then, because they are all shortest paths, when I augment 415 00:34:03,900 --> 00:34:06,580 that, each path will be broken. 416 00:34:06,580 --> 00:34:10,050 Maybe I'll get rid of this edge, this edge, and that edge. 417 00:34:10,050 --> 00:34:15,540 And the thesis is that the shortest path will increase. 418 00:34:15,540 --> 00:34:17,650 So here, the shortest path is 3, but I 419 00:34:17,650 --> 00:34:20,230 have destroyed all the shortest path of length 3, 420 00:34:20,230 --> 00:34:23,650 so I'm going to shortest path of 4. 421 00:34:23,650 --> 00:34:26,469 If they do that, you can bound the number of iterations 422 00:34:26,469 --> 00:34:30,409 to O of V, because your shortest path can be, 423 00:34:30,409 --> 00:34:35,179 at most, V. But each iteration is slightly more complicated, 424 00:34:35,179 --> 00:34:37,515 because you need to find all the shortest paths, 425 00:34:37,515 --> 00:34:39,344 and it happens that they can show-- you 426 00:34:39,344 --> 00:34:42,830 can find it in V times E. That gives the V square of E. 427 00:34:42,830 --> 00:34:44,757 That's not the important part. 428 00:34:44,757 --> 00:34:46,590 The more interesting part is that, actually, 429 00:34:46,590 --> 00:34:53,658 the author of this algorithm, his name is Dinitz. 430 00:34:53,658 --> 00:34:58,006 But his algorithm is very hard to understand. 431 00:34:58,006 --> 00:34:59,610 Yeah, nobody got that. 432 00:34:59,610 --> 00:35:05,000 And there's some other guy whose name I think is Even. 433 00:35:05,000 --> 00:35:08,290 He understood the problem and started advertising to people 434 00:35:08,290 --> 00:35:12,290 and giving lectures on Dinitz's algorithm. 435 00:35:12,290 --> 00:35:15,600 So he popularized the algorithm, but unfortunately he 436 00:35:15,600 --> 00:35:17,900 got the name of the author wrong. 437 00:35:17,900 --> 00:35:19,900 So that's why this algorithm is henceforth 438 00:35:19,900 --> 00:35:22,660 called Dinic's algorithm. 439 00:35:22,660 --> 00:35:24,330 This is useful to know. 440 00:35:24,330 --> 00:35:25,370 Why? 441 00:35:25,370 --> 00:35:28,180 Because you can tell this story to other people so they will 442 00:35:28,180 --> 00:35:30,520 assume that you know a lot about Dinic's algorithm, 443 00:35:30,520 --> 00:35:32,396 while in fact, you probably don't. 444 00:35:32,396 --> 00:35:34,020 And that's exactly what I'm doing here. 445 00:35:37,611 --> 00:35:38,110 OK. 446 00:35:42,374 --> 00:35:43,790 Now let's look at one application. 447 00:35:50,690 --> 00:35:53,574 Bipartite matching. 448 00:35:58,141 --> 00:35:58,640 OK. 449 00:35:58,640 --> 00:36:04,740 So the problem is that we have several person 450 00:36:04,740 --> 00:36:07,300 and several tasks. 451 00:36:07,300 --> 00:36:08,675 And let me get rid of one person, 452 00:36:08,675 --> 00:36:11,440 because I don't want to draw that many stuff. 453 00:36:11,440 --> 00:36:15,350 So we have a graph like that. 454 00:36:15,350 --> 00:36:19,210 And each edge-- if there is an edge, that 455 00:36:19,210 --> 00:36:22,680 means this person is capable of performing that task. 456 00:36:26,030 --> 00:36:29,310 And the problem is that-- find the matching, which 457 00:36:29,310 --> 00:36:33,660 means the assignment from people to tasks, 458 00:36:33,660 --> 00:36:37,830 such that we get as many tasks done as possible. 459 00:36:37,830 --> 00:36:38,330 OK? 460 00:36:38,330 --> 00:36:40,130 So one person can only do one task, 461 00:36:40,130 --> 00:36:42,720 and one task only needs one person. 462 00:36:42,720 --> 00:36:45,310 So here you can see a bad matching, which 463 00:36:45,310 --> 00:36:50,100 is I assign this first guy to task one, 464 00:36:50,100 --> 00:36:54,260 then no one can do task two. 465 00:36:54,260 --> 00:36:58,210 So if I'm smarter, I'll assign one of these guys to that task 466 00:36:58,210 --> 00:37:01,790 and have this person handle the other task. 467 00:37:01,790 --> 00:37:02,715 Is the problem clear? 468 00:37:06,040 --> 00:37:10,610 So this is called bipartite graph, because-- well, 469 00:37:10,610 --> 00:37:13,540 which means you can partition a graph into two parts, 470 00:37:13,540 --> 00:37:16,340 and within each part, there's no edge connecting 471 00:37:16,340 --> 00:37:18,470 any pair of vertices. 472 00:37:18,470 --> 00:37:22,690 And you can also define this problem for a general graph. 473 00:37:27,650 --> 00:37:29,300 The goal is the same. 474 00:37:29,300 --> 00:37:38,870 Find a subset of edges such that no two edges are 475 00:37:38,870 --> 00:37:44,180 connected to the same vertex. 476 00:37:44,180 --> 00:37:49,340 But we are going to look at bipartite graph. 477 00:37:49,340 --> 00:37:52,160 And we claim in bipartite graph, this 478 00:37:52,160 --> 00:37:53,975 can be solved using max flow. 479 00:37:57,791 --> 00:37:58,290 OK. 480 00:37:58,290 --> 00:38:01,240 I'll give you one minute to think about that, how 481 00:38:01,240 --> 00:38:04,635 to transform that problem to a max flow problem. 482 00:39:01,210 --> 00:39:01,810 Any ideas? 483 00:39:51,911 --> 00:39:52,410 OK. 484 00:39:52,410 --> 00:39:53,770 A hint. 485 00:39:53,770 --> 00:39:59,384 I will add the source here, and the sink there, 486 00:39:59,384 --> 00:40:00,800 and I'll have created these edges. 487 00:40:05,570 --> 00:40:06,070 OK. 488 00:40:06,070 --> 00:40:08,830 How do I restrict the capacity of all the edges 489 00:40:08,830 --> 00:40:17,120 such that I can guarantee no person is taking two tasks, 490 00:40:17,120 --> 00:40:18,960 and no task is assigned to two people? 491 00:40:26,880 --> 00:40:29,360 AUDIENCE: Make all of them weight 1. 492 00:40:29,360 --> 00:40:31,959 PROFESSOR: Make all of them weight 1. 493 00:40:31,959 --> 00:40:32,458 OK. 494 00:40:32,458 --> 00:40:32,999 You're right. 495 00:40:32,999 --> 00:40:36,920 We do that-- 1, 1, 1, 1, 1, and everything here 496 00:40:36,920 --> 00:40:40,910 is weight 1, then that's definitely correct. 497 00:40:40,910 --> 00:40:41,922 What's your name? 498 00:40:41,922 --> 00:40:42,630 AUDIENCE: Calvin. 499 00:40:42,630 --> 00:40:43,640 PROFESSOR: Calvin? 500 00:40:43,640 --> 00:40:46,200 OK. 501 00:40:46,200 --> 00:40:49,810 If we do that, then, well, because each person only 502 00:40:49,810 --> 00:40:54,080 has one incoming edge-- oh, sorry, maybe I 503 00:40:54,080 --> 00:40:56,294 should have drawn the arrows here. 504 00:40:59,230 --> 00:41:00,920 Each person only has one incoming edge, 505 00:41:00,920 --> 00:41:05,290 so it cannot take care of two tasks at the same time. 506 00:41:05,290 --> 00:41:06,050 Right? 507 00:41:06,050 --> 00:41:08,890 Same thing for each task. 508 00:41:08,890 --> 00:41:12,520 It only has one outgoing edge, so it cannot be taken care 509 00:41:12,520 --> 00:41:13,774 of by multiple people. 510 00:41:18,345 --> 00:41:18,845 OK. 511 00:41:18,845 --> 00:41:21,990 So if we find-- if the max flow is 512 00:41:21,990 --> 00:41:34,740 k, that means we can find the max matching is also k. 513 00:41:34,740 --> 00:41:38,390 We can get k tasks done. 514 00:41:38,390 --> 00:41:42,990 It's very easy to see because we can have a cut here, 515 00:41:42,990 --> 00:41:47,580 and if the max flow is k, that clearly k tasks 516 00:41:47,580 --> 00:41:48,370 are taken care of. 517 00:41:53,562 --> 00:41:54,259 OK. 518 00:41:54,259 --> 00:41:55,300 Any questions about that? 519 00:41:59,616 --> 00:42:01,240 AUDIENCE: So, the question is can we do 520 00:42:01,240 --> 00:42:04,210 all the assignment [INAUDIBLE]? 521 00:42:04,210 --> 00:42:07,390 PROFESSOR: Find an assignment from people to tasks 522 00:42:07,390 --> 00:42:09,830 to get as many tasks done as possible. 523 00:42:09,830 --> 00:42:13,550 So how many tasks can we handle? 524 00:42:17,621 --> 00:42:18,120 OK. 525 00:42:18,120 --> 00:42:23,310 So I'm doing a different topic from the recitation notes. 526 00:42:23,310 --> 00:42:29,030 In the recitation notes, we are considering another problem 527 00:42:29,030 --> 00:42:34,920 called bipartite cover, which is exactly the same thing as that. 528 00:42:38,790 --> 00:42:41,990 So cover, also, bipartite graph, is 529 00:42:41,990 --> 00:42:50,500 defined too as, let's find several vertices in this graph 530 00:42:50,500 --> 00:42:56,060 such that each node, at least-- OK, 531 00:42:56,060 --> 00:43:00,140 let me color several nodes in this graph-- such 532 00:43:00,140 --> 00:43:04,990 that each edge is connected to at least one dark node. 533 00:43:07,890 --> 00:43:08,390 OK. 534 00:43:08,390 --> 00:43:11,210 And this, the nodes I colored, is called a cover. 535 00:43:11,210 --> 00:43:14,750 I want to find a minimum cover. 536 00:43:14,750 --> 00:43:19,070 You can of course cover all the nodes, that trivially holds, 537 00:43:19,070 --> 00:43:20,850 but we are looking for the minimum cover. 538 00:43:20,850 --> 00:43:28,890 And the claim is that min cover is k if and only 539 00:43:28,890 --> 00:43:43,270 if max flow-- sorry, max matching-- is k. 540 00:43:43,270 --> 00:43:44,610 Why is that? 541 00:43:44,610 --> 00:43:50,680 Because in that matching-- if we have a matching, 542 00:43:50,680 --> 00:43:55,713 then we have a set of disjointed edges, right? 543 00:43:55,713 --> 00:43:59,040 No two edges are connected to the same node. 544 00:43:59,040 --> 00:44:02,460 So if we want to cover these edges, 545 00:44:02,460 --> 00:44:07,570 we at least have to add one of these guys-- color 546 00:44:07,570 --> 00:44:10,070 one of these two, and one of these two. 547 00:44:10,070 --> 00:44:10,750 Right? 548 00:44:10,750 --> 00:44:14,870 So if we have k matching edges, then we at least 549 00:44:14,870 --> 00:44:17,408 need k nodes to cover them. 550 00:44:20,280 --> 00:44:22,920 For example, I can cover them like that. 551 00:44:28,280 --> 00:44:31,770 But this is not foolproof, because I also 552 00:44:31,770 --> 00:44:36,537 need to show I can indeed find a cover that is k. 553 00:44:45,110 --> 00:44:45,610 OK. 554 00:44:45,610 --> 00:44:48,918 Let me think about whether I should prove that. 555 00:44:54,396 --> 00:44:54,900 OK. 556 00:44:54,900 --> 00:44:56,850 I'm going to give it a try. 557 00:44:56,850 --> 00:45:00,365 If you don't get that, that's fine. 558 00:45:00,365 --> 00:45:02,947 AUDIENCE: Can you say again what cover is? 559 00:45:02,947 --> 00:45:03,530 PROFESSOR: OK. 560 00:45:03,530 --> 00:45:04,030 Cover-- 561 00:45:04,030 --> 00:45:05,210 AUDIENCE: [INAUDIBLE]? 562 00:45:05,210 --> 00:45:07,990 PROFESSOR: Cover is a set of nodes such 563 00:45:07,990 --> 00:45:13,720 that every edge in the graph is connected to at least one 564 00:45:13,720 --> 00:45:16,810 of the nodes, in a cover. 565 00:45:16,810 --> 00:45:17,310 OK? 566 00:45:17,310 --> 00:45:20,765 So this is not a cover, because this edge is not covered. 567 00:45:26,090 --> 00:45:29,940 So in this case I probably have to add that as well. 568 00:45:29,940 --> 00:45:33,570 But clearly there's a better cover, even a smaller cover, 569 00:45:33,570 --> 00:45:36,199 which is those two. 570 00:45:36,199 --> 00:45:36,698 Right? 571 00:45:36,698 --> 00:45:37,197 Yeah. 572 00:45:40,440 --> 00:45:44,420 So how are we going to transform that matching to cover? 573 00:45:44,420 --> 00:45:47,400 So let me first give a matching here. 574 00:45:47,400 --> 00:45:51,950 One max matching should be something like this. 575 00:45:51,950 --> 00:45:55,470 I have this edge and one of those two. 576 00:45:59,640 --> 00:46:01,340 That is a matching. 577 00:46:01,340 --> 00:46:01,940 Right? 578 00:46:01,940 --> 00:46:03,290 That is a max matching. 579 00:46:08,406 --> 00:46:09,405 No questions about that? 580 00:46:12,810 --> 00:46:15,460 Let me get rid of all this. 581 00:46:15,460 --> 00:46:18,120 One way to transform this into a cover 582 00:46:18,120 --> 00:46:24,230 is that I will first color these two guys. 583 00:46:24,230 --> 00:46:27,140 I colored the nodes on the left where they are 584 00:46:27,140 --> 00:46:30,620 connected to a matching edge. 585 00:46:30,620 --> 00:46:33,330 After that, I'm going to start from this one 586 00:46:33,330 --> 00:46:38,790 and jump between nodes, taking an alternating path. 587 00:46:38,790 --> 00:46:41,850 Meaning I'll take an unmatched edge, 588 00:46:41,850 --> 00:46:45,560 and then take a matched edge, and then take an unmatched edge 589 00:46:45,560 --> 00:46:47,240 again, but there's no such thing. 590 00:47:04,880 --> 00:47:05,410 OK. 591 00:47:05,410 --> 00:47:09,670 And if I take this jump, I will swap them, make that dark. 592 00:47:17,870 --> 00:47:18,370 OK. 593 00:47:18,370 --> 00:47:19,661 This graph is a little strange. 594 00:47:26,372 --> 00:47:27,530 Ah, OK. 595 00:47:27,530 --> 00:47:30,460 Now I claim this is a cover. 596 00:47:30,460 --> 00:47:31,570 Is that? 597 00:47:31,570 --> 00:47:32,652 Yeah, that is one, right? 598 00:47:35,490 --> 00:47:41,380 And if there is another unmatched edge going out, 599 00:47:41,380 --> 00:47:44,160 then I'll keep taking that alternating path. 600 00:47:44,160 --> 00:47:49,090 But I have to stop, because there's no such edge anymore. 601 00:47:49,090 --> 00:47:51,640 How can I say-- why I can prove-- why can 602 00:47:51,640 --> 00:47:55,370 I claim this is a cover? 603 00:47:55,370 --> 00:47:58,410 So clearly if this is a cover, then it's a cover of size k, 604 00:47:58,410 --> 00:47:58,910 right? 605 00:47:58,910 --> 00:48:01,869 So we have proved the entire thing. 606 00:48:01,869 --> 00:48:04,160 Then we're going to consider several things separately. 607 00:48:09,280 --> 00:48:12,970 So I'm going to first claim if I have a matched edge, 608 00:48:12,970 --> 00:48:19,410 then it's definitely covered, because one of its end points 609 00:48:19,410 --> 00:48:20,750 is dark. 610 00:48:20,750 --> 00:48:21,250 Right. 611 00:48:21,250 --> 00:48:26,040 We only do a switching between dark and white 612 00:48:26,040 --> 00:48:28,371 if it's a matched edge itself. 613 00:48:28,371 --> 00:48:28,870 Right. 614 00:48:28,870 --> 00:48:33,930 So I only need to show that this thing doesn't happen. 615 00:48:33,930 --> 00:48:36,020 There's an edge that's unmatched, 616 00:48:36,020 --> 00:48:41,590 and two of its endpoints are both white. 617 00:48:41,590 --> 00:48:42,090 OK. 618 00:48:42,090 --> 00:48:46,740 I'm going to first claim this node cannot have a matched 619 00:48:46,740 --> 00:48:48,800 edge. 620 00:48:48,800 --> 00:48:51,040 Because if it does, then this is an alternating path, 621 00:48:51,040 --> 00:48:54,950 and I'm going to switch this too. 622 00:48:54,950 --> 00:48:55,450 OK. 623 00:48:55,450 --> 00:48:57,660 Make sense? 624 00:48:57,660 --> 00:48:58,160 OK. 625 00:48:58,160 --> 00:49:01,100 So this doesn't exist. 626 00:49:01,100 --> 00:49:03,490 So it can only have an unmatched edge. 627 00:49:03,490 --> 00:49:06,330 Now what can I say about this node? 628 00:49:06,330 --> 00:49:12,230 I claim this node needs at least one matched edge, because if it 629 00:49:12,230 --> 00:49:17,890 doesn't, right, then I should add this guy into my matching. 630 00:49:17,890 --> 00:49:20,040 It doesn't violate any constraint. 631 00:49:20,040 --> 00:49:23,165 I didn't add that because there's probably a matched 632 00:49:23,165 --> 00:49:27,080 edge connecting to this guy. 633 00:49:27,080 --> 00:49:30,030 Then I'm going to-- so, then this guy 634 00:49:30,030 --> 00:49:33,410 has to be dark, because this one is not. 635 00:49:33,410 --> 00:49:35,510 Then how did this one become dark? 636 00:49:35,510 --> 00:49:38,020 It must have come from some other guy on the left, right? 637 00:49:38,020 --> 00:49:40,460 So there's an alternating path going back and forth. 638 00:49:48,840 --> 00:49:50,620 Something like this. 639 00:49:50,620 --> 00:49:54,010 There is an alternating path, starting from left, 640 00:49:54,010 --> 00:49:57,070 but ends here. 641 00:49:57,070 --> 00:49:59,490 Because we showed that this guy is not connecting 642 00:49:59,490 --> 00:50:02,080 to any matched edges. 643 00:50:02,080 --> 00:50:04,640 In that case, what I'm going to do is match this edge, 644 00:50:04,640 --> 00:50:06,350 match this edge, match this edge, 645 00:50:06,350 --> 00:50:09,230 then unmatch these two edges. 646 00:50:09,230 --> 00:50:13,380 And that's a larger matching. 647 00:50:13,380 --> 00:50:15,331 Because I removed the two, I added three. 648 00:50:26,400 --> 00:50:35,720 That means a max matching of k leads to a minimum cover of k 649 00:50:35,720 --> 00:50:41,284 as well, which also means max flow of k in our network flow. 650 00:50:44,450 --> 00:50:46,585 So this part-- this equivalence is not required. 651 00:50:50,050 --> 00:50:54,730 You should know this proof, the proof of Edmonds-Karp, 652 00:50:54,730 --> 00:50:57,400 and know that a matching and cover can 653 00:50:57,400 --> 00:51:01,380 be solved by network flow, and that Dinitz's name is 654 00:51:01,380 --> 00:51:02,925 spelled not as Dinic. 655 00:51:07,601 --> 00:51:08,100 OK. 656 00:51:08,100 --> 00:51:11,104 And that's everything for today.