1 00:00:00,080 --> 00:00:02,430 The following content is provided under a Creative 2 00:00:02,430 --> 00:00:03,810 Commons license. 3 00:00:03,810 --> 00:00:06,050 Your support will help MIT OpenCourseWare 4 00:00:06,050 --> 00:00:10,150 continue to offer high quality educational resources for free. 5 00:00:10,150 --> 00:00:12,690 To make a donation or to view additional materials 6 00:00:12,690 --> 00:00:16,600 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:16,600 --> 00:00:17,260 at ocw.mit.edu. 8 00:00:25,920 --> 00:00:26,920 ERIK DEMAINE: All right. 9 00:00:26,920 --> 00:00:30,840 Today we start a new section of NP-hardness. 10 00:00:30,840 --> 00:00:34,230 I think it'll be one lecture about Hamiltonicity. 11 00:00:34,230 --> 00:00:39,600 So Hamiltonian cycle and path. 12 00:00:39,600 --> 00:00:41,260 We've talked about this briefly. 13 00:00:41,260 --> 00:00:48,970 But cycle is just a cycle visiting every vertex exactly 14 00:00:48,970 --> 00:00:49,470 once. 15 00:00:58,900 --> 00:01:02,840 And usually when you talk about a graph being Hamiltonian, 16 00:01:02,840 --> 00:01:05,180 you mean that there's a Hamiltonian cycle, also called 17 00:01:05,180 --> 00:01:08,840 a Hamiltonian tour, or Hamiltonian circuit all 18 00:01:08,840 --> 00:01:10,440 mean the same thing. 19 00:01:10,440 --> 00:01:13,090 And then there's Hamiltonian path. 20 00:01:13,090 --> 00:01:16,000 Another problem we have looked at before. 21 00:01:16,000 --> 00:01:18,650 And same thing, but path that visits every vertex exactly 22 00:01:18,650 --> 00:01:19,150 once. 23 00:01:19,150 --> 00:01:20,774 These are pretty much the same problem, 24 00:01:20,774 --> 00:01:24,580 but different versions are useful in different settings. 25 00:01:24,580 --> 00:01:26,910 In case you're curious where this comes from, 26 00:01:26,910 --> 00:01:31,290 it comes from this game introduced by Hamilton in 1857. 27 00:01:31,290 --> 00:01:36,410 He was the royal astronomer of Ireland back then, 28 00:01:36,410 --> 00:01:40,360 but he had fun with games as well. 29 00:01:40,360 --> 00:01:44,520 So here you have something like the graph of a dodecahedron. 30 00:01:44,520 --> 00:01:46,890 The dual is an icosahedron, hence the name, 31 00:01:46,890 --> 00:01:49,577 and you want to find a Hamiltonian circuit through it. 32 00:01:49,577 --> 00:01:52,160 Or there's actually a two-player game where one person chooses 33 00:01:52,160 --> 00:01:53,660 a subset of the graph, the other one 34 00:01:53,660 --> 00:01:57,500 tries to find Hamiltonian circuit in that subset. 35 00:01:57,500 --> 00:02:01,080 So that's where Hamiltonicity comes from. 36 00:02:01,080 --> 00:02:05,280 But for us today it is a nice NP-complete problem. 37 00:02:05,280 --> 00:02:11,760 We've actually seen one proof that planar max degree four, 38 00:02:11,760 --> 00:02:16,730 I think, Hamiltonicity is hard. 39 00:02:16,730 --> 00:02:20,890 That was in the planar SAT discussion, 40 00:02:20,890 --> 00:02:23,730 and this is the original paper that does planar 3SAT. 41 00:02:23,730 --> 00:02:26,470 And there was this proof-- I guess it's not actually 42 00:02:26,470 --> 00:02:29,090 max degree four, probably a max degree six or something. 43 00:02:33,140 --> 00:02:35,420 We argued the directed case-- this apparently 44 00:02:35,420 --> 00:02:37,245 works for the undirected case-- we'll get 45 00:02:37,245 --> 00:02:40,890 an even stronger result here. 46 00:02:40,890 --> 00:02:50,140 In general, the problem is NP-complete in a lot 47 00:02:50,140 --> 00:02:56,090 of different special cases, such as the one we saw. 48 00:02:56,090 --> 00:02:59,310 For example, if you're looking for a path 49 00:02:59,310 --> 00:03:05,734 and you're given the two end points-- so 50 00:03:05,734 --> 00:03:07,650 normally you'd say is there a Hamiltonian path 51 00:03:07,650 --> 00:03:08,900 or is there Hamiltonian cycle? 52 00:03:08,900 --> 00:03:10,800 Those are both hard in general graphs. 53 00:03:10,800 --> 00:03:14,740 But if I give you a graph and I give you two nodes, s and t, 54 00:03:14,740 --> 00:03:18,540 and I want to know is there-- so here's the graph, 55 00:03:18,540 --> 00:03:20,790 here's s and t-- I want to know is there a path that 56 00:03:20,790 --> 00:03:23,420 starts at s, ends at t. 57 00:03:23,420 --> 00:03:25,140 This is NP-hard. 58 00:03:25,140 --> 00:03:30,374 By reduction from Hamiltonian cycle, tell me what to do. 59 00:03:30,374 --> 00:03:34,182 AUDIENCE: You add a new node which has connection to s 60 00:03:34,182 --> 00:03:35,907 and t and nothing else. 61 00:03:35,907 --> 00:03:37,490 ERIK DEMAINE: Add a new node connected 62 00:03:37,490 --> 00:03:38,660 to s and t and nothing else. 63 00:03:38,660 --> 00:03:39,160 Yeah. 64 00:03:39,160 --> 00:03:44,294 So we'll add this new node x, connected to s and t. 65 00:03:44,294 --> 00:03:45,960 What's interesting about adding a degree 66 00:03:45,960 --> 00:03:48,590 two node is you know it has to be in the cycle, 67 00:03:48,590 --> 00:03:52,016 so you know that these two edges have to be in the cycle. 68 00:03:52,016 --> 00:03:53,515 AUDIENCE: Also, if it's directed you 69 00:03:53,515 --> 00:03:55,000 can direct those two so that-- 70 00:03:55,000 --> 00:03:57,749 ERIK DEMAINE: It's not directed. 71 00:03:57,749 --> 00:03:59,290 All these are going to be undirected. 72 00:04:05,650 --> 00:04:09,160 This would preserve directedness if you wanted it. 73 00:04:09,160 --> 00:04:11,520 So there you go. 74 00:04:11,520 --> 00:04:14,310 So if Hamiltonian cycle's hard, then Hamiltonian path 75 00:04:14,310 --> 00:04:15,750 given two end points is hard. 76 00:04:15,750 --> 00:04:18,529 Easy warm-up. 77 00:04:18,529 --> 00:04:27,640 It's also NP-complete for planar three regular, 78 00:04:27,640 --> 00:04:36,595 three connected graphs, where every face 79 00:04:36,595 --> 00:04:37,790 has degree at least five. 80 00:04:37,790 --> 00:04:40,370 But probably already met them. 81 00:04:40,370 --> 00:04:43,790 It's NP-hard for bipartite graphs. 82 00:04:43,790 --> 00:04:51,277 These are all various results proved in the '70s. 83 00:04:51,277 --> 00:04:53,110 It's going to be hard for squares of graphs. 84 00:04:57,580 --> 00:04:59,020 Squares of graphs is interesting. 85 00:04:59,020 --> 00:05:02,060 This is whenever you have a length two path, 86 00:05:02,060 --> 00:05:03,730 you add an edge. 87 00:05:03,730 --> 00:05:08,610 It's a square, and that's still hard. 88 00:05:08,610 --> 00:05:12,540 Another fun problem is computing a Hamiltonian cycle 89 00:05:12,540 --> 00:05:15,740 given a Hamiltonian path is also hard. 90 00:05:20,720 --> 00:05:23,700 On the other hand, some variations are easy. 91 00:05:23,700 --> 00:05:26,770 So you have to be a little bit careful. 92 00:05:26,770 --> 00:05:29,990 There are a lot of papers about various graphs 93 00:05:29,990 --> 00:05:31,860 that are always Hamiltonian and usually 94 00:05:31,860 --> 00:05:34,193 when they're always Hamiltonian there's a good algorithm 95 00:05:34,193 --> 00:05:35,370 to find them. 96 00:05:35,370 --> 00:05:37,540 Here are just a couple of examples. 97 00:05:37,540 --> 00:05:41,130 One is cubes of graphs. 98 00:05:41,130 --> 00:05:44,410 So if you take all length three paths 99 00:05:44,410 --> 00:05:46,820 and connect them by an edge, or maybe length less than 100 00:05:46,820 --> 00:05:49,347 or equal to three-- I'm not sure exactly-- that's easy. 101 00:05:49,347 --> 00:05:51,680 All such graphs are Hamiltonian, where with squares it's 102 00:05:51,680 --> 00:05:52,910 still hard. 103 00:05:52,910 --> 00:05:54,290 So that's kind of a limit. 104 00:05:54,290 --> 00:05:57,720 And the other one here is planar-- three 105 00:05:57,720 --> 00:05:59,930 connector graphs is NP-complete. 106 00:05:59,930 --> 00:06:02,460 Planar four connector graphs is polynomial. 107 00:06:08,130 --> 00:06:12,570 This is a tough theorem, one of many tough theorems. 108 00:06:12,570 --> 00:06:15,630 All such graphs are Hamiltonian. 109 00:06:15,630 --> 00:06:18,280 So those are a few cases to worry about. 110 00:06:18,280 --> 00:06:20,190 We will see some more today. 111 00:06:20,190 --> 00:06:22,950 And these are relatively simple. 112 00:06:22,950 --> 00:06:24,710 We're going to prove even stricter 113 00:06:24,710 --> 00:06:26,780 versions of this problem NP-complete, 114 00:06:26,780 --> 00:06:30,490 but it starts to give you the flavor of what's there. 115 00:06:34,120 --> 00:06:41,780 In fact the first one we will prove 116 00:06:41,780 --> 00:06:49,150 is-- this may seem a little weird because I wanted 117 00:06:49,150 --> 00:06:51,000 to do undirected, but we're going 118 00:06:51,000 --> 00:06:52,620 to make it undirected in a moment. 119 00:06:52,620 --> 00:06:55,240 We're going to do a series of reductions. 120 00:06:55,240 --> 00:07:01,530 First one we'll do is planar max degree three graphs. 121 00:07:06,180 --> 00:07:11,210 So this will be a reduction from 3SAT. 122 00:07:11,210 --> 00:07:15,999 So the general idea, and please wait why you 123 00:07:15,999 --> 00:07:17,290 should care about this problem. 124 00:07:17,290 --> 00:07:19,456 We're going to reduce it to another more interesting 125 00:07:19,456 --> 00:07:21,020 version of Hamiltonicity. 126 00:07:21,020 --> 00:07:24,600 But here's one way to represent 3SAT as Hamiltonicity-- 127 00:07:24,600 --> 00:07:27,300 another way, similar to the one we did before. 128 00:07:27,300 --> 00:07:29,450 We got clauses here over on the left. 129 00:07:29,450 --> 00:07:31,760 Here some of the clauses have size two, 130 00:07:31,760 --> 00:07:34,620 but it works for the three case. 131 00:07:34,620 --> 00:07:38,030 Here we have the variables. 132 00:07:38,030 --> 00:07:43,370 And the key concept here is this notation. 133 00:07:43,370 --> 00:07:48,030 This is shorthand for a more complicated gadget, 134 00:07:48,030 --> 00:07:52,040 which is to say that these two things should not 135 00:07:52,040 --> 00:07:53,100 be both chosen. 136 00:07:53,100 --> 00:07:55,910 This is an exclusive OR. 137 00:07:55,910 --> 00:07:57,710 Exactly one of them should be chosen. 138 00:07:57,710 --> 00:08:01,210 So that forces x1 to be the opposite of x1 bar, 139 00:08:01,210 --> 00:08:02,862 and it also lets you duplicate things. 140 00:08:02,862 --> 00:08:04,820 So here we get multiple copies of the variable. 141 00:08:04,820 --> 00:08:06,361 You keep doing that several times you 142 00:08:06,361 --> 00:08:09,070 get many copies of variable and its complement. 143 00:08:09,070 --> 00:08:12,790 And then we're also going to use some connections like this. 144 00:08:12,790 --> 00:08:14,880 We're going to need a crossover gadget, 145 00:08:14,880 --> 00:08:18,780 but this will say that you-- well, 146 00:08:18,780 --> 00:08:20,910 so this is going to be some clause which 147 00:08:20,910 --> 00:08:22,420 it's not literally as drawn. 148 00:08:22,420 --> 00:08:25,370 Again, this is notation for a gadget the 149 00:08:25,370 --> 00:08:29,580 is going to force at least one of these to be traversable. 150 00:08:29,580 --> 00:08:31,780 And so that overall should represent 3SAT. 151 00:08:31,780 --> 00:08:33,190 We need a clause gadget. 152 00:08:33,190 --> 00:08:35,919 We need this exclusive OR so that we can split, 153 00:08:35,919 --> 00:08:36,690 duplicate things. 154 00:08:36,690 --> 00:08:39,253 Overall, the cycle's going to do this. 155 00:08:39,253 --> 00:08:41,419 It's going to visit all the variables in order, then 156 00:08:41,419 --> 00:08:43,159 all the clauses in order. 157 00:08:43,159 --> 00:08:46,200 So we can't get anything interesting out of planarity, 158 00:08:46,200 --> 00:08:48,157 because that graph with these connections 159 00:08:48,157 --> 00:08:49,240 is not going to be planar. 160 00:08:49,240 --> 00:08:50,374 So we'll need a crossover. 161 00:08:50,374 --> 00:08:52,040 And those are the three gadgets we need. 162 00:08:52,040 --> 00:08:52,465 Yeah. 163 00:08:52,465 --> 00:08:54,157 AUDIENCE: Why were you using exclusively 164 00:08:54,157 --> 00:08:57,690 working with [INAUDIBLE] variables [INAUDIBLE]? 165 00:08:57,690 --> 00:09:00,170 ERIK DEMAINE: So the idea is here there's a choice. 166 00:09:00,170 --> 00:09:03,870 Do I choose this edge or this edge in the Hamiltonian cycle. 167 00:09:03,870 --> 00:09:05,700 And I want the choice for this copy of x1 168 00:09:05,700 --> 00:09:08,450 to be the same as for that copy of x1. 169 00:09:08,450 --> 00:09:12,940 So the exclusive OR forces each instance of x1 to be the same. 170 00:09:12,940 --> 00:09:14,560 In general, if there's k instances, 171 00:09:14,560 --> 00:09:16,116 you'd have k of these. 172 00:09:16,116 --> 00:09:18,008 AUDIENCE: Can you connect that? 173 00:09:18,008 --> 00:09:19,924 Use the same guy to connect it to the instance 174 00:09:19,924 --> 00:09:20,876 inside the clause? 175 00:09:24,700 --> 00:09:29,129 ERIK DEMAINE: I guess the reason why we need two copies here is 176 00:09:29,129 --> 00:09:31,670 that you can't-- well, see you can't have 2 XOR gadgets going 177 00:09:31,670 --> 00:09:33,680 to the same place. 178 00:09:33,680 --> 00:09:35,907 So it will be clear once we've seen the XOR gadget. 179 00:09:35,907 --> 00:09:38,490 We want two distinct copies so that these two things can point 180 00:09:38,490 --> 00:09:41,040 to different copies of x1. 181 00:09:41,040 --> 00:09:43,155 That's why we're making a copy like that. 182 00:09:43,155 --> 00:09:44,502 Does that make sense? 183 00:09:44,502 --> 00:09:45,710 AUDIENCE: [INAUDIBLE]. 184 00:09:45,710 --> 00:09:46,680 ERIK DEMAINE: OK. 185 00:09:46,680 --> 00:09:48,500 Excellent. 186 00:09:48,500 --> 00:09:49,405 Actually, same slide. 187 00:09:49,405 --> 00:09:51,350 I should just show them. 188 00:09:51,350 --> 00:09:55,220 So here is-- maybe let's start with the XOR gadget 189 00:09:55,220 --> 00:09:59,010 because the clause-- ah, clause doesn't actually use it. 190 00:09:59,010 --> 00:10:03,940 So the XOR gadget is if we have two edges of opposite direction 191 00:10:03,940 --> 00:10:06,687 relative to the way we're being connected. 192 00:10:06,687 --> 00:10:08,270 I think it also works in the other way 193 00:10:08,270 --> 00:10:10,970 because these are-- no, these are also opposite 194 00:10:10,970 --> 00:10:14,870 if you redraw it this way. 195 00:10:14,870 --> 00:10:17,570 We're just going to have this picture, which 196 00:10:17,570 --> 00:10:19,540 can be traversed. 197 00:10:19,540 --> 00:10:21,150 Either this guy can come in-- here 198 00:10:21,150 --> 00:10:24,930 we're really using direction, directionality of the graph. 199 00:10:24,930 --> 00:10:27,740 You can traverse the top edge or you 200 00:10:27,740 --> 00:10:32,070 can traverse the bottom edge in the opposite direction. 201 00:10:32,070 --> 00:10:35,570 But you can't just turn around because then these vertices 202 00:10:35,570 --> 00:10:37,580 would be uncovered. 203 00:10:37,580 --> 00:10:40,430 And as soon as you've gone this far, 204 00:10:40,430 --> 00:10:41,800 you can't come back this way. 205 00:10:41,800 --> 00:10:43,780 So once you enter here you're forced to leave there. 206 00:10:43,780 --> 00:10:44,743 Once you enter here you're forced 207 00:10:44,743 --> 00:10:46,826 to leave there, if you want to cover everything. 208 00:10:46,826 --> 00:10:48,450 So that's an exclusive OR, and at least 209 00:10:48,450 --> 00:10:50,740 one of those better happen. 210 00:10:50,740 --> 00:10:53,340 So that's what happens over there. 211 00:10:53,340 --> 00:10:55,600 And also what we'll end up doing here, 212 00:10:55,600 --> 00:10:58,210 except we also need the crossing case. 213 00:10:58,210 --> 00:11:00,620 On the other hand, for the clause, 214 00:11:00,620 --> 00:11:07,070 the idea is basically there's a cycle over here, which is fine. 215 00:11:07,070 --> 00:11:10,300 But somehow that cycle for that clause 216 00:11:10,300 --> 00:11:13,530 has to be connected into the big cycle that we've drawn already. 217 00:11:13,530 --> 00:11:15,020 And at least one of the variables 218 00:11:15,020 --> 00:11:16,810 needs to connect to that. 219 00:11:16,810 --> 00:11:25,050 So the idea is we can come up here-- 220 00:11:25,050 --> 00:11:29,230 so also these vertices need to be covered. 221 00:11:29,230 --> 00:11:33,870 So we can come up here, go over here, loop around, 222 00:11:33,870 --> 00:11:34,790 and be happy. 223 00:11:34,790 --> 00:11:38,870 And then we've grab the entire cycle. 224 00:11:38,870 --> 00:11:42,050 Also, when we've grabbed this cycle, 225 00:11:42,050 --> 00:11:50,010 we can also grab these vertices. 226 00:11:50,010 --> 00:11:51,950 All of them. 227 00:11:51,950 --> 00:11:56,840 That's only going to be possible if this is possible. 228 00:11:56,840 --> 00:12:02,930 So in the outer side, we can't go here and then up here. 229 00:12:02,930 --> 00:12:05,450 We can go here over here. 230 00:12:05,450 --> 00:12:06,900 That's also fine. 231 00:12:06,900 --> 00:12:08,660 OK. 232 00:12:08,660 --> 00:12:09,341 Good. 233 00:12:09,341 --> 00:12:09,840 I see. 234 00:12:09,840 --> 00:12:13,250 So that the issue is-- so these are actually flexible. 235 00:12:13,250 --> 00:12:16,430 These guys can be covered basically from the right side 236 00:12:16,430 --> 00:12:18,280 or from the left side, either way. 237 00:12:18,280 --> 00:12:22,520 So it doesn't matter whether you take this path or this path. 238 00:12:22,520 --> 00:12:26,810 But at least one of these sort of pairs of edges, 239 00:12:26,810 --> 00:12:28,800 as they're drawn over here, you need 240 00:12:28,800 --> 00:12:31,380 to be able to choose the left choice 241 00:12:31,380 --> 00:12:34,430 and, therefore, get the big cycle. 242 00:12:34,430 --> 00:12:37,650 And the issue with that is because you have this XOR, 243 00:12:37,650 --> 00:12:40,320 it's an exclusive OR, exactly one of those two things 244 00:12:40,320 --> 00:12:41,190 must be true. 245 00:12:41,190 --> 00:12:42,810 So in some cases, you'll be forced 246 00:12:42,810 --> 00:12:45,240 to choose the right thing. 247 00:12:45,240 --> 00:12:47,750 If this variable chose the right path, 248 00:12:47,750 --> 00:12:51,340 then this one will also have to choose the right path because 249 00:12:51,340 --> 00:12:54,280 of this exclusive OR, and preventing you 250 00:12:54,280 --> 00:12:55,780 from grabbing the cycle. 251 00:12:55,780 --> 00:12:58,700 You're fine in this clause if at least one of them 252 00:12:58,700 --> 00:13:00,860 you choose the left path. 253 00:13:00,860 --> 00:13:02,820 In fact, if you look very closely 254 00:13:02,820 --> 00:13:04,570 there's some bold edges indicating 255 00:13:04,570 --> 00:13:05,760 which one's got chosen here. 256 00:13:05,760 --> 00:13:08,650 So here, two of them were on the right, one of them 257 00:13:08,650 --> 00:13:10,320 was on the left for this clause. 258 00:13:10,320 --> 00:13:12,630 In general, if at least one of them is on the left 259 00:13:12,630 --> 00:13:16,230 you're OK for the clause. 260 00:13:16,230 --> 00:13:16,810 Clear. 261 00:13:16,810 --> 00:13:18,010 The high level now. 262 00:13:18,010 --> 00:13:21,170 This would work fine if we didn't care about planarity, 263 00:13:21,170 --> 00:13:23,400 but I want planar directed max degree three. 264 00:13:23,400 --> 00:13:27,260 At this point we should be directed max degree three. 265 00:13:27,260 --> 00:13:32,050 So that's an improvement from last time in terms of degrees. 266 00:13:32,050 --> 00:13:37,150 And then there's this fun figure for the crossover. 267 00:13:37,150 --> 00:13:40,170 So in general, that's just a repetition 268 00:13:40,170 --> 00:13:41,810 of what our XOR gadget was. 269 00:13:41,810 --> 00:13:46,760 Now we have crossing XOR constraints. 270 00:13:46,760 --> 00:13:49,190 So here's a typical example. 271 00:13:49,190 --> 00:13:51,260 Let's say we have this XOR trying 272 00:13:51,260 --> 00:13:55,440 to go from there to there and it crosses these other XORs. 273 00:13:55,440 --> 00:13:58,510 So what we're going to do is build something 274 00:13:58,510 --> 00:14:02,710 like that gadget for the vertical connection with this, 275 00:14:02,710 --> 00:14:05,290 and this, and this, and this. 276 00:14:05,290 --> 00:14:07,270 And we duplicate these edges. 277 00:14:07,270 --> 00:14:10,205 That doesn't help you-- I mean it's the same as that picture, 278 00:14:10,205 --> 00:14:11,820 I just happened to duplicate them. 279 00:14:11,820 --> 00:14:13,319 The reason we do that is we're going 280 00:14:13,319 --> 00:14:19,670 to put XORs across like this, and this forces an alternation. 281 00:14:19,670 --> 00:14:22,650 So if this is in, then this must be out, 282 00:14:22,650 --> 00:14:25,430 so this must be in, so this must be out, 283 00:14:25,430 --> 00:14:29,030 so this must be in, and so on all the way through. 284 00:14:29,030 --> 00:14:31,970 And so that forces an XOR between this edge 285 00:14:31,970 --> 00:14:34,990 and that edge. 286 00:14:34,990 --> 00:14:36,730 Cool? 287 00:14:36,730 --> 00:14:41,440 So that is the crossing x over XOR gadget, which 288 00:14:41,440 --> 00:14:44,000 you plug into all of these pictures, 289 00:14:44,000 --> 00:14:48,310 and you end up with planar directed max degree three. 290 00:14:48,310 --> 00:14:49,740 All right? 291 00:14:49,740 --> 00:14:53,050 So far so good. 292 00:14:53,050 --> 00:14:55,762 Next-- I have a goal. 293 00:14:55,762 --> 00:14:57,470 I'm still not going to tell you the goal. 294 00:15:00,780 --> 00:15:07,980 Next one is going to be planar bipartite max degree three. 295 00:15:18,715 --> 00:15:19,215 Undirected. 296 00:15:21,930 --> 00:15:25,320 This is going to be one of our simplest reductions ever. 297 00:15:25,320 --> 00:15:27,210 There it is. 298 00:15:27,210 --> 00:15:29,720 So the cool thing about max degree three 299 00:15:29,720 --> 00:15:33,340 directed-- I mean there are few cases you can exclude. 300 00:15:33,340 --> 00:15:35,071 You can't have three incoming edges. 301 00:15:35,071 --> 00:15:36,570 You can't have three outgoing edges. 302 00:15:36,570 --> 00:15:38,403 It would be pretty hard to have a cycle that 303 00:15:38,403 --> 00:15:40,440 includes such vertices. 304 00:15:40,440 --> 00:15:42,530 So you could have degree two vertices, 305 00:15:42,530 --> 00:15:46,080 but I don't think we even had any. 306 00:15:46,080 --> 00:15:52,500 Did I say that we had degree two in this picture? 307 00:15:52,500 --> 00:15:54,100 Probably not. 308 00:15:54,100 --> 00:15:57,670 I mean if we did we could double the edge or something. 309 00:15:57,670 --> 00:16:02,110 So that was probably actually planar directed three regular. 310 00:16:02,110 --> 00:16:05,110 OK, but now undirected. 311 00:16:05,110 --> 00:16:06,950 But you can basically have two edges in, 312 00:16:06,950 --> 00:16:11,790 one out, or one edge in and two out. 313 00:16:11,790 --> 00:16:14,534 And we're going to convert that. 314 00:16:14,534 --> 00:16:15,950 So the interesting thing here, you 315 00:16:15,950 --> 00:16:18,110 have to visit this vertex, which means 316 00:16:18,110 --> 00:16:22,166 you have to visit this edge in any Hamiltonian cycle. 317 00:16:22,166 --> 00:16:23,540 Because once you come here you've 318 00:16:23,540 --> 00:16:24,410 got to leave on that edge. 319 00:16:24,410 --> 00:16:26,160 Similarly, you have to visit this edge. 320 00:16:26,160 --> 00:16:27,868 You can tell that just from this picture. 321 00:16:27,868 --> 00:16:29,880 So we call these forced edges. 322 00:16:29,880 --> 00:16:32,810 And we can represent that by adding a vertex there. 323 00:16:32,810 --> 00:16:34,720 It says, hey, you've got to visit that edge. 324 00:16:34,720 --> 00:16:38,950 So you're going to visit it by that little path there. 325 00:16:38,950 --> 00:16:40,810 And now things are bipartite. 326 00:16:44,800 --> 00:16:46,590 And the bipartiteness is essentially 327 00:16:46,590 --> 00:16:49,760 forcing the directionality as well. 328 00:16:49,760 --> 00:16:53,800 So let's say when you come into a vertex and you're blue, 329 00:16:53,800 --> 00:16:55,830 so that means these guys have had 330 00:16:55,830 --> 00:16:59,840 to have been red, whenever you leave, 331 00:16:59,840 --> 00:17:02,450 you first visit a red vertex and then go. 332 00:17:02,450 --> 00:17:05,579 So here you're coming in again as blue, and then 333 00:17:05,579 --> 00:17:07,400 before you leave you turn red. 334 00:17:07,400 --> 00:17:12,220 And so because you've satisfied directionality over here, 335 00:17:12,220 --> 00:17:14,480 the outgoing edge here becomes an incoming edge 336 00:17:14,480 --> 00:17:17,000 to the next vertex, that means you'll 337 00:17:17,000 --> 00:17:19,510 be going into a blue vertex either because it's 338 00:17:19,510 --> 00:17:22,250 like this or like that. 339 00:17:22,250 --> 00:17:26,836 And you are effectively forcing directionality. 340 00:17:30,310 --> 00:17:31,810 I mean everything could be reversed. 341 00:17:36,120 --> 00:17:38,675 Because you're always coming into a blue vertex 342 00:17:38,675 --> 00:17:39,550 and leaving on a red. 343 00:17:39,550 --> 00:17:44,100 That forces you to be going from the tail of an arrow 344 00:17:44,100 --> 00:17:46,530 to the head of an arrow. 345 00:17:46,530 --> 00:17:49,430 So same thing by symmetry. 346 00:17:49,430 --> 00:17:54,910 So these problems are actually really close to each other. 347 00:17:54,910 --> 00:17:56,520 These were done in different papers, 348 00:17:56,520 --> 00:17:59,210 but this was an older one. 349 00:17:59,210 --> 00:18:04,160 And then this problem was introduced for another reason, 350 00:18:04,160 --> 00:18:07,110 which is grid graphs. 351 00:18:07,110 --> 00:18:08,602 This is where I really want to go. 352 00:18:14,750 --> 00:18:19,500 So the idea with the grid graph is you, 353 00:18:19,500 --> 00:18:27,405 let's say, have a set of points on the square lattice. 354 00:18:35,160 --> 00:18:38,580 And then you're going to have an edge whenever you have 355 00:18:38,580 --> 00:18:40,090 two points at unit distance. 356 00:18:45,580 --> 00:18:49,130 So let me draw an example. 357 00:18:49,130 --> 00:18:52,560 Cheat, and have some examples drawn for me. 358 00:18:52,560 --> 00:18:56,010 This was in a much more recent paper, but some nice pictures. 359 00:18:56,010 --> 00:18:59,900 So we're just choosing a set of points in the square grid. 360 00:18:59,900 --> 00:19:02,180 And then whenever we have two points that 361 00:19:02,180 --> 00:19:03,642 are a unit distance apart, you're 362 00:19:03,642 --> 00:19:04,850 forced to have an edge there. 363 00:19:04,850 --> 00:19:06,100 You can't say there's no edge. 364 00:19:06,100 --> 00:19:08,990 That would be a sub-graph of a grid graph. 365 00:19:08,990 --> 00:19:11,130 But for example, when this point is absent, 366 00:19:11,130 --> 00:19:14,510 you don't get any connections through here. 367 00:19:14,510 --> 00:19:17,100 So these are all examples of grid graphs. 368 00:19:19,900 --> 00:19:23,210 Now there's one special case, or in general, we 369 00:19:23,210 --> 00:19:26,490 distinguish-- there's sort of three types of faces 370 00:19:26,490 --> 00:19:27,920 in such a planar graph. 371 00:19:27,920 --> 00:19:30,640 There's what you might call pixels-- little one 372 00:19:30,640 --> 00:19:32,070 by one squares. 373 00:19:32,070 --> 00:19:35,570 There's the outside face, and then there's 374 00:19:35,570 --> 00:19:37,300 everything else which we call holes. 375 00:19:37,300 --> 00:19:43,195 So any non-length for face we call hole. 376 00:19:43,195 --> 00:19:47,690 If there are no holes we call it a solid grid graph. 377 00:19:47,690 --> 00:19:51,110 This is interesting because solid grid 378 00:19:51,110 --> 00:19:53,370 graphs you can solve Hamiltonicity 379 00:19:53,370 --> 00:19:55,660 in polynomial time. 380 00:19:55,660 --> 00:19:59,070 It's not always possible, but there is a polynomial time 381 00:19:59,070 --> 00:20:02,570 algorithm for solving the solid grid graph 382 00:20:02,570 --> 00:20:06,255 case by Umens and Lenhart, '97. 383 00:20:06,255 --> 00:20:08,800 A very complicated algorithm. 384 00:20:08,800 --> 00:20:10,460 Luckily, this is a hardness proof class 385 00:20:10,460 --> 00:20:13,710 so I don't have to cover it. 386 00:20:13,710 --> 00:20:16,465 I'm going to focus on the hardness when you allow holes. 387 00:20:20,270 --> 00:20:23,430 So this is where things get fun. 388 00:20:23,430 --> 00:20:28,200 We are going to reduce-- we did a reduction from here to here. 389 00:20:28,200 --> 00:20:31,500 We're going to do a reduction from here to here. 390 00:20:31,500 --> 00:20:34,050 So we're going to suppose that we want to solve Hamiltonicity 391 00:20:34,050 --> 00:20:37,370 in planar bipartite max degree three graphs, 392 00:20:37,370 --> 00:20:39,960 and we're going to convert such a planar bipartite max degree 393 00:20:39,960 --> 00:20:40,690 three. 394 00:20:40,690 --> 00:20:46,370 Graph into a grid graph that acts the same. 395 00:20:49,520 --> 00:20:56,900 So the first step is to draw the graph on a grid. 396 00:20:56,900 --> 00:21:00,200 That's pretty obvious. 397 00:21:00,200 --> 00:21:02,310 So here's an example of what we want to do, 398 00:21:02,310 --> 00:21:04,400 and then this is a picture of how to do it. 399 00:21:04,400 --> 00:21:06,977 Suppose you have a bipartite planar graph. 400 00:21:06,977 --> 00:21:08,810 Not obvious this is planar, but it's obvious 401 00:21:08,810 --> 00:21:09,643 that it's bipartite. 402 00:21:09,643 --> 00:21:10,690 It happens to be planar. 403 00:21:10,690 --> 00:21:12,760 It's max degree three. 404 00:21:12,760 --> 00:21:16,410 And the vertices are labeled, the XIs and the YIs, 405 00:21:16,410 --> 00:21:18,740 and you can see the corresponding labeling here. 406 00:21:18,740 --> 00:21:22,280 So not all of the grid dots are going to be labeled. 407 00:21:22,280 --> 00:21:23,740 Some of them are just auxiliary. 408 00:21:23,740 --> 00:21:25,680 In order to connect to vertices we're 409 00:21:25,680 --> 00:21:30,150 going to have to draw paths, orthogonal paths on the grid. 410 00:21:30,150 --> 00:21:33,710 But the key thing I want is the square grid 411 00:21:33,710 --> 00:21:37,000 has a two-coloring inherently, and I want that two-coloring 412 00:21:37,000 --> 00:21:38,740 to match this two-coloring. 413 00:21:38,740 --> 00:21:41,620 That's what I would call a parity-preserving embedding 414 00:21:41,620 --> 00:21:44,770 of the Graph 415 00:21:44,770 --> 00:21:48,210 And you can see in this example, the three XIs are white, 416 00:21:48,210 --> 00:21:51,300 and the three YIs are black. 417 00:21:51,300 --> 00:21:54,212 And if you check all the edges they should correspond. 418 00:21:54,212 --> 00:21:55,670 Just ignore the dash lines-- that's 419 00:21:55,670 --> 00:21:59,460 to show you the grid underlying. 420 00:21:59,460 --> 00:22:01,140 So this is a valid embedding. 421 00:22:01,140 --> 00:22:02,500 How do we do it? 422 00:22:02,500 --> 00:22:05,397 Well, we just take any embedding in the grid. 423 00:22:05,397 --> 00:22:07,730 It's well known that if you have a max degree four graph 424 00:22:07,730 --> 00:22:10,270 you can draw it in the grid without crossings, 425 00:22:10,270 --> 00:22:12,580 and each edge is some orthogonal polyline. 426 00:22:15,530 --> 00:22:17,990 I won't prove that here. 427 00:22:17,990 --> 00:22:22,130 And then suppose the parity's wrong for some vertex. 428 00:22:22,130 --> 00:22:25,560 Suppose you draw vertex B and it happens to be black, 429 00:22:25,560 --> 00:22:27,320 but you want it to be white? 430 00:22:27,320 --> 00:22:29,310 Then I'm just going to shift it over by one 431 00:22:29,310 --> 00:22:32,710 and do these kinds of wiggles, and that's it. 432 00:22:32,710 --> 00:22:35,610 So you scale everything by a factor of three 433 00:22:35,610 --> 00:22:38,010 and you'll have room to do those wiggles. 434 00:22:38,010 --> 00:22:40,500 So take an arbitrary orthogonal grid drawing 435 00:22:40,500 --> 00:22:44,615 and then add the wiggles whenever 436 00:22:44,615 --> 00:22:46,740 things are in the wrong parity and now every vertex 437 00:22:46,740 --> 00:22:48,970 will be in the correct parity. 438 00:22:48,970 --> 00:22:52,730 That will be crucial for the reduction. 439 00:22:52,730 --> 00:22:57,830 So at this point we've got an orthogonal parity-preserving 440 00:22:57,830 --> 00:23:02,760 drawing of our given bipartite planar max degree three graph. 441 00:23:02,760 --> 00:23:06,760 And the issue is there are sort of two types of vertices here. 442 00:23:06,760 --> 00:23:09,169 There's the ones there we really need to visit, 443 00:23:09,169 --> 00:23:10,710 and then there's these other vertices 444 00:23:10,710 --> 00:23:12,890 which are representing edges. 445 00:23:12,890 --> 00:23:15,560 We don't need to visit every edge-- that's the tour problem. 446 00:23:15,560 --> 00:23:18,830 Hamiltonian tour, we just need to visit every vertex which 447 00:23:18,830 --> 00:23:22,030 are the labeled dots over here. 448 00:23:22,030 --> 00:23:25,730 So this is where things get fun. 449 00:23:25,730 --> 00:23:30,190 Here is a key gadget before we see the overall architecture. 450 00:23:30,190 --> 00:23:32,597 These are called tentacles in the original paper. 451 00:23:32,597 --> 00:23:34,680 I'm calling them edge gadgets because they're just 452 00:23:34,680 --> 00:23:37,210 simulating a single edge of the original graph, 453 00:23:37,210 --> 00:23:38,610 but tentacles is cooler. 454 00:23:38,610 --> 00:23:40,530 Whichever you prefer. 455 00:23:40,530 --> 00:23:43,400 So these are the dots that haven't all 456 00:23:43,400 --> 00:23:45,570 been drawn explicitly here. 457 00:23:45,570 --> 00:23:48,330 And so it's just like a two by and sort of corridor. 458 00:23:48,330 --> 00:23:53,160 The base version would be this, but if you want to have turns, 459 00:23:53,160 --> 00:23:54,910 which we're going to need 90 degree turns, 460 00:23:54,910 --> 00:23:57,050 it looks more like this. 461 00:23:57,050 --> 00:23:59,170 And there's basically two ways to cover this. 462 00:23:59,170 --> 00:24:00,080 Sort of three ways. 463 00:24:00,080 --> 00:24:01,940 But the way parity will work out, 464 00:24:01,940 --> 00:24:04,280 there will only be two ways that we care about. 465 00:24:04,280 --> 00:24:06,695 There's not a variable gadget. 466 00:24:06,695 --> 00:24:09,330 It looks like maybe a variable gadget, 467 00:24:09,330 --> 00:24:11,380 but that's not how we're using it. 468 00:24:11,380 --> 00:24:15,340 So one way you can visit this gadget is to zigzag like this. 469 00:24:15,340 --> 00:24:18,500 We've seen this in pretty much all of our planar 470 00:24:18,500 --> 00:24:20,270 Hamiltonicity proofs. 471 00:24:20,270 --> 00:24:22,460 The core idea's the same. 472 00:24:22,460 --> 00:24:27,000 You could start at A and end at C, or you could start at B 473 00:24:27,000 --> 00:24:29,815 and end at D, and that's true in this version as well. 474 00:24:29,815 --> 00:24:31,190 Once you start alternating you're 475 00:24:31,190 --> 00:24:32,590 forced to alternate all the way through. 476 00:24:32,590 --> 00:24:34,630 So you could imagine using that for a wire, 477 00:24:34,630 --> 00:24:36,730 but we're not going to use the two alternations. 478 00:24:36,730 --> 00:24:39,580 By parity we'll be forced to do it one way or the other. 479 00:24:39,580 --> 00:24:42,000 We'll be told whether we're starting or ending 480 00:24:42,000 --> 00:24:45,830 in one of them, I think. 481 00:24:45,830 --> 00:24:47,379 Well, it won't matter. 482 00:24:47,379 --> 00:24:49,170 But there's this other way you could visit, 483 00:24:49,170 --> 00:24:51,162 which is to just go all the way down then come 484 00:24:51,162 --> 00:24:51,870 all the way back. 485 00:24:55,260 --> 00:24:57,920 This is going to correspond to an edge that 486 00:24:57,920 --> 00:25:00,600 is in the Hamiltonian cycle. 487 00:25:00,600 --> 00:25:03,020 Because I want to start at some vertex up here, 488 00:25:03,020 --> 00:25:06,530 and I want to end at some vertex down here if I follow the edge. 489 00:25:06,530 --> 00:25:10,760 This is going to correspond to an edge that we don't use. 490 00:25:10,760 --> 00:25:13,360 Because at this vertex, I still need 491 00:25:13,360 --> 00:25:15,866 to cover these vertices somehow, but I don't 492 00:25:15,866 --> 00:25:16,990 want that to really matter. 493 00:25:16,990 --> 00:25:19,210 I want this edge to be coverable for free. 494 00:25:19,210 --> 00:25:21,810 So the idea is as I visit this vertex we're just going 495 00:25:21,810 --> 00:25:23,530 to zip down here, zip back up. 496 00:25:23,530 --> 00:25:27,530 And all these vertices get visited for free. 497 00:25:27,530 --> 00:25:30,270 It's not really part of the tour. 498 00:25:30,270 --> 00:25:33,420 Let me show you in some more detail. 499 00:25:33,420 --> 00:25:35,050 Here's what a vertex looks like. 500 00:25:35,050 --> 00:25:39,940 Vertex is just going to be a 3 by 3 grid of dots. 501 00:25:39,940 --> 00:25:42,120 Now, remember there are two kinds of vertices. 502 00:25:42,120 --> 00:25:44,630 There's the ones that were-- so again, 503 00:25:44,630 --> 00:25:47,470 we're expanding everything for this to work out. 504 00:25:47,470 --> 00:25:49,370 The vertices that were originally white 505 00:25:49,370 --> 00:25:51,326 and the vertices that were originally black. 506 00:25:51,326 --> 00:25:52,700 It doesn't matter which is which, 507 00:25:52,700 --> 00:25:54,930 but there's two classes of vertices. 508 00:25:54,930 --> 00:25:59,720 And we're going to attach the edge gadgets, which were 509 00:25:59,720 --> 00:26:02,390 these 2 by n kind of things. 510 00:26:02,390 --> 00:26:05,220 So this is all edge gadget here. 511 00:26:05,220 --> 00:26:07,740 We're going to attach it to a vertex that's 512 00:26:07,740 --> 00:26:13,370 white in this sort of flush length two connection. 513 00:26:13,370 --> 00:26:16,140 So this is the variable up here, this 3 by 3 thing, 514 00:26:16,140 --> 00:26:21,150 and here we're having two edges connecting to the edge gadget. 515 00:26:21,150 --> 00:26:22,770 For the black vertices we're only 516 00:26:22,770 --> 00:26:25,050 going to have a single edge connecting them. 517 00:26:25,050 --> 00:26:29,350 This is called a pin connection, between the wire 518 00:26:29,350 --> 00:26:33,650 gadget or the tentacle, and the 3 by 3 down here. 519 00:26:33,650 --> 00:26:34,300 OK. 520 00:26:34,300 --> 00:26:34,800 Why? 521 00:26:37,410 --> 00:26:40,240 Because. 522 00:26:40,240 --> 00:26:43,420 So here let's consider two vertices 523 00:26:43,420 --> 00:26:45,750 that are attached by an edge. 524 00:26:45,750 --> 00:26:47,050 So they have opposite parity. 525 00:26:47,050 --> 00:26:49,170 One's-- I've forgotten which is which. 526 00:26:49,170 --> 00:26:51,287 This is white and this black I think. 527 00:26:51,287 --> 00:26:52,620 Here we have the pin connection. 528 00:26:52,620 --> 00:26:55,200 Here we have the length two connection. 529 00:26:55,200 --> 00:26:58,280 And the idea is there's exactly two ways to traverse this edge, 530 00:26:58,280 --> 00:26:59,091 as we saw. 531 00:26:59,091 --> 00:27:00,590 But now you can see the connections. 532 00:27:00,590 --> 00:27:02,060 Let me put it that way. 533 00:27:02,060 --> 00:27:03,727 So the idea is, well, maybe you choose 534 00:27:03,727 --> 00:27:05,560 to use that edge in the cycle, and so I want 535 00:27:05,560 --> 00:27:07,340 to be able to just traverse it. 536 00:27:07,340 --> 00:27:08,500 Everything is good. 537 00:27:08,500 --> 00:27:10,130 And so here I know that I'm entering 538 00:27:10,130 --> 00:27:11,540 at this point, which means I know that I'll 539 00:27:11,540 --> 00:27:12,660 have to be exiting here. 540 00:27:12,660 --> 00:27:14,610 So the parities are forced. 541 00:27:14,610 --> 00:27:17,610 So the zigzag parity is forced. 542 00:27:17,610 --> 00:27:20,200 The other possibility, because there's only one connection 543 00:27:20,200 --> 00:27:23,980 here, you couldn't traverse this way and then come back. 544 00:27:23,980 --> 00:27:27,250 But from this side you could traverse and then come back. 545 00:27:27,250 --> 00:27:29,620 And it doesn't touch the vertex at all. 546 00:27:29,620 --> 00:27:32,370 So the idea is you could ignore this edge entirely 547 00:27:32,370 --> 00:27:35,765 and it gets covered for free, provided once you erase this, 548 00:27:35,765 --> 00:27:40,970 this edge is in the Hamiltonian tour. 549 00:27:40,970 --> 00:27:44,710 And at this point I should mention what all this labeling 550 00:27:44,710 --> 00:27:46,500 means on the vertex gadget. 551 00:27:46,500 --> 00:27:48,480 The idea is for this vertex, if you 552 00:27:48,480 --> 00:27:52,350 start at any of the PIs, any of the four corners-- 553 00:27:52,350 --> 00:27:55,700 any of the private investigators-- then 554 00:27:55,700 --> 00:28:01,450 you can end at any other PI, PJ in such a way 555 00:28:01,450 --> 00:28:03,710 that you visit all three of the EIs. 556 00:28:06,590 --> 00:28:08,030 AUDIENCE: There are four of them. 557 00:28:08,030 --> 00:28:09,571 ERIK DEMAINE: There are four of them. 558 00:28:09,571 --> 00:28:12,890 EI, EO, EIEI-O. No, OK. 559 00:28:12,890 --> 00:28:15,940 So let me get to the point. 560 00:28:15,940 --> 00:28:17,810 You could start at PI, end at PJ, 561 00:28:17,810 --> 00:28:23,620 and visit all the vertices and all of the EIs, all of the EKs. 562 00:28:23,620 --> 00:28:26,420 So for example, if I want to go from here to here, 563 00:28:26,420 --> 00:28:30,360 I can go like this, visited all the edges. 564 00:28:30,360 --> 00:28:32,530 If I want to go from here to here, 565 00:28:32,530 --> 00:28:36,530 I can go like this, visited all the vertices, 566 00:28:36,530 --> 00:28:38,530 visited all the EIs. 567 00:28:38,530 --> 00:28:41,560 So that's good because each of these EIs 568 00:28:41,560 --> 00:28:44,670 is potentially attached to an edge gadget 569 00:28:44,670 --> 00:28:46,950 and we might want to visit all of the things out there 570 00:28:46,950 --> 00:28:48,770 and come back. 571 00:28:48,770 --> 00:28:50,570 OK? 572 00:28:50,570 --> 00:28:58,740 So you see the reason why we only want a pin connection here 573 00:28:58,740 --> 00:29:02,480 is if we had a full connection with two edges, 574 00:29:02,480 --> 00:29:04,400 you might imagine that you come out here, 575 00:29:04,400 --> 00:29:07,120 do something, eventually do other stuff, 576 00:29:07,120 --> 00:29:09,039 and then come back on this path. 577 00:29:09,039 --> 00:29:10,830 But because we have a pin connection always 578 00:29:10,830 --> 00:29:13,820 on one of the two sides, you can't have 579 00:29:13,820 --> 00:29:15,710 two separate traversal paths. 580 00:29:15,710 --> 00:29:18,370 As soon as you get here you have to turn back around. 581 00:29:18,370 --> 00:29:19,870 If you went this way, then this guy 582 00:29:19,870 --> 00:29:23,230 would never be visible in a cycle. 583 00:29:23,230 --> 00:29:24,670 So that's the key thing. 584 00:29:24,670 --> 00:29:26,870 This was one of the EIs, and so the idea 585 00:29:26,870 --> 00:29:28,876 is you can completely forget about this path. 586 00:29:28,876 --> 00:29:30,500 You can just think about going from one 587 00:29:30,500 --> 00:29:31,961 of these white vertices to another. 588 00:29:31,961 --> 00:29:33,460 In general, it's going to correspond 589 00:29:33,460 --> 00:29:38,050 to which edge gadgets that vertex gadget is connected to. 590 00:29:42,502 --> 00:29:44,210 So you can go from one vertex to another. 591 00:29:44,210 --> 00:29:45,310 You will visit this edge. 592 00:29:45,310 --> 00:29:48,070 And so you can add in this part if you don't use the edge. 593 00:29:48,070 --> 00:29:49,632 If you do use the edge, then you'll 594 00:29:49,632 --> 00:29:51,465 be starting from one of these white vertices 595 00:29:51,465 --> 00:29:53,410 and you want to go to this one. 596 00:29:53,410 --> 00:29:55,239 And then you'll follow this path. 597 00:29:55,239 --> 00:29:56,780 And then you get to this vertex, then 598 00:29:56,780 --> 00:29:58,279 you'll go from one of black vertices 599 00:29:58,279 --> 00:30:01,020 to one of the other four corners, and so on. 600 00:30:01,020 --> 00:30:01,520 Question? 601 00:30:01,520 --> 00:30:04,280 AUDIENCE: Should that line of three white dots, 602 00:30:04,280 --> 00:30:06,030 shouldn't they all be black? 603 00:30:06,030 --> 00:30:08,170 ERIK DEMAINE: Yes, this should be black. 604 00:30:08,170 --> 00:30:09,040 It's not my fault. 605 00:30:09,040 --> 00:30:11,470 It could be the scanner or it could 606 00:30:11,470 --> 00:30:14,010 be-- this is a hand-drawn figure as you might guess. 607 00:30:14,010 --> 00:30:15,890 So yeah, that should be black. 608 00:30:15,890 --> 00:30:17,380 Everything should alternate. 609 00:30:17,380 --> 00:30:20,020 So you can tell the parity's a vertex based 610 00:30:20,020 --> 00:30:23,620 on the color of the corners. 611 00:30:23,620 --> 00:30:28,366 Any other questions about that proof? 612 00:30:28,366 --> 00:30:28,866 OK. 613 00:30:31,790 --> 00:30:33,910 So this is pretty cool. 614 00:30:33,910 --> 00:30:37,290 And I would say Hamiltonicity in grid graphs 615 00:30:37,290 --> 00:30:40,620 is used a lot as a base problem for reductions 616 00:30:40,620 --> 00:30:45,530 in computational geometry, especially tour-like problems. 617 00:30:45,530 --> 00:30:47,350 And you'll notice a theme. 618 00:30:47,350 --> 00:30:50,100 Every reduction so far, except the very first one I guess, 619 00:30:50,100 --> 00:30:51,880 was from one type of Hamiltonian circuit 620 00:30:51,880 --> 00:30:53,505 to another type of Hamiltonian circuit. 621 00:30:53,505 --> 00:30:57,287 And this tends to be common that you can work within Hamiltonian 622 00:30:57,287 --> 00:30:59,370 circuit and modify your graph in all sorts of ways 623 00:30:59,370 --> 00:31:02,440 to get to a very simplified version of Hamiltonian circuit. 624 00:31:02,440 --> 00:31:04,270 And that's cool. 625 00:31:04,270 --> 00:31:07,320 And so you get a lot of mileage just within the Hamiltonian 626 00:31:07,320 --> 00:31:08,565 circuit family. 627 00:31:12,160 --> 00:31:12,710 Cool. 628 00:31:12,710 --> 00:31:16,420 Let me give you a couple of applications right off the bat. 629 00:31:16,420 --> 00:31:17,280 What? 630 00:31:17,280 --> 00:31:19,030 AUDIENCE: This is going back a little bit, 631 00:31:19,030 --> 00:31:22,600 but are there any sort of natural families of graphs 632 00:31:22,600 --> 00:31:24,340 for which finding a Hamiltonian path 633 00:31:24,340 --> 00:31:26,490 is strictly easier than finding a circle? 634 00:31:29,420 --> 00:31:33,450 ERIK DEMAINE: I think the only-- this problem would be easy. 635 00:31:33,450 --> 00:31:35,580 Find a Hamiltonian path given a Hamiltonian path. 636 00:31:35,580 --> 00:31:40,300 But I'm not aware of any other problems where a Hamiltonian 637 00:31:40,300 --> 00:31:43,360 path is easier than cycle. 638 00:31:43,360 --> 00:31:44,940 I mean in general, you can reduce one 639 00:31:44,940 --> 00:31:47,250 to the other somehow. 640 00:31:47,250 --> 00:31:49,990 That's maybe a little tricky without the two given end 641 00:31:49,990 --> 00:31:52,090 points. 642 00:31:52,090 --> 00:31:53,830 And if you have lots of structure, 643 00:31:53,830 --> 00:31:57,120 like planarity and through regularity it's not so clear, 644 00:31:57,120 --> 00:31:59,950 but definitely Hamiltonian path is still hard in this problem. 645 00:31:59,950 --> 00:32:02,880 I think one easy way to do that is 646 00:32:02,880 --> 00:32:05,220 to just do the same chain of reductions, 647 00:32:05,220 --> 00:32:08,030 but start with Hamiltonian path instead of cycle 648 00:32:08,030 --> 00:32:10,240 and follow through, and pretty much every step 649 00:32:10,240 --> 00:32:13,020 should still be path-based. 650 00:32:13,020 --> 00:32:14,880 So it's actually useful. 651 00:32:14,880 --> 00:32:19,010 We'll want Hamiltonian path and grid graphs also at some point. 652 00:32:19,010 --> 00:32:21,429 But what I showed was Hamiltonian cycle. 653 00:32:21,429 --> 00:32:23,720 So for pretty much everywhere they seem to be the same, 654 00:32:23,720 --> 00:32:25,594 but it would be cool to find an example where 655 00:32:25,594 --> 00:32:28,790 they have different complexity. 656 00:32:28,790 --> 00:32:30,170 OK. 657 00:32:30,170 --> 00:32:32,916 So here's another problem. 658 00:32:32,916 --> 00:32:34,130 Euclidean TSP. 659 00:32:39,330 --> 00:32:40,970 Traveling salesman problem. 660 00:32:40,970 --> 00:32:45,300 You're given a set of points in the plane. 661 00:32:45,300 --> 00:32:48,810 Better not make it too big because this might be hard. 662 00:32:48,810 --> 00:32:52,185 And I want to find a tour. 663 00:32:52,185 --> 00:32:55,270 It visits every point exactly once, 664 00:32:55,270 --> 00:32:58,700 and has minimum total length, Euclidean length. 665 00:32:58,700 --> 00:33:02,066 So the usual notion of length. 666 00:33:02,066 --> 00:33:04,260 I claim this is NP-hard. 667 00:33:04,260 --> 00:33:05,496 Now, this is a little scary. 668 00:33:05,496 --> 00:33:08,120 Most of the problems we've been working with are very discrete. 669 00:33:08,120 --> 00:33:09,911 I mean the output here is sort of discrete. 670 00:33:09,911 --> 00:33:13,090 You choose a permutation on the points. 671 00:33:13,090 --> 00:33:15,880 But it feels like there's almost no control here. 672 00:33:15,880 --> 00:33:18,720 I mean how would I construct localized gadgets when 673 00:33:18,720 --> 00:33:22,100 I can just jump from any point to any other point at any time 674 00:33:22,100 --> 00:33:25,190 as long as that point hasn't already been used. 675 00:33:25,190 --> 00:33:27,760 But it's really easy to prove this is NP-hard 676 00:33:27,760 --> 00:33:29,920 given what we just did. 677 00:33:29,920 --> 00:33:33,814 Oh, I should say, here's a full worked out example, 678 00:33:33,814 --> 00:33:35,480 so this is what I should be pointing at. 679 00:33:35,480 --> 00:33:41,430 This was the parity-preserving graph that we drew before. 680 00:33:41,430 --> 00:33:44,190 And this is what you get in the reduction, 681 00:33:44,190 --> 00:33:46,230 along with actual solution, which is 682 00:33:46,230 --> 00:33:49,880 the one drawn in orange here. 683 00:33:49,880 --> 00:33:52,960 So you can see read that off, because wherever 684 00:33:52,960 --> 00:33:57,530 you see zigzags, that's where you're using the path here. 685 00:33:57,530 --> 00:34:02,130 So these correspond, and then this corresponds. 686 00:34:02,130 --> 00:34:04,000 And then up and over. 687 00:34:04,000 --> 00:34:08,400 And then the unused edges, the not orange ones, 688 00:34:08,400 --> 00:34:10,870 that's where we get these kinds of loops, 689 00:34:10,870 --> 00:34:14,810 starting from the vertices of one parity, 690 00:34:14,810 --> 00:34:18,460 I guess the white ones, and then going to the black ones 691 00:34:18,460 --> 00:34:21,770 and turning around at the pin joint. 692 00:34:21,770 --> 00:34:22,800 Cool. 693 00:34:22,800 --> 00:34:26,654 So given this is hard, why is this hard? 694 00:34:30,170 --> 00:34:32,190 So the decision problem, let's say, 695 00:34:32,190 --> 00:34:34,010 is I give you a set of points. 696 00:34:34,010 --> 00:34:36,630 I give you the desired length of the tour. 697 00:34:36,630 --> 00:34:39,900 I want to know is there a tour, visits every point exactly 698 00:34:39,900 --> 00:34:44,066 once, and has length at most that given length. 699 00:34:44,066 --> 00:34:48,467 AUDIENCE: So if you look at a grid graph, 700 00:34:48,467 --> 00:34:50,284 you'll have some number of nodes, 701 00:34:50,284 --> 00:34:53,124 which means the tour would have to necessarily have-- it 702 00:34:53,124 --> 00:34:54,900 can just choose those points. 703 00:34:54,900 --> 00:34:57,090 The tour would necessarily have at least-- exactly 704 00:34:57,090 --> 00:35:00,562 that many edges, and each edge would 705 00:35:00,562 --> 00:35:02,370 have to have length at least one, 706 00:35:02,370 --> 00:35:06,010 because the close [INAUDIBLE] points is one apart. 707 00:35:06,010 --> 00:35:06,760 ERIK DEMAINE: Yup. 708 00:35:06,760 --> 00:35:08,759 AUDIENCE: And so if you just counter [INAUDIBLE] 709 00:35:08,759 --> 00:35:11,327 those points and say that that's the desired 710 00:35:11,327 --> 00:35:12,910 length of your tour, then you can only 711 00:35:12,910 --> 00:35:15,410 do that if you can get through this by following only edges 712 00:35:15,410 --> 00:35:16,724 that are length one. 713 00:35:16,724 --> 00:35:17,640 ERIK DEMAINE: Exactly. 714 00:35:17,640 --> 00:35:20,560 So we're going to reduce from this problem. 715 00:35:20,560 --> 00:35:23,620 Given such a grid graph, the reduction 716 00:35:23,620 --> 00:35:26,080 just looks at the vertices, throws away the edges. 717 00:35:26,080 --> 00:35:31,280 That is our input-- those points are the input to TSP. 718 00:35:31,280 --> 00:35:34,200 And then the claim is that every tour-- 719 00:35:34,200 --> 00:35:36,620 let's say there are end points in this picture. 720 00:35:36,620 --> 00:35:38,862 Every tour has to have length at least n, as you say, 721 00:35:38,862 --> 00:35:41,070 because they're end points, the total number of edges 722 00:35:41,070 --> 00:35:44,010 is n in a cycle, a Hamiltonian cycle, 723 00:35:44,010 --> 00:35:47,520 and every edge must have length at least one, 724 00:35:47,520 --> 00:35:49,600 because that's the nearest pair. 725 00:35:49,600 --> 00:35:52,311 And so that's a lower bound. 726 00:35:52,311 --> 00:35:53,810 And then on the other hand, if there 727 00:35:53,810 --> 00:35:58,437 is a tour that has length only n, 728 00:35:58,437 --> 00:36:00,270 then it must actually be a Hamiltonian cycle 729 00:36:00,270 --> 00:36:02,280 in this graph, because then you're 730 00:36:02,280 --> 00:36:04,837 only using edges that exist in the grid graph. 731 00:36:04,837 --> 00:36:06,170 So it's really the same problem. 732 00:36:06,170 --> 00:36:08,670 Euclidean TSP really is a special case of this. 733 00:36:11,780 --> 00:36:14,310 Cool. 734 00:36:14,310 --> 00:36:16,190 This problem was proved hard much earlier. 735 00:36:18,890 --> 00:36:22,710 Hamiltonicity and grid graph. 736 00:36:26,100 --> 00:36:29,700 But here is now a nice simple proof using what we know. 737 00:36:32,580 --> 00:36:36,200 I'll tell you more reasons in a little bit, 738 00:36:36,200 --> 00:36:40,870 but I have one more at this point, which is platform games. 739 00:36:44,830 --> 00:36:46,560 I don't have a graphic because there's 740 00:36:46,560 --> 00:36:49,790 so many games that could apply here, 741 00:36:49,790 --> 00:36:51,790 Super Mario Brothers among them. 742 00:36:51,790 --> 00:36:56,440 Suppose you have a little dude, you can walk around. 743 00:36:56,440 --> 00:36:59,630 And you've got some kind of coins-- 744 00:36:59,630 --> 00:37:01,290 I don't know how to draw coins. 745 00:37:01,290 --> 00:37:02,630 They almost look like eyeballs. 746 00:37:02,630 --> 00:37:04,840 But anyway, you've got a bunch of coins 747 00:37:04,840 --> 00:37:07,712 which you want to collect. 748 00:37:07,712 --> 00:37:09,670 And you have some way that you can walk around. 749 00:37:09,670 --> 00:37:11,790 If you're a top-down game, then that's 750 00:37:11,790 --> 00:37:14,450 pretty much the entire reduction. 751 00:37:14,450 --> 00:37:17,890 And then also you have a timer. 752 00:37:17,890 --> 00:37:26,490 So timer plus collectibles-- ables or ibles? 753 00:37:26,490 --> 00:37:28,630 Ables. 754 00:37:28,630 --> 00:37:34,160 And any such game is NP-hard, at least, 755 00:37:34,160 --> 00:37:36,520 because if you want to get all of these coins, that's 756 00:37:36,520 --> 00:37:38,350 like vertices you need to visit. 757 00:37:38,350 --> 00:37:41,930 As I say, a top-down game you're walking in a grid graph. 758 00:37:41,930 --> 00:37:45,580 The time limit will prevent us from going out 759 00:37:45,580 --> 00:37:48,141 into the white space because there's no coins there. 760 00:37:48,141 --> 00:37:50,640 And so if the timeline limit is exactly the number of coins, 761 00:37:50,640 --> 00:37:53,170 and every step you make you have to get a coin, 762 00:37:53,170 --> 00:37:56,950 then that will force you to only follow-- the edges in the grid 763 00:37:56,950 --> 00:37:59,165 graph can't go out here. 764 00:37:59,165 --> 00:38:01,990 No obstacles needed. 765 00:38:01,990 --> 00:38:04,410 And you understand that in the real game, of course, 766 00:38:04,410 --> 00:38:06,010 there might be stuff happening here. 767 00:38:06,010 --> 00:38:08,985 Maybe there's a ladder so you can go up here. 768 00:38:08,985 --> 00:38:11,110 You just have to set up all these traversal lengths 769 00:38:11,110 --> 00:38:14,652 to take the same amount of time in under optimal play. 770 00:38:14,652 --> 00:38:17,110 And then you can simulate a ton of video games in this way. 771 00:38:20,330 --> 00:38:22,120 This is a result. 772 00:38:22,120 --> 00:38:26,290 This is in Fun 2010 by Forishek. 773 00:38:26,290 --> 00:38:28,530 So some reasons why you care. 774 00:38:28,530 --> 00:38:31,650 A lot of games map naturally onto grids. 775 00:38:31,650 --> 00:38:36,620 A lot of real problems can map onto grids. 776 00:38:36,620 --> 00:38:38,270 In general, grids will be very helpful. 777 00:38:42,110 --> 00:38:47,750 So next problem I want to solve is-- 778 00:38:47,750 --> 00:38:52,250 by solve, I mean show hard, as usual. 779 00:38:52,250 --> 00:38:58,715 Let's say, max degree three grid graphs. 780 00:39:03,670 --> 00:39:05,500 I don't have a great motivation-- well, 781 00:39:05,500 --> 00:39:07,650 I have a motivation for this. 782 00:39:07,650 --> 00:39:09,250 Probably others that I'm not aware of. 783 00:39:09,250 --> 00:39:12,300 I didn't actually know about this result until recently. 784 00:39:12,300 --> 00:39:13,420 It's pretty cool. 785 00:39:13,420 --> 00:39:15,829 If you look at this reduction, there are some vertices 786 00:39:15,829 --> 00:39:17,620 that-- I mean here we're drawing the cycle, 787 00:39:17,620 --> 00:39:19,240 but some vertices have degree four. 788 00:39:19,240 --> 00:39:23,270 Of course, every grid graph is max degree four. 789 00:39:23,270 --> 00:39:28,440 And max degree two is pretty easy to solve Hamiltonicity. 790 00:39:28,440 --> 00:39:30,600 So what's left is max degree three. 791 00:39:30,600 --> 00:39:33,230 So a natural question in between is can you do max degree 792 00:39:33,230 --> 00:39:34,485 three grid graphs. 793 00:39:34,485 --> 00:39:36,870 The claim is that is also hard. 794 00:39:36,870 --> 00:39:38,890 And it's going to be basically the same proof, 795 00:39:38,890 --> 00:39:43,507 but we're going to change all the gadgets, most of them. 796 00:39:43,507 --> 00:39:44,590 There's one shared author. 797 00:39:44,590 --> 00:39:47,900 This was Eti Papadimitriou and Szwarcfiter. 798 00:39:50,620 --> 00:39:53,890 And then this is Papadimitriou and Vazirani 799 00:39:53,890 --> 00:39:55,860 a couple years later. 800 00:39:55,860 --> 00:39:59,815 So this is actually very similar to the edge 801 00:39:59,815 --> 00:40:00,690 gadget we saw before. 802 00:40:00,690 --> 00:40:03,730 Here's the old edge gadget. 803 00:40:03,730 --> 00:40:06,430 Before when we had a turn we had a degree four vertex. 804 00:40:06,430 --> 00:40:08,940 I want to get rid of that, and I'm going to get rid of it 805 00:40:08,940 --> 00:40:11,880 by just sort of shifting these things apart and blowing up 806 00:40:11,880 --> 00:40:14,240 this circle, this cycle. 807 00:40:14,240 --> 00:40:16,430 So I end up with a bigger cycle here, 808 00:40:16,430 --> 00:40:18,240 end up with an edge connection there. 809 00:40:18,240 --> 00:40:22,020 But effectively, it's the same kind of topology. 810 00:40:22,020 --> 00:40:26,932 If you're coming in and alternating-- 811 00:40:26,932 --> 00:40:28,640 I guess you have to get the parity right. 812 00:40:28,640 --> 00:40:31,190 If you're coming in from this side and you're alternating, 813 00:40:31,190 --> 00:40:33,930 then you can come around and visit like that, 814 00:40:33,930 --> 00:40:36,090 and everything is OK. 815 00:40:36,090 --> 00:40:38,450 Back and forth. 816 00:40:38,450 --> 00:40:39,260 Cool. 817 00:40:39,260 --> 00:40:41,150 That was drawn right over here. 818 00:40:41,150 --> 00:40:42,080 That's a zigzag path. 819 00:40:42,080 --> 00:40:44,570 The return path is just as before. 820 00:40:44,570 --> 00:40:47,550 And so we can use this edge gadget exactly 821 00:40:47,550 --> 00:40:51,810 as we did before, but now it's max degree three everywhere. 822 00:40:51,810 --> 00:40:52,520 So that's easy. 823 00:40:52,520 --> 00:40:55,420 In general, using this trick that here 824 00:40:55,420 --> 00:40:57,980 we had a corner with a vertex on it. 825 00:40:57,980 --> 00:40:59,574 You can turn that into a longer path 826 00:40:59,574 --> 00:41:00,740 with various vertices on it. 827 00:41:00,740 --> 00:41:03,750 That will act the same from a Hamiltonicity perspective. 828 00:41:03,750 --> 00:41:05,250 So that's the key thing we're doing. 829 00:41:05,250 --> 00:41:08,475 And then it's a matter of putting things 830 00:41:08,475 --> 00:41:11,310 to fit on the grid. 831 00:41:11,310 --> 00:41:13,689 So that's the first change. 832 00:41:13,689 --> 00:41:15,980 Now, the second change is going to be a little bit more 833 00:41:15,980 --> 00:41:18,630 drastic, a little weirder. 834 00:41:18,630 --> 00:41:21,420 The vertex gadget used to be this 3 by 3 thing. 835 00:41:21,420 --> 00:41:23,270 Very hard to get rid of that, vertex 836 00:41:23,270 --> 00:41:25,590 would have to be four in the center. 837 00:41:25,590 --> 00:41:27,670 Well, if you did that, you would be 838 00:41:27,670 --> 00:41:30,720 left with a little square, an empty square. 839 00:41:30,720 --> 00:41:33,980 And we're going to need two of those. 840 00:41:33,980 --> 00:41:37,760 So this is the dumbbell picture used 841 00:41:37,760 --> 00:41:40,350 in many theoretical results. 842 00:41:40,350 --> 00:41:43,670 So we have two of these squares. 843 00:41:43,670 --> 00:41:46,240 We're going to separate them by a fairly long path 844 00:41:46,240 --> 00:41:48,330 of the right parity. 845 00:41:48,330 --> 00:41:51,850 And the idea is you can have up to two connections over here 846 00:41:51,850 --> 00:41:54,190 to edges, and up to two connections over here 847 00:41:54,190 --> 00:41:55,960 for edges. 848 00:41:55,960 --> 00:41:57,940 And typical connections are going 849 00:41:57,940 --> 00:42:00,750 to look just like we had before, but it's not 850 00:42:00,750 --> 00:42:02,550 going quite all be like this. 851 00:42:02,550 --> 00:42:05,830 So it used to be we could have a full edge connection 852 00:42:05,830 --> 00:42:12,040 or we could have a pin connection as before. 853 00:42:12,040 --> 00:42:15,010 When this edge turns it's going to use the weirder turn gadget. 854 00:42:15,010 --> 00:42:17,780 So the edges look basically the same, 855 00:42:17,780 --> 00:42:21,090 it's just the turns that we changed in the last slide. 856 00:42:21,090 --> 00:42:23,790 OK. 857 00:42:23,790 --> 00:42:28,650 This almost works, but I have to specify some details. 858 00:42:28,650 --> 00:42:31,070 So for example, easy case. 859 00:42:31,070 --> 00:42:33,020 Degree two vertex. 860 00:42:33,020 --> 00:42:35,520 Suppose the original graph has a degree two vertex-- 861 00:42:35,520 --> 00:42:37,740 we had that in our reduction. 862 00:42:37,740 --> 00:42:40,030 Because in fact, every other vertex pretty much 863 00:42:40,030 --> 00:42:44,622 was degree two, if you track all of these things. 864 00:42:44,622 --> 00:42:46,080 When we went from the directed case 865 00:42:46,080 --> 00:42:48,220 to the bipartite case we added in lots of vertices, 866 00:42:48,220 --> 00:42:49,630 lots of degree two vertices. 867 00:42:49,630 --> 00:42:52,170 So if we want to simulate a degree two vertex, 868 00:42:52,170 --> 00:42:55,930 we will just have one of the edges attaching up here, 869 00:42:55,930 --> 00:42:58,360 and one of the edges attaching down here. 870 00:42:58,360 --> 00:43:02,550 And again-- in this picture it's one on the left side, 871 00:43:02,550 --> 00:43:03,810 one on the right side. 872 00:43:03,810 --> 00:43:05,610 And again, we have this feature that if we 873 00:43:05,610 --> 00:43:10,850 start at any of the PIs we can get to one of the PJs 874 00:43:10,850 --> 00:43:14,920 by visiting all the EI edges. 875 00:43:14,920 --> 00:43:19,705 So for example, if we start here we go like this over here. 876 00:43:19,705 --> 00:43:20,580 And we have a choice. 877 00:43:20,580 --> 00:43:23,070 We can either go like this, end at P3 or go like this 878 00:43:23,070 --> 00:43:23,770 and end at P4. 879 00:43:23,770 --> 00:43:26,170 We visited all the EIs. 880 00:43:26,170 --> 00:43:29,500 But we can't start at P1 and end at P2. 881 00:43:29,500 --> 00:43:31,050 We want to visit everything. 882 00:43:31,050 --> 00:43:32,100 Start at P1. 883 00:43:32,100 --> 00:43:34,710 If you go out there, you can never come back. 884 00:43:34,710 --> 00:43:37,510 To come around here, you've already visited P2. 885 00:43:37,510 --> 00:43:40,150 So we cannot start and end on the left side. 886 00:43:40,150 --> 00:43:42,090 We cannot start and end on the right side. 887 00:43:42,090 --> 00:43:43,864 So for a degree two vertex, that's fine. 888 00:43:43,864 --> 00:43:45,280 We just put one of the connections 889 00:43:45,280 --> 00:43:48,620 on one side, one on the other, and we'll come in, 890 00:43:48,620 --> 00:43:50,110 visit everything, come out. 891 00:43:50,110 --> 00:43:52,220 And because we visit all the EIs, 892 00:43:52,220 --> 00:43:57,870 we can do this kind of traversal every time. 893 00:43:57,870 --> 00:44:00,374 Now, for a degree three vertex, this 894 00:44:00,374 --> 00:44:01,540 is a little bit troublesome. 895 00:44:04,150 --> 00:44:08,885 Remember our picture. 896 00:44:19,394 --> 00:44:21,060 What do degree three vertices look like? 897 00:44:21,060 --> 00:44:23,310 If you follow through the chain of reductions, 898 00:44:23,310 --> 00:44:30,760 we had this case, and we had this case, and this one 899 00:44:30,760 --> 00:44:35,490 we converted into that. 900 00:44:35,490 --> 00:44:45,001 And this one we converted into that I think. 901 00:44:45,001 --> 00:44:45,500 Yup. 902 00:44:45,500 --> 00:44:47,500 Because this was a forced edge. 903 00:44:47,500 --> 00:44:52,050 This was a forced edge and so we added a dot to represent that. 904 00:44:52,050 --> 00:44:54,720 So the good news is every time we have a degree three 905 00:44:54,720 --> 00:45:00,520 vertex in the starting graph, one of the edges is forced. 906 00:45:00,520 --> 00:45:01,987 One of the three edges is forced. 907 00:45:01,987 --> 00:45:04,153 So it's really a choice between do you take this one 908 00:45:04,153 --> 00:45:05,152 or do you take this one. 909 00:45:05,152 --> 00:45:08,160 I mean that's, of course, what we had over here. 910 00:45:08,160 --> 00:45:10,900 So what we're going to do is take these two edges, which 911 00:45:10,900 --> 00:45:12,750 are exclusively OR'd together. 912 00:45:12,750 --> 00:45:15,400 I choose exactly one of these. 913 00:45:15,400 --> 00:45:19,210 We're going to put that on one side, so that one of them 914 00:45:19,210 --> 00:45:22,350 will go up here, one of them will go down here. 915 00:45:22,350 --> 00:45:25,910 And then the forced edge we'll put over on the other side. 916 00:45:25,910 --> 00:45:27,570 Forced edge is always chosen, so that 917 00:45:27,570 --> 00:45:31,450 means we'll come in either P1 or P2, or leave on P1 or P2, 918 00:45:31,450 --> 00:45:33,710 depending on which of those two cases we're in. 919 00:45:33,710 --> 00:45:38,870 And then we will leave or enter from P3 or P4, 920 00:45:38,870 --> 00:45:43,761 according to which of the two edges you choose. 921 00:45:43,761 --> 00:45:44,260 Happy? 922 00:45:44,260 --> 00:45:44,910 No? 923 00:45:44,910 --> 00:45:45,810 AUDIENCE: I'm understanding that we're actually 924 00:45:45,810 --> 00:45:48,630 reducing from a sub-problem of [INAUDIBLE] bipartite, 925 00:45:48,630 --> 00:45:51,300 max degree three graphs in that every vertex is connected 926 00:45:51,300 --> 00:45:54,990 to at least one degree two vertex? 927 00:45:54,990 --> 00:45:57,220 ERIK DEMAINE: Yeah. 928 00:45:57,220 --> 00:45:57,720 Right. 929 00:45:57,720 --> 00:46:03,450 So we could say at this point-- in fact, it's planar 930 00:46:03,450 --> 00:46:07,110 bipartite max degree three graphs where every degree three 931 00:46:07,110 --> 00:46:11,270 vertex is adjacent to exactly one, or no, 932 00:46:11,270 --> 00:46:15,290 at least one degree two vertex. 933 00:46:15,290 --> 00:46:18,060 And then we can carry that condition 934 00:46:18,060 --> 00:46:19,810 through all the reductions, and that would 935 00:46:19,810 --> 00:46:21,740 make this an actual reduction. 936 00:46:21,740 --> 00:46:24,490 Or you can think of this as a reduction going from here, 937 00:46:24,490 --> 00:46:26,220 just copying all the details. 938 00:46:26,220 --> 00:46:26,720 Yeah. 939 00:46:29,244 --> 00:46:29,910 Other questions? 940 00:46:33,500 --> 00:46:35,510 OK. 941 00:46:35,510 --> 00:46:38,589 I'm a little confused because there's one more gadget. 942 00:46:38,589 --> 00:46:40,130 But I didn't seem to use that gadget. 943 00:46:40,130 --> 00:46:45,690 So I'm not sure whether this is necessary. 944 00:46:45,690 --> 00:46:48,182 But here's another thing you can do, 945 00:46:48,182 --> 00:46:49,890 which they're using for the forced edges. 946 00:46:49,890 --> 00:46:54,390 You can have one wire-- sorry, this is the picture. 947 00:46:54,390 --> 00:46:56,790 You can have one edge gadget that attaches 948 00:46:56,790 --> 00:46:59,420 to both ends of the dumbbell. 949 00:46:59,420 --> 00:47:02,080 So then you have a choice whether you end up 950 00:47:02,080 --> 00:47:06,540 connecting that edge to the bottom of the dumbbell 951 00:47:06,540 --> 00:47:09,980 or to the top of the dumbbell. 952 00:47:09,980 --> 00:47:11,170 Sorry. 953 00:47:11,170 --> 00:47:14,040 This is connecting to the top, and this is connecting 954 00:47:14,040 --> 00:47:16,060 to the bottom, the dumbbell. 955 00:47:16,060 --> 00:47:18,980 So that's another way to do the same kind of degree three 956 00:47:18,980 --> 00:47:19,480 vertex. 957 00:47:19,480 --> 00:47:23,550 You could have this guy coming in-- this is the forced edge, 958 00:47:23,550 --> 00:47:26,450 and the forced edge has to come to this vertex. 959 00:47:26,450 --> 00:47:29,090 You get a choice of whether you start up here and then leave 960 00:47:29,090 --> 00:47:33,420 along this non-forced edge, or you first 961 00:47:33,420 --> 00:47:35,510 traverse down this way and then leave along 962 00:47:35,510 --> 00:47:37,740 this non-forced edge. 963 00:47:37,740 --> 00:47:40,910 So that's another way to do it, but it seems just as good 964 00:47:40,910 --> 00:47:44,720 as the way I described, which was to put forced edge only 965 00:47:44,720 --> 00:47:48,130 a one side, and then the other two guys on the other side. 966 00:47:48,130 --> 00:47:49,970 Unless there's a parity issue. 967 00:47:49,970 --> 00:47:54,880 It could be that this connection and this connection 968 00:47:54,880 --> 00:47:59,580 have the opposite parities, which is not good. 969 00:47:59,580 --> 00:48:06,030 Because we want the two connections-- in this case, 970 00:48:06,030 --> 00:48:08,980 both of these are going to be white. 971 00:48:08,980 --> 00:48:11,270 And in this case both of these are going to be black. 972 00:48:11,270 --> 00:48:13,780 So the two non-forced edges connect 973 00:48:13,780 --> 00:48:16,260 to vertices of the same color. 974 00:48:16,260 --> 00:48:19,100 And I think if you try to attach one of them over here 975 00:48:19,100 --> 00:48:21,850 and one of them over here on a variable, 976 00:48:21,850 --> 00:48:24,570 they will have the wrong colors, they'll have opposite colors. 977 00:48:24,570 --> 00:48:26,430 I think that's why you need this gadget. 978 00:48:26,430 --> 00:48:30,580 Because now this left connection and this other left connection 979 00:48:30,580 --> 00:48:34,570 will have the same parity because this count is odd 980 00:48:34,570 --> 00:48:36,290 I think. 981 00:48:36,290 --> 00:48:38,620 I think that's why you need it. 982 00:48:38,620 --> 00:48:39,790 And that preserves parity. 983 00:48:39,790 --> 00:48:40,710 So it's a bit subtle. 984 00:48:40,710 --> 00:48:44,640 You have to be careful all the connections preserve parity. 985 00:48:44,640 --> 00:48:46,370 Cool. 986 00:48:46,370 --> 00:48:51,852 So that was max degree three grid graphs. 987 00:48:51,852 --> 00:48:52,685 Any other questions? 988 00:48:56,130 --> 00:49:00,740 Here is one motivation from this Papadimitriou/Vazirani paper 989 00:49:00,740 --> 00:49:15,080 for this problem related to Euclidean traveling salesman 990 00:49:15,080 --> 00:49:15,580 problem. 991 00:49:29,920 --> 00:49:32,630 It's this notion of degree-bounded minimum spanning 992 00:49:32,630 --> 00:49:33,340 tree. 993 00:49:33,340 --> 00:49:36,180 Minimum spanning tree normally is a polynomial problem. 994 00:49:36,180 --> 00:49:39,890 We're given some graph, you want to find a spanning tree. 995 00:49:39,890 --> 00:49:42,030 Tree that this is all the vertices, 996 00:49:42,030 --> 00:49:45,850 but it can be a tree instead of just a path. 997 00:49:45,850 --> 00:49:49,060 And it's minimum in that it has minimum total length of all 998 00:49:49,060 --> 00:49:49,560 the edges. 999 00:49:49,560 --> 00:49:51,700 So that's a polynomial problem. 1000 00:49:51,700 --> 00:49:54,270 If I say, well, I want a minimum spanning tree 1001 00:49:54,270 --> 00:49:58,060 where all of the vertices in the tree 1002 00:49:58,060 --> 00:50:01,996 have max degree two, that is Hamiltonian path, 1003 00:50:01,996 --> 00:50:03,870 or I guess really traveling salesman problem. 1004 00:50:03,870 --> 00:50:10,430 So we already proved Euclidean max degree two minimum spanning 1005 00:50:10,430 --> 00:50:11,300 tree is hard. 1006 00:50:11,300 --> 00:50:12,490 What about max degree three? 1007 00:50:12,490 --> 00:50:15,060 Does that somehow-- does the branching make it easier, 1008 00:50:15,060 --> 00:50:17,170 and the answer is no. 1009 00:50:17,170 --> 00:50:20,230 You start from this problem. 1010 00:50:20,230 --> 00:50:22,420 And the cool thing about a max degree 1011 00:50:22,420 --> 00:50:28,030 three grid graph is if you look at any point, at most three 1012 00:50:28,030 --> 00:50:32,870 of its neighboring spots are actual vertices. 1013 00:50:32,870 --> 00:50:36,000 One of them has to be absent in a max degree three. 1014 00:50:36,000 --> 00:50:42,880 So what I'm going to do is add a point really close to that one. 1015 00:50:42,880 --> 00:50:47,290 And now you can show in any minimum spanning tree, 1016 00:50:47,290 --> 00:50:51,962 these guys must be connected, and this one basically 1017 00:50:51,962 --> 00:50:54,170 has to be a leaf because everything else is quite far 1018 00:50:54,170 --> 00:50:55,130 away. 1019 00:50:55,130 --> 00:51:00,330 I mean at most you have these guys occupied. 1020 00:51:00,330 --> 00:51:02,850 You know that this is completely absent. 1021 00:51:02,850 --> 00:51:04,300 So I add this point. 1022 00:51:04,300 --> 00:51:05,910 I'm going to have to connect this. 1023 00:51:05,910 --> 00:51:09,200 it won't be able to connect any other way if I'm using 1024 00:51:09,200 --> 00:51:10,520 the shortest possible length. 1025 00:51:10,520 --> 00:51:13,510 And so at that point, if this has degree three, 1026 00:51:13,510 --> 00:51:16,300 there's only two incident edges left, 1027 00:51:16,300 --> 00:51:20,390 and so it's Hamiltonian path again in the grid graph. 1028 00:51:20,390 --> 00:51:23,550 So this is why they were motivated 1029 00:51:23,550 --> 00:51:26,950 to define max degree grid graphs and prove that hard. 1030 00:51:30,380 --> 00:51:31,250 Cool. 1031 00:51:31,250 --> 00:51:33,800 Some more geometry. 1032 00:51:33,800 --> 00:51:35,300 All right. 1033 00:51:35,300 --> 00:51:36,910 So for a long time-- you know, this 1034 00:51:36,910 --> 00:51:39,650 is all done in the '80s, all the grid graph stuff. 1035 00:51:39,650 --> 00:51:42,340 We only had square grids. 1036 00:51:42,340 --> 00:51:46,630 We couldn't afford triangles back in the day. 1037 00:51:46,630 --> 00:51:50,220 But recently, people started to think about triangular grids 1038 00:51:50,220 --> 00:51:51,040 and hex grids. 1039 00:51:51,040 --> 00:51:53,620 Those are the only tiling regular n-gons. 1040 00:51:53,620 --> 00:51:56,460 So you can define the same kind of thing. 1041 00:51:56,460 --> 00:51:58,790 A triangular grid graph, a hexagonal grid graph. 1042 00:51:58,790 --> 00:52:02,170 Again, you take a set of points in the triangular 1043 00:52:02,170 --> 00:52:03,935 lattice or the hex lattice. 1044 00:52:03,935 --> 00:52:05,930 Is the hex actually a lattice? 1045 00:52:05,930 --> 00:52:08,750 Well, anyway, you know what I mean, the hex grid. 1046 00:52:08,750 --> 00:52:13,630 And you connect any two points when 1047 00:52:13,630 --> 00:52:16,430 they're a unit distance apart, where that's 1048 00:52:16,430 --> 00:52:18,990 defined to be one and one. 1049 00:52:18,990 --> 00:52:22,160 So again, we have the notion of solid, triangular, or hex grid 1050 00:52:22,160 --> 00:52:23,520 graph, and there are no holes. 1051 00:52:23,520 --> 00:52:26,620 Again, we can characterize the pixels-- they're not really 1052 00:52:26,620 --> 00:52:29,430 pixels-- hexels and trigles? 1053 00:52:29,430 --> 00:52:30,590 I don't know. 1054 00:52:30,590 --> 00:52:32,580 In the paper they're all just called pixels. 1055 00:52:32,580 --> 00:52:34,180 There's those types of faces. 1056 00:52:34,180 --> 00:52:35,510 There's the outside face. 1057 00:52:35,510 --> 00:52:41,400 And then there's the hole faces-- H-O-L-E, not W-H-O-L-E. 1058 00:52:41,400 --> 00:52:43,690 OK. 1059 00:52:43,690 --> 00:52:45,190 Cool. 1060 00:52:45,190 --> 00:52:47,840 They define some other terms, which I will get to. 1061 00:52:55,330 --> 00:52:58,425 Let me tell you what's known about all of these problems. 1062 00:53:10,060 --> 00:53:33,800 So first thing, so these are-- So first thing that's known 1063 00:53:33,800 --> 00:53:38,090 is that if you have a solid grid graph, 1064 00:53:38,090 --> 00:53:41,330 then the triangular case is also polynomial. 1065 00:53:41,330 --> 00:53:45,110 So I mentioned solid square grid graphs are 1066 00:53:45,110 --> 00:53:46,850 easy to solve Hamiltonicity in. 1067 00:53:46,850 --> 00:53:48,650 Turns out solid triangular grid graphs 1068 00:53:48,650 --> 00:53:52,410 are also easy to solve grid graphs-- solve Hamiltonicity 1069 00:53:52,410 --> 00:53:52,910 in. 1070 00:53:52,910 --> 00:53:55,511 Almost all of them are Hamiltonian in a certain sense, 1071 00:53:55,511 --> 00:53:57,260 as long as you check for some basic things 1072 00:53:57,260 --> 00:53:59,950 you shouldn't have. 1073 00:53:59,950 --> 00:54:02,410 But hex is open. 1074 00:54:02,410 --> 00:54:05,000 So there's actually a ton of nice open problems still. 1075 00:54:07,790 --> 00:54:13,090 Next case is called a super thin. 1076 00:54:28,040 --> 00:54:30,800 So what is super thin? 1077 00:54:30,800 --> 00:54:36,500 Super thin means there are no pixels. 1078 00:54:36,500 --> 00:54:40,130 Every face is either a hole or the outside face. 1079 00:54:40,130 --> 00:54:43,880 I don't have an example here, but this kind of connection 1080 00:54:43,880 --> 00:54:46,150 is what you would have in super thin graphs. 1081 00:54:46,150 --> 00:54:50,620 So you've got the whole face here, a whole face there. 1082 00:54:50,620 --> 00:54:53,360 You shouldn't have any of these pixels to be super thin. 1083 00:54:53,360 --> 00:54:56,380 That case turns out to be polynomial for squares 1084 00:54:56,380 --> 00:54:59,250 and hexes, open for triangles. 1085 00:54:59,250 --> 00:55:02,660 All right, next case is called thin. 1086 00:55:12,091 --> 00:55:14,670 That one right there implies. 1087 00:55:14,670 --> 00:55:19,330 In the thin case, both the triangle and the square, 1088 00:55:19,330 --> 00:55:21,810 problems are NP-hard, hexes are open. 1089 00:55:21,810 --> 00:55:23,210 What does thin mean? 1090 00:55:23,210 --> 00:55:27,750 Thin means every vertex is on the boundary. 1091 00:55:27,750 --> 00:55:31,950 So super thin is something like every edge is on the boundary. 1092 00:55:31,950 --> 00:55:34,200 Thin is that every vertex is on the boundary. 1093 00:55:34,200 --> 00:55:36,910 So for example, this part here is thin. 1094 00:55:36,910 --> 00:55:39,320 The banner's actually drawn in bold here. 1095 00:55:39,320 --> 00:55:42,070 If every vertex has bold edges incident to it, 1096 00:55:42,070 --> 00:55:43,320 then we call that thin. 1097 00:55:43,320 --> 00:55:47,510 So it's a little bit thicker than super thin. 1098 00:55:47,510 --> 00:55:52,270 So it's also easier to think of the dual if you care to. 1099 00:55:52,270 --> 00:55:56,330 If you draw a vertex for every pixel, in the super thin case 1100 00:55:56,330 --> 00:55:58,282 there are no vertices in the dual. 1101 00:55:58,282 --> 00:56:03,470 In the thin case, the dual is super thin. 1102 00:56:03,470 --> 00:56:06,200 I don't know if that's easier to think about. 1103 00:56:06,200 --> 00:56:08,370 But these cases are actually hard, 1104 00:56:08,370 --> 00:56:10,710 at least in two out of the three pictures. 1105 00:56:10,710 --> 00:56:12,185 One of them we have already proved. 1106 00:56:16,150 --> 00:56:20,200 If you have a max degree three grid graph, 1107 00:56:20,200 --> 00:56:23,460 if max degree is three then it must 1108 00:56:23,460 --> 00:56:26,200 be on the boundary because of that absent pixel. 1109 00:56:26,200 --> 00:56:29,040 So we already showed the thin case for squares is hard. 1110 00:56:29,040 --> 00:56:34,450 Max degree thin implies thin, four squares. 1111 00:56:34,450 --> 00:56:41,710 And so you might ask what about triangles? 1112 00:56:41,710 --> 00:56:47,024 OK, so finally we get to an actual proof. 1113 00:56:47,024 --> 00:56:48,690 It's going to be the same kind of thing. 1114 00:56:48,690 --> 00:56:52,360 I'll skip this detail, but this is the planar and betting part. 1115 00:56:52,360 --> 00:56:57,710 So again, we're going to reduce from bipartite max degree three 1116 00:56:57,710 --> 00:57:02,190 planar Hamiltonicity as we did before. 1117 00:57:02,190 --> 00:57:04,770 And then we're going to draw it in the plane 1118 00:57:04,770 --> 00:57:06,770 in some kind of parity-preserving sense 1119 00:57:06,770 --> 00:57:11,860 with edges routed on the triangular grid. 1120 00:57:11,860 --> 00:57:14,900 That's not hard. 1121 00:57:14,900 --> 00:57:18,420 Then we have very similar looking gadgets. 1122 00:57:18,420 --> 00:57:21,400 Although in this case, a vertex can just 1123 00:57:21,400 --> 00:57:24,460 be a little triangle of dots. 1124 00:57:24,460 --> 00:57:26,490 The edge gadget's going to look pretty similar. 1125 00:57:26,490 --> 00:57:31,244 It's like a ladder, but now the ladder has funny rungs on it. 1126 00:57:31,244 --> 00:57:32,785 Turns are just what you would expect. 1127 00:57:35,500 --> 00:57:40,322 Notice we get degree five here. 1128 00:57:40,322 --> 00:57:41,780 But otherwise, things are the same. 1129 00:57:41,780 --> 00:57:45,154 You can traverse either in the loopback configuration. 1130 00:57:45,154 --> 00:57:46,570 When you have this pin joint there 1131 00:57:46,570 --> 00:57:48,690 you'll be forced to turn around there. 1132 00:57:48,690 --> 00:57:51,490 Or you zigzag all the way through, 1133 00:57:51,490 --> 00:57:54,224 and then that's used for present edges. 1134 00:57:54,224 --> 00:57:56,390 So this is edges you don't use in Hamiltonian cycle. 1135 00:57:56,390 --> 00:57:57,940 These are edges you do use. 1136 00:57:57,940 --> 00:57:59,620 And there are two types of vertices. 1137 00:57:59,620 --> 00:58:05,690 There's the ones of one parity where you always meet-- here, 1138 00:58:05,690 --> 00:58:07,860 you're kind of meeting with three edges, 1139 00:58:07,860 --> 00:58:11,270 but you're kind of meeting on a whole edge, like that. 1140 00:58:11,270 --> 00:58:13,100 And from here you have the choice 1141 00:58:13,100 --> 00:58:15,880 whether you do this or do this. 1142 00:58:15,880 --> 00:58:20,826 Two of them will be zigzags, one of them will be double-back. 1143 00:58:20,826 --> 00:58:22,450 And then there's the other parity class 1144 00:58:22,450 --> 00:58:23,800 where you only have pin joints. 1145 00:58:23,800 --> 00:58:25,841 These are, again, just connected by single edges, 1146 00:58:25,841 --> 00:58:28,240 so they act just like we had before. 1147 00:58:28,240 --> 00:58:32,750 So pretty much the same reduction, but with different-- 1148 00:58:32,750 --> 00:58:35,451 in some ways, this is an easier reduction I think. 1149 00:58:38,600 --> 00:58:39,100 Cool. 1150 00:58:39,100 --> 00:58:41,600 Now, that was max degree five. 1151 00:58:41,600 --> 00:58:43,790 What about max degree four? 1152 00:58:43,790 --> 00:58:48,060 So here we had degree five vertex there. 1153 00:58:48,060 --> 00:58:52,080 If we kind of do our same trick of spreading them around, 1154 00:58:52,080 --> 00:58:55,560 you end up with degree four at most. 1155 00:58:55,560 --> 00:58:57,550 And it acts the same. 1156 00:58:57,550 --> 00:59:04,870 And the vertices we're going to explode into a hexagon. 1157 00:59:04,870 --> 00:59:08,030 And it works. 1158 00:59:08,030 --> 00:59:22,480 So I should say max degree four triangle is NP-hard. 1159 00:59:25,700 --> 00:59:28,790 This reduction should also be thin. 1160 00:59:28,790 --> 00:59:30,750 Previous one may have also been thin, 1161 00:59:30,750 --> 00:59:34,410 but again, all of the vertices are on the boundary. 1162 00:59:34,410 --> 00:59:37,590 So this is the thin triangle is hard. 1163 00:59:37,590 --> 00:59:39,644 Max degree four triangle is hard. 1164 00:59:39,644 --> 00:59:40,310 We did this one. 1165 00:59:40,310 --> 00:59:44,070 So we've done all the hardest proofs. 1166 00:59:44,070 --> 00:59:47,720 That will cease to be the case in a moment. 1167 00:59:47,720 --> 00:59:51,470 OK, here's one more thing. 1168 00:59:51,470 --> 00:59:55,480 Max-- so what about hex grids. 1169 00:59:55,480 --> 00:59:58,580 I haven't mentioned any hardness for hex grids yet. 1170 00:59:58,580 --> 01:00:01,680 And one thing we know is max degree three, 1171 01:00:01,680 --> 01:00:09,610 writing new squares, but also hexagons are NP-hard. 1172 01:00:09,610 --> 01:00:11,550 Now, this is not so impressive. 1173 01:00:11,550 --> 01:00:15,090 Every vertex in the hex grid has a degree at most three. 1174 01:00:15,090 --> 01:00:18,307 But you can't hope for two, so that's 1175 01:00:18,307 --> 01:00:20,640 the best you can hope for in max degree characterization 1176 01:00:20,640 --> 01:00:21,710 with respect to hex grid. 1177 01:00:24,220 --> 01:00:26,195 This proof is tricky. 1178 01:00:30,910 --> 01:00:35,390 Maybe before I go there let me just mention one other result. 1179 01:00:35,390 --> 01:00:37,630 So this is delayed. 1180 01:00:37,630 --> 01:00:42,810 One other notion you can think about for grid graphs 1181 01:00:42,810 --> 01:00:46,170 is called polygonal grid graphs, and that's 1182 01:00:46,170 --> 01:00:48,050 what's supposed to be illustrated here. 1183 01:00:48,050 --> 01:00:50,840 Polygonal's kind of the opposite of super thin. 1184 01:00:50,840 --> 01:00:53,570 So super thin we had an edge that 1185 01:00:53,570 --> 01:00:58,340 had non-pixels on both sides. 1186 01:00:58,340 --> 01:01:01,770 In polygonal, every edge has a pixel on at least one 1187 01:01:01,770 --> 01:01:03,690 of the two sides. 1188 01:01:03,690 --> 01:01:06,690 So you never have an edge between two holes 1189 01:01:06,690 --> 01:01:08,900 or a hole in the outside face. 1190 01:01:08,900 --> 01:01:10,405 That's a polygonal situation. 1191 01:01:13,350 --> 01:01:15,080 So that's something you might assume. 1192 01:01:15,080 --> 01:01:17,030 It's sort of like saying you had a polygon 1193 01:01:17,030 --> 01:01:19,280 and then you sort of took the interior of the polygon, 1194 01:01:19,280 --> 01:01:20,710 whereas here, this was not really 1195 01:01:20,710 --> 01:01:23,519 a polygon because it's like there was a doubled edge there 1196 01:01:23,519 --> 01:01:24,060 or something. 1197 01:01:24,060 --> 01:01:26,884 That's not really a nice picture. 1198 01:01:26,884 --> 01:01:28,300 So polygonal's something you might 1199 01:01:28,300 --> 01:01:31,120 hope for in the practical applications, 1200 01:01:31,120 --> 01:01:33,510 which we will get to soon. 1201 01:01:33,510 --> 01:01:38,420 Funny thing is for polygonal triangular grid graphs, 1202 01:01:38,420 --> 01:01:40,120 the problem is polynomial. 1203 01:01:40,120 --> 01:01:48,410 And for polygonal hex grid graphs, the problem is NP-hard. 1204 01:01:48,410 --> 01:01:53,460 And for polygonal square grid graphs, we don't know. 1205 01:01:53,460 --> 01:01:54,490 Another open problem. 1206 01:01:57,390 --> 01:01:59,220 I won't prove this. 1207 01:01:59,220 --> 01:02:02,270 I think, again, this is almost always feasible. 1208 01:02:02,270 --> 01:02:05,220 It's almost always a Hamiltonian path. 1209 01:02:05,220 --> 01:02:09,540 For this, I'm guessing it follows from the same proof. 1210 01:02:09,540 --> 01:02:17,590 Let's go into this proof, hex grid hardness. 1211 01:02:17,590 --> 01:02:19,140 Again, there's a drawing step. 1212 01:02:19,140 --> 01:02:21,780 You're given some bipartite max degree 1213 01:02:21,780 --> 01:02:28,280 three graph, and bipartite planar max three degree graph. 1214 01:02:28,280 --> 01:02:31,540 And then we're going to draw on the hex grid. 1215 01:02:31,540 --> 01:02:33,540 In this case, we're going to represent variables 1216 01:02:33,540 --> 01:02:38,330 by sort of horizontal strips, just because that's what 1217 01:02:38,330 --> 01:02:40,110 is a little bit easier to do. 1218 01:02:40,110 --> 01:02:43,700 So it turns out-- I think turns are really annoying on the hex 1219 01:02:43,700 --> 01:02:44,260 grid. 1220 01:02:44,260 --> 01:02:45,480 Hard to do a turn. 1221 01:02:45,480 --> 01:02:49,090 So we're going to focus our turn attention 1222 01:02:49,090 --> 01:02:50,430 within these little rectangles. 1223 01:02:50,430 --> 01:02:52,680 And it turns out you can draw everything in such a way 1224 01:02:52,680 --> 01:02:56,260 that all of the edges are straight lines, straight line 1225 01:02:56,260 --> 01:02:59,510 segments, if you grow the vertices to be these longer 1226 01:02:59,510 --> 01:03:01,220 horizontal things. 1227 01:03:01,220 --> 01:03:05,280 So believe that. 1228 01:03:05,280 --> 01:03:11,021 Then main idea is a very similar kind of thing. 1229 01:03:11,021 --> 01:03:13,020 In this case, they're going to draw the pictures 1230 01:03:13,020 --> 01:03:15,269 and they're going to draw all of the forced edges that 1231 01:03:15,269 --> 01:03:17,540 must be in there, and here they haven't 1232 01:03:17,540 --> 01:03:18,850 drawn the part in the middle. 1233 01:03:18,850 --> 01:03:19,970 There's two ways to fill it in. 1234 01:03:19,970 --> 01:03:21,850 Essentially, you could zigzag back and forth, 1235 01:03:21,850 --> 01:03:22,950 just like before. 1236 01:03:22,950 --> 01:03:25,760 Or you could go there and come back, just like before. 1237 01:03:25,760 --> 01:03:28,225 So edge gadget looks pretty reasonable. 1238 01:03:31,530 --> 01:03:33,670 These are some more gadgets. 1239 01:03:33,670 --> 01:03:37,210 These are like sub-routines they're going to use. 1240 01:03:37,210 --> 01:03:40,100 Their named and they have color patterns to give you a sense. 1241 01:03:40,100 --> 01:03:43,150 This is going to be the center of a vertex, 1242 01:03:43,150 --> 01:03:45,850 and there's a few different things you could do with that. 1243 01:03:45,850 --> 01:03:48,171 This is some kind of turn gadget. 1244 01:03:48,171 --> 01:03:49,170 That's what I called it. 1245 01:03:49,170 --> 01:03:51,030 They called it something a little different. 1246 01:03:51,030 --> 01:03:52,620 I think a rosette. 1247 01:03:52,620 --> 01:03:57,250 But you can sort of zigzag, or you can kind of 1248 01:03:57,250 --> 01:03:59,340 go there and double-back, but you end up 1249 01:03:59,340 --> 01:04:01,180 with different orientations at the end. 1250 01:04:01,180 --> 01:04:04,080 This is what they call a U turn. 1251 01:04:04,080 --> 01:04:05,330 Again, these edges are forced. 1252 01:04:05,330 --> 01:04:07,590 You can either use it as a zigzag, 1253 01:04:07,590 --> 01:04:10,220 or they could both kind of cancel each other out. 1254 01:04:10,220 --> 01:04:12,450 Sort of don't meet each other. 1255 01:04:12,450 --> 01:04:15,670 So you could do different kind of connectivity. 1256 01:04:15,670 --> 01:04:21,390 With that in mind, here is all the vertex gadgets. 1257 01:04:21,390 --> 01:04:26,421 So I don't know all the details here. 1258 01:04:26,421 --> 01:04:28,940 But I think there's a lot of cases 1259 01:04:28,940 --> 01:04:31,780 because of the different ways things could be connected. 1260 01:04:31,780 --> 01:04:35,080 You could have like one on top of the-- notice 1261 01:04:35,080 --> 01:04:37,740 the dash things are the rectangles that I had before. 1262 01:04:37,740 --> 01:04:39,790 Normally they'd be really spread out. 1263 01:04:39,790 --> 01:04:42,020 So maybe you have two in the bottom, one on the top, 1264 01:04:42,020 --> 01:04:44,190 here I have two on the top, one on the bottom. 1265 01:04:44,190 --> 01:04:47,970 And they could be oriented like this, or oriented like that. 1266 01:04:47,970 --> 01:04:50,680 So there's a lot of different cases as a result. 1267 01:04:50,680 --> 01:04:53,310 The core part in the middle is the same. 1268 01:04:53,310 --> 01:04:54,960 It's pretty much like the examples 1269 01:04:54,960 --> 01:04:59,370 we had before of essentially like a little 3 1270 01:04:59,370 --> 01:05:02,010 by 3 square for the square case, or a little triangle 1271 01:05:02,010 --> 01:05:03,057 in the triangle case. 1272 01:05:03,057 --> 01:05:04,265 A little bit bigger in a hex. 1273 01:05:04,265 --> 01:05:08,360 It's basically a cycle is an extra dot in the middle. 1274 01:05:08,360 --> 01:05:11,380 But then this was a U turn gadgets, 1275 01:05:11,380 --> 01:05:14,080 so if something was coming up here, 1276 01:05:14,080 --> 01:05:16,080 you could just sort of turn back around 1277 01:05:16,080 --> 01:05:19,320 if you don't want to use the edge. 1278 01:05:19,320 --> 01:05:21,210 I think these are prob-- well, yeah, 1279 01:05:21,210 --> 01:05:24,170 so there's probably also two parity classes. 1280 01:05:24,170 --> 01:05:26,330 There's the turn gadgets. 1281 01:05:26,330 --> 01:05:30,680 And it works, but it's complicated. 1282 01:05:35,140 --> 01:05:38,245 I think that's all I'll say about various grid graphs. 1283 01:05:38,245 --> 01:05:38,870 AUDIENCE: Yeah. 1284 01:05:38,870 --> 01:05:41,349 You said that in hexagonal grids were open? 1285 01:05:41,349 --> 01:05:42,349 Did you mean the vertex? 1286 01:05:42,349 --> 01:05:43,343 Every vertex on the boundary-- 1287 01:05:43,343 --> 01:05:45,509 ERIK DEMAINE: It means every vertex on the boundary. 1288 01:05:45,509 --> 01:05:47,320 AUDIENCE: --[INAUDIBLE]. 1289 01:05:47,320 --> 01:05:48,140 ERIK DEMAINE: No. 1290 01:05:48,140 --> 01:05:49,520 It's not necessarily the same. 1291 01:05:49,520 --> 01:05:52,510 So if you have hex grid-- I mean this could still 1292 01:05:52,510 --> 01:05:54,230 be a boundary cycle and you still 1293 01:05:54,230 --> 01:05:56,520 have a degree three vertex. 1294 01:05:56,520 --> 01:05:59,150 Something like this part is thin. 1295 01:05:59,150 --> 01:06:01,820 And I'm guessing you could complete that. 1296 01:06:01,820 --> 01:06:03,420 So they're probably very special, 1297 01:06:03,420 --> 01:06:06,080 so I could imagine the thin hex grids are polynomial, 1298 01:06:06,080 --> 01:06:07,450 but it's not known. 1299 01:06:07,450 --> 01:06:08,990 OK. 1300 01:06:08,990 --> 01:06:10,340 One more picture. 1301 01:06:10,340 --> 01:06:13,270 This is an actual explicitly constructed example 1302 01:06:13,270 --> 01:06:17,762 from that graph to this crazy gadgets. 1303 01:06:17,762 --> 01:06:19,220 But now you can see a little better 1304 01:06:19,220 --> 01:06:20,469 what the rectangles look like. 1305 01:06:20,469 --> 01:06:22,290 If you want to stretch something out, 1306 01:06:22,290 --> 01:06:24,870 there's always horizontal wires that you can stretch out. 1307 01:06:24,870 --> 01:06:26,135 And I keep calling them wires. 1308 01:06:26,135 --> 01:06:28,330 So those horizontal pieces of edge gadgets 1309 01:06:28,330 --> 01:06:32,050 that you can stretch out so that you end up firing 1310 01:06:32,050 --> 01:06:35,770 and hitting the next vertex, which is this rectangle. 1311 01:06:35,770 --> 01:06:37,360 And when you spread out the rectangles 1312 01:06:37,360 --> 01:06:41,620 you have to stretch out these diagonal shots. 1313 01:06:41,620 --> 01:06:42,420 Cool. 1314 01:06:42,420 --> 01:06:43,726 Those hex grid graphs. 1315 01:06:43,726 --> 01:06:45,600 Why do we care about hex grid graphs so much? 1316 01:06:45,600 --> 01:06:50,680 Because Settlers of Catan, and various other board games 1317 01:06:50,680 --> 01:06:53,620 that have a hex grid. 1318 01:06:53,620 --> 01:06:56,980 Now, has anyone here not played Settlers of Catan? 1319 01:06:56,980 --> 01:06:59,510 OK, a few. 1320 01:06:59,510 --> 01:07:01,760 There's a whole game to it. 1321 01:07:01,760 --> 01:07:02,608 But-- 1322 01:07:02,608 --> 01:07:04,480 [LAUGHTER] 1323 01:07:04,480 --> 01:07:08,520 What I'm going to focus on is this card. 1324 01:07:08,520 --> 01:07:11,110 It's called longest road. 1325 01:07:11,110 --> 01:07:13,990 So in general, you're constructing cities. 1326 01:07:13,990 --> 01:07:15,510 Don't worry about cities. 1327 01:07:15,510 --> 01:07:17,500 But you're constructing these road segments. 1328 01:07:17,500 --> 01:07:19,590 They're edges on the hex grid. 1329 01:07:19,590 --> 01:07:23,370 And the longest road says that you get two points, two victory 1330 01:07:23,370 --> 01:07:26,910 points, if you have the longest road, meaning the longest 1331 01:07:26,910 --> 01:07:29,270 path that can be formed using edges 1332 01:07:29,270 --> 01:07:31,980 of your color versus edges of anyone else's color, 1333 01:07:31,980 --> 01:07:33,790 then you get two points. 1334 01:07:33,790 --> 01:07:36,142 So here is the idea. 1335 01:07:36,142 --> 01:07:38,350 Settlers of Catan has randomness and stuff like that, 1336 01:07:38,350 --> 01:07:40,870 but again, if we look at a mate-in-1 problem, 1337 01:07:40,870 --> 01:07:42,247 that goes out the window. 1338 01:07:42,247 --> 01:07:43,580 Just can I win in this one move. 1339 01:07:43,580 --> 01:07:45,680 There's no randomness to that. 1340 01:07:45,680 --> 01:07:47,810 Let's suppose you have tons of resources. 1341 01:07:47,810 --> 01:07:49,850 This is what you need to build a road. 1342 01:07:49,850 --> 01:07:52,440 And inconveniently, your opponents 1343 01:07:52,440 --> 01:07:56,099 have built cities and things in all of these white spots, 1344 01:07:56,099 --> 01:07:57,890 so you're not allowed to build roads there. 1345 01:07:57,890 --> 01:07:59,870 That's just part of the rules. 1346 01:07:59,870 --> 01:08:02,140 So that's the opponent's form obstacles. 1347 01:08:02,140 --> 01:08:04,940 And then because you have infinite cash, 1348 01:08:04,940 --> 01:08:08,130 you can basically build the entire grid graph here. 1349 01:08:08,130 --> 01:08:11,300 And then to figure out whether there's a really long road, 1350 01:08:11,300 --> 01:08:15,130 namely a road length n, where n is the number of pixels that 1351 01:08:15,130 --> 01:08:17,779 were not occupied by opponents. 1352 01:08:17,779 --> 01:08:21,050 Number of dots that are not occupied by opponents 1353 01:08:21,050 --> 01:08:23,470 is NP-complete. 1354 01:08:23,470 --> 01:08:23,970 Cool? 1355 01:08:23,970 --> 01:08:26,740 And your opponent has a slightly shorter road, 1356 01:08:26,740 --> 01:08:31,125 so you really have to distinguish whether you 1357 01:08:31,125 --> 01:08:32,000 had the longest road. 1358 01:08:32,000 --> 01:08:35,270 In fact, I like to say mate-in-0 is NP-complete, 1359 01:08:35,270 --> 01:08:39,550 deciding whether you've already won the game is NP-complete. 1360 01:08:39,550 --> 01:08:40,790 Now you don't even need cash. 1361 01:08:40,790 --> 01:08:43,189 It's just I give you a configuration. 1362 01:08:43,189 --> 01:08:45,979 Do you have the longest road is NP-hard. 1363 01:08:45,979 --> 01:08:49,720 So it's the only mate-in-0 hardness result I know of. 1364 01:08:49,720 --> 01:08:52,060 Maybe we can find more. 1365 01:08:52,060 --> 01:08:55,990 OK, so that's why hex grids are cool. 1366 01:08:55,990 --> 01:08:58,100 Let's do some more games. 1367 01:08:58,100 --> 01:09:00,899 Here is another Nikoli puzzle, Slither Link. 1368 01:09:00,899 --> 01:09:03,410 Their more famous one. 1369 01:09:03,410 --> 01:09:05,260 So you're given a grid of squares. 1370 01:09:05,260 --> 01:09:08,100 Each square is either blank, meaning no constraint, 1371 01:09:08,100 --> 01:09:10,510 or there's a number saying there should be exactly two 1372 01:09:10,510 --> 01:09:12,146 edges among those four. 1373 01:09:12,146 --> 01:09:14,520 And there should be exactly three edges among those four. 1374 01:09:14,520 --> 01:09:17,550 Your goal is to find a cycle-- not Hamiltonian 1375 01:09:17,550 --> 01:09:21,390 but just a cycle, doesn't visit all the dots-- that satisfies 1376 01:09:21,390 --> 01:09:23,420 that neighboring constraint. 1377 01:09:23,420 --> 01:09:24,899 So here there were exactly two. 1378 01:09:24,899 --> 01:09:30,270 Here there are exactly three edges in your cycle. 1379 01:09:30,270 --> 01:09:30,899 OK? 1380 01:09:30,899 --> 01:09:32,950 This is the very first puzzle on the website. 1381 01:09:32,950 --> 01:09:35,660 Again, there are books on Slither Link puzzles. 1382 01:09:35,660 --> 01:09:40,290 And here is a little overkill of a hardness proof, 1383 01:09:40,290 --> 01:09:42,010 but in one slide. 1384 01:09:42,010 --> 01:09:48,130 So this is a reduction from Hamiltonicity in planar graphs. 1385 01:09:48,130 --> 01:09:50,890 So you take any planar graph and draw it in the grid. 1386 01:09:50,890 --> 01:09:54,380 This is one of the very first steps we did today. 1387 01:09:54,380 --> 01:09:56,944 And then if you do that, there are two types of vertices. 1388 01:09:56,944 --> 01:09:58,360 There's the ones you have to visit 1389 01:09:58,360 --> 01:10:00,234 and there's the ones you don't have to visit. 1390 01:10:00,234 --> 01:10:02,530 Now, we know grid graphs are hard. 1391 01:10:02,530 --> 01:10:05,080 So we could actually assume all of the vertices 1392 01:10:05,080 --> 01:10:06,690 have to be visited. 1393 01:10:06,690 --> 01:10:10,410 But for whatever reason, this proof did not do that. 1394 01:10:10,410 --> 01:10:12,640 This is back in 2000, so at that point maybe 1395 01:10:12,640 --> 01:10:14,990 it was not so well known. 1396 01:10:14,990 --> 01:10:16,980 But these days, grid graphs, Hamiltonicity 1397 01:10:16,980 --> 01:10:20,180 is used a lot, but probably not so much then. 1398 01:10:20,180 --> 01:10:22,110 So anyway, there's this gadget which 1399 01:10:22,110 --> 01:10:25,840 is you can do whatever you want, basically. 1400 01:10:25,840 --> 01:10:28,560 These are the vertices that don't need to be visited. 1401 01:10:28,560 --> 01:10:30,800 The key gadget is this one. 1402 01:10:30,800 --> 01:10:32,680 So let's focus our attention here. 1403 01:10:32,680 --> 01:10:36,600 We have these ones which means the cycle must come here. 1404 01:10:36,600 --> 01:10:40,070 And so collectively these are going to form Hamiltonian cycle 1405 01:10:40,070 --> 01:10:41,200 constraints. 1406 01:10:41,200 --> 01:10:43,890 You're building a cycle and you have to visit these ones. 1407 01:10:43,890 --> 01:10:46,640 Now it turns out no matter which end you come in 1408 01:10:46,640 --> 01:10:49,320 and which end you leave, you can visit all of the ones. 1409 01:10:49,320 --> 01:10:51,450 You could be adjacent to all of the ones. 1410 01:10:51,450 --> 01:10:54,740 So different turns are going straight. 1411 01:10:54,740 --> 01:10:56,660 And so if there is a Hamiltonian cycle, 1412 01:10:56,660 --> 01:10:59,170 you'll be able to visit all the ones. 1413 01:10:59,170 --> 01:11:01,850 And conversely, if you can visit all the ones, 1414 01:11:01,850 --> 01:11:03,460 that must be a Hamiltonian cycle. 1415 01:11:03,460 --> 01:11:05,294 The one extra thing we need to say, 1416 01:11:05,294 --> 01:11:06,960 if you just glue these gadgets together, 1417 01:11:06,960 --> 01:11:11,720 then there's no-- you can go from anywhere to anywhere. 1418 01:11:11,720 --> 01:11:14,100 So you just add in some zeroes here 1419 01:11:14,100 --> 01:11:16,940 if you don't want there to be a connection from left to right. 1420 01:11:16,940 --> 01:11:19,220 So you can use that to delineate the boundary. 1421 01:11:19,220 --> 01:11:21,450 So this could actually do a sub-graph of a grid graph 1422 01:11:21,450 --> 01:11:25,255 even more special, or you leave a clear if there's an edge. 1423 01:11:25,255 --> 01:11:28,470 And so you get a picture like this. 1424 01:11:28,470 --> 01:11:31,150 In this case, they're using these bunch of zeroes 1425 01:11:31,150 --> 01:11:33,470 to say, well, you don't have to visit 1426 01:11:33,470 --> 01:11:36,755 these pixels because they're just simulating a big edge. 1427 01:11:36,755 --> 01:11:38,130 But we really have infrastructure 1428 01:11:38,130 --> 01:11:38,880 to simulate edges. 1429 01:11:38,880 --> 01:11:41,120 We don't really need that. 1430 01:11:41,120 --> 01:11:42,850 So that's a really easy proof. 1431 01:11:45,069 --> 01:11:46,610 I would say in general, what you have 1432 01:11:46,610 --> 01:11:49,350 to be careful about here is that edges are free, 1433 01:11:49,350 --> 01:11:51,050 because in Hamiltonian cycle you're not 1434 01:11:51,050 --> 01:11:52,300 supposed to pay for the edges. 1435 01:11:52,300 --> 01:11:54,740 You just have to visit every vertex. 1436 01:11:54,740 --> 01:11:57,380 But that's really easy in this kind of set up. 1437 01:11:57,380 --> 01:12:03,850 Another Nikoli puzzle, Hashiwokakero, bridge building. 1438 01:12:03,850 --> 01:12:06,250 You have a bunch of dots in the plane. 1439 01:12:06,250 --> 01:12:11,290 Each dot has a number on it, specifying a degree request. 1440 01:12:11,290 --> 01:12:15,126 And your goal is to make a connected structure. 1441 01:12:15,126 --> 01:12:17,150 It looks like it's usually a tree, 1442 01:12:17,150 --> 01:12:19,050 but that's not part of the constraints. 1443 01:12:19,050 --> 01:12:21,426 Where every vertex has that degree, 1444 01:12:21,426 --> 01:12:22,550 you can use multiple edges. 1445 01:12:22,550 --> 01:12:25,700 You could build multiple bridges between the same two cities. 1446 01:12:25,700 --> 01:12:28,849 And so there's four incident to that, eight incident to that, 1447 01:12:28,849 --> 01:12:30,015 and everything's orthogonal. 1448 01:12:30,015 --> 01:12:31,960 It can only build horizontal, vertical. 1449 01:12:31,960 --> 01:12:34,190 You can't build a bridge like this. 1450 01:12:34,190 --> 01:12:35,670 You're not allowed to make turns. 1451 01:12:35,670 --> 01:12:37,045 AUDIENCE: Same as standard coding 1452 01:12:37,045 --> 01:12:39,932 where you've only got two parallel edges per [INAUDIBLE]. 1453 01:12:39,932 --> 01:12:40,640 ERIK DEMAINE: Ah. 1454 01:12:40,640 --> 01:12:41,139 OK. 1455 01:12:41,139 --> 01:12:46,800 So also standard is that max double-edge, no triple-edge. 1456 01:12:46,800 --> 01:12:47,870 Thank you. 1457 01:12:47,870 --> 01:12:51,020 Obviously, i haven't actually played. 1458 01:12:51,020 --> 01:12:52,590 It won't matter in this reduction. 1459 01:12:52,590 --> 01:12:56,540 So here we are reducing from Hamiltonicity in grid graphs. 1460 01:12:56,540 --> 01:12:59,330 So these are edges that we might want to allow. 1461 01:12:59,330 --> 01:13:02,250 In general, we're going to use these little ones to delineate 1462 01:13:02,250 --> 01:13:03,690 the boundary. 1463 01:13:03,690 --> 01:13:07,470 It's just the same kind of trick we use here 1464 01:13:07,470 --> 01:13:10,320 with Euclidean degree three MST. 1465 01:13:10,320 --> 01:13:13,386 We added a little dot just off to the side. 1466 01:13:13,386 --> 01:13:15,260 It's not a metric problem here, so we're just 1467 01:13:15,260 --> 01:13:16,752 adding it one unit over. 1468 01:13:16,752 --> 01:13:17,960 That delineates the boundary. 1469 01:13:17,960 --> 01:13:21,399 It basically is forced to connect into the only neighbor. 1470 01:13:21,399 --> 01:13:23,190 If you tried to do this kind of connection, 1471 01:13:23,190 --> 01:13:24,523 you'd end up being disconnected. 1472 01:13:24,523 --> 01:13:26,490 You'd just get a single edge there. 1473 01:13:26,490 --> 01:13:29,060 Because ones will only face ones. 1474 01:13:29,060 --> 01:13:29,560 Sorry. 1475 01:13:29,560 --> 01:13:31,310 The other constraint is you're not allowed 1476 01:13:31,310 --> 01:13:33,570 to have crossing bridges. 1477 01:13:33,570 --> 01:13:35,852 That won't matter here. 1478 01:13:35,852 --> 01:13:37,560 So we delineate the boundary at the ones, 1479 01:13:37,560 --> 01:13:39,060 and then every other vertex is going 1480 01:13:39,060 --> 01:13:42,370 to have value two plus the number of boundary edges 1481 01:13:42,370 --> 01:13:43,000 incident to it. 1482 01:13:43,000 --> 01:13:45,660 So here it happens to be four, here it happens to be three. 1483 01:13:45,660 --> 01:13:46,990 So I could have gone like this. 1484 01:13:46,990 --> 01:13:48,073 That would have been fine. 1485 01:13:48,073 --> 01:13:51,790 But in the cycle, I happened to go around that way. 1486 01:13:51,790 --> 01:13:53,290 That's representing the cycle. 1487 01:13:53,290 --> 01:13:55,450 So again, very easy. 1488 01:13:55,450 --> 01:13:58,890 This shows you how useful it is once you have grid graphs. 1489 01:13:58,890 --> 01:14:01,760 You can do any problem on any grid, pretty much, that has 1490 01:14:01,760 --> 01:14:04,020 any kind of tour-like thing. 1491 01:14:04,020 --> 01:14:06,940 That will be hard using these reductions. 1492 01:14:06,940 --> 01:14:08,520 So that's why we care. 1493 01:14:11,470 --> 01:14:12,310 All right. 1494 01:14:12,310 --> 01:14:14,410 Here's some practical motivation. 1495 01:14:14,410 --> 01:14:15,620 Well, I have a game here. 1496 01:14:15,620 --> 01:14:17,740 But suppose you're mowing your lawn. 1497 01:14:17,740 --> 01:14:21,560 And so usually a lawnmower has a circular cutting tool, 1498 01:14:21,560 --> 01:14:24,550 but in this game it happens to be a square cutting tool. 1499 01:14:24,550 --> 01:14:26,030 It's basically the same. 1500 01:14:26,030 --> 01:14:32,271 And you have some polygon with holes that you want to mow. 1501 01:14:32,271 --> 01:14:34,145 There's actually two versions of the problem. 1502 01:14:45,344 --> 01:14:50,020 And they were introduced by Arkin, Fekete and Mitchell, 1503 01:14:50,020 --> 01:14:51,271 2000. 1504 01:14:51,271 --> 01:14:52,790 One's called Lawn Mowing. 1505 01:14:57,690 --> 01:15:00,350 So Lawn Mowing you're given a polygon. 1506 01:15:00,350 --> 01:15:04,010 You have to visit, let's say, if we're using a square cutter, 1507 01:15:04,010 --> 01:15:05,900 you have to visit every pixel of the polygon. 1508 01:15:05,900 --> 01:15:07,441 You have to visit the entire-- you're 1509 01:15:07,441 --> 01:15:08,780 moving a unit square around. 1510 01:15:08,780 --> 01:15:11,300 You've got to visit everything to cut the entire lawn. 1511 01:15:11,300 --> 01:15:13,260 But you're also allowed to leave the polygon, 1512 01:15:13,260 --> 01:15:15,600 because for a lawn mower you can go outside the grass. 1513 01:15:15,600 --> 01:15:17,010 You can go onto the pavement. 1514 01:15:17,010 --> 01:15:18,940 Most lawnmowers that doesn't break it. 1515 01:15:18,940 --> 01:15:21,160 So that's called Lawn Mowing. 1516 01:15:21,160 --> 01:15:23,090 You can go outside if you want. 1517 01:15:26,360 --> 01:15:28,275 And the other problem is called Milling. 1518 01:15:31,800 --> 01:15:33,970 And with Milling, you can't go outside. 1519 01:15:37,196 --> 01:15:39,570 That video game is probably some hybrid between these two 1520 01:15:39,570 --> 01:15:41,307 problems, but both problems have been 1521 01:15:41,307 --> 01:15:43,390 considered a lot, especially from an approximation 1522 01:15:43,390 --> 01:15:44,690 standpoint. 1523 01:15:44,690 --> 01:15:48,670 But there are lots of situations where this kind of problem 1524 01:15:48,670 --> 01:15:49,370 comes up. 1525 01:15:49,370 --> 01:15:50,890 Suppose you're laser cutting. 1526 01:15:50,890 --> 01:15:52,540 This is one of the first laser cutter 1527 01:15:52,540 --> 01:15:56,410 projects we did with George Hart, back in 2003, 1528 01:15:56,410 --> 01:15:59,002 where cutting out these two-headed salamanders 1529 01:15:59,002 --> 01:16:00,460 like that and then assembling them. 1530 01:16:00,460 --> 01:16:05,770 If you've ever been to G6 in Stata, it's hanging there. 1531 01:16:05,770 --> 01:16:08,060 So you can think of this laser cutting problems, 1532 01:16:08,060 --> 01:16:11,340 you have a lot of dots and you have to cut them all. 1533 01:16:11,340 --> 01:16:13,610 That is literally what happens to laser cutter 1534 01:16:13,610 --> 01:16:16,150 is pulsing with little dots. 1535 01:16:16,150 --> 01:16:17,780 And in this case it looks pretty clear 1536 01:16:17,780 --> 01:16:18,988 how to connect them together. 1537 01:16:18,988 --> 01:16:22,380 But if you're cutting many salamanders out of one sheet, 1538 01:16:22,380 --> 01:16:24,910 and you think of the salamander's pretty small, 1539 01:16:24,910 --> 01:16:27,640 that's like a TSP problem or really a milling problem. 1540 01:16:27,640 --> 01:16:30,000 You have to visit all these things using 1541 01:16:30,000 --> 01:16:32,619 the shortest-- it's really a lawn mowing problem. 1542 01:16:32,619 --> 01:16:34,160 So you can turn off the laser and you 1543 01:16:34,160 --> 01:16:39,640 can move around somewhere else that you don't want to visit. 1544 01:16:39,640 --> 01:16:43,870 3D printing is like lawn mowing problem in each layer. 1545 01:16:43,870 --> 01:16:46,520 So 3D printing is done by printing each layer 1546 01:16:46,520 --> 01:16:48,630 and then stacking them up one at a time. 1547 01:16:48,630 --> 01:16:51,990 So in each layer you have to deposit material in FDM, 1548 01:16:51,990 --> 01:16:53,700 say we're additive printing. 1549 01:16:53,700 --> 01:16:55,529 You have to deposit material. 1550 01:16:55,529 --> 01:16:57,570 If you're doing laser curing, same kind of thing. 1551 01:16:57,570 --> 01:17:01,260 How do you move the laser with the shortest amount of work. 1552 01:17:01,260 --> 01:17:02,810 It's called milling. 1553 01:17:02,810 --> 01:17:04,270 I don't have an image for this. 1554 01:17:04,270 --> 01:17:06,495 Because if you're doing NC milling you have a drill 1555 01:17:06,495 --> 01:17:09,810 and you're moving the drill around to cut out some shape 1556 01:17:09,810 --> 01:17:11,435 or to cut a region. 1557 01:17:14,464 --> 01:17:16,630 There you're not allowed to go outside the shape you 1558 01:17:16,630 --> 01:17:20,346 want to cut, because you go outside, you cut too much. 1559 01:17:20,346 --> 01:17:22,220 And you don't want to have to pay to retract. 1560 01:17:22,220 --> 01:17:24,761 There are other versions of the problem where you can retract 1561 01:17:24,761 --> 01:17:28,320 the cutting bit and so on. 1562 01:17:28,320 --> 01:17:32,010 So of course we proved milling is hard. 1563 01:17:32,010 --> 01:17:34,280 That is exactly the Hamilton [INAUDIBLE] 1564 01:17:34,280 --> 01:17:36,926 graphs if you're not allowed to leave the region. 1565 01:17:36,926 --> 01:17:39,050 Of course, that also shows that lawn mowing is hard 1566 01:17:39,050 --> 01:17:41,190 because you never want to go outside the region. 1567 01:17:41,190 --> 01:17:43,430 One fun result is lawn mowing is hard even when you 1568 01:17:43,430 --> 01:17:45,360 have no holes in your region. 1569 01:17:45,360 --> 01:17:48,197 So if you cut these little slits, from a lawn mowing 1570 01:17:48,197 --> 01:17:50,030 perspective it basically makes no difference 1571 01:17:50,030 --> 01:17:51,795 because you could still go over it, 1572 01:17:51,795 --> 01:17:53,420 and it doesn't really save you anything 1573 01:17:53,420 --> 01:17:55,050 to not have to cut that. 1574 01:17:55,050 --> 01:17:57,925 So lawn mowing is hard even without holes. 1575 01:18:01,350 --> 01:18:02,060 Cool. 1576 01:18:02,060 --> 01:18:03,540 I have one more problem. 1577 01:18:03,540 --> 01:18:05,330 Do you want to see it? 1578 01:18:05,330 --> 01:18:07,520 OK. 1579 01:18:07,520 --> 01:18:10,230 So here's-- sorry-- a brief warm-up. 1580 01:18:10,230 --> 01:18:12,700 Suppose you have a grid graph. 1581 01:18:12,700 --> 01:18:14,650 You rotate it 45 degrees. 1582 01:18:14,650 --> 01:18:19,200 You can represent each of these vertices as a vertical segment 1583 01:18:19,200 --> 01:18:22,260 if they're black parity or horizontal segment. 1584 01:18:22,260 --> 01:18:25,230 If they're white parity such that segments 1585 01:18:25,230 --> 01:18:28,580 intersect, if and only if there's an edge joining. 1586 01:18:28,580 --> 01:18:30,180 So these are unit orthogonal segments. 1587 01:18:30,180 --> 01:18:31,679 This is called an intersection graph 1588 01:18:31,679 --> 01:18:33,810 where the vertices are the objects, 1589 01:18:33,810 --> 01:18:37,430 and the edges are whether things intersect. 1590 01:18:37,430 --> 01:18:41,790 I need that, so Hamiltonicity in these graphs is hard. 1591 01:18:41,790 --> 01:18:45,270 Here's a problem called minimum turn milling. 1592 01:18:45,270 --> 01:18:49,590 So a big issue for 3D printing, for milling, 1593 01:18:49,590 --> 01:18:52,710 usually when you're cutting or you're depositing material, 1594 01:18:52,710 --> 01:18:55,061 you can move really fast in a straight line. 1595 01:18:55,061 --> 01:18:56,560 But when you need to make a turn you 1596 01:18:56,560 --> 01:19:00,050 have to basically come to a stop and then speed up again. 1597 01:19:00,050 --> 01:19:05,100 So suppose you have infinite acceleration, so to speak, 1598 01:19:05,100 --> 01:19:06,630 or close to infinite acceleration. 1599 01:19:06,630 --> 01:19:08,800 So once you're going straight you can go arbitrarily 1600 01:19:08,800 --> 01:19:10,610 far for the same cost, and what you really 1601 01:19:10,610 --> 01:19:13,060 pay for is the slowing down and speeding back up 1602 01:19:13,060 --> 01:19:14,102 at every corner. 1603 01:19:14,102 --> 01:19:16,310 So then you want to minimize the number of turns, not 1604 01:19:16,310 --> 01:19:17,760 the lengths. 1605 01:19:17,760 --> 01:19:19,610 This is one of my first hardness proofs 1606 01:19:19,610 --> 01:19:22,050 that was not about puzzles. 1607 01:19:22,050 --> 01:19:23,940 I think the original paper was 2000, 1608 01:19:23,940 --> 01:19:26,090 the journal version's 2005. 1609 01:19:26,090 --> 01:19:29,170 So suppose you have one of these rectangle intersection graphs. 1610 01:19:29,170 --> 01:19:34,130 What we're going to do is replace each of these things 1611 01:19:34,130 --> 01:19:38,100 with a cycle, and then thicken that cycle. 1612 01:19:38,100 --> 01:19:44,090 This is a thin grid graph, not super thin. 1613 01:19:44,090 --> 01:19:46,640 Maybe super thin. 1614 01:19:46,640 --> 01:19:48,820 Here it's super thin, and here you 1615 01:19:48,820 --> 01:19:51,790 have a little square that you're cutting with. 1616 01:19:51,790 --> 01:19:55,780 So each of these things you have to make four turns. 1617 01:19:55,780 --> 01:19:58,770 Then also, to go from one of these to one of these, 1618 01:19:58,770 --> 01:20:02,590 to go from one vertex to the next, you need a turn. 1619 01:20:02,590 --> 01:20:05,520 So in general, you're going to need 5n turns in order 1620 01:20:05,520 --> 01:20:08,341 to visit n of these original segments. 1621 01:20:08,341 --> 01:20:10,090 And you can do that if and only if there's 1622 01:20:10,090 --> 01:20:12,510 a Hamiltonian cycle in the original graph, 1623 01:20:12,510 --> 01:20:14,190 which was this picture. 1624 01:20:14,190 --> 01:20:17,760 Basically, if you come in one position-- 1625 01:20:17,760 --> 01:20:22,320 so here's one of these rectangles you want to visit. 1626 01:20:22,320 --> 01:20:24,420 You come in one place and you know 1627 01:20:24,420 --> 01:20:26,600 that you want to leave on some other place. 1628 01:20:26,600 --> 01:20:29,520 So you double this edge-- you're going to cut it twice. 1629 01:20:29,520 --> 01:20:31,170 That's allowed in this model. 1630 01:20:31,170 --> 01:20:32,580 And then you loop around. 1631 01:20:32,580 --> 01:20:35,660 And the number of turns here is exactly one to come in, 1632 01:20:35,660 --> 01:20:37,560 four to go around, and then one to come out. 1633 01:20:37,560 --> 01:20:41,080 In general, it's one per edge in the cycle, 1634 01:20:41,080 --> 01:20:43,350 and four per vertex in the cycle. 1635 01:20:43,350 --> 01:20:47,679 So again, Hamiltonicity gives us what we want. 1636 01:20:47,679 --> 01:20:49,470 Even where we minimize the number of turns, 1637 01:20:49,470 --> 01:20:55,740 we can simulate that by counting vertices as turns, basically. 1638 01:20:55,740 --> 01:20:58,040 And that's it for Hamiltonicity.