WEBVTT

00:00:00.080 --> 00:00:02.430
The following content is
provided under a Creative

00:00:02.430 --> 00:00:03.810
Commons license.

00:00:03.810 --> 00:00:06.050
Your support will help
MIT OpenCourseWare

00:00:06.050 --> 00:00:10.150
continue to offer high quality
educational resources for free.

00:00:10.150 --> 00:00:12.690
To make a donation or to
view additional materials

00:00:12.690 --> 00:00:16.600
from hundreds of MIT courses,
visit MIT OpenCourseWare

00:00:16.600 --> 00:00:17.260
at ocw.mit.edu.

00:00:25.920 --> 00:00:26.920
ERIK DEMAINE: All right.

00:00:26.920 --> 00:00:30.840
Today we start a new
section of NP-hardness.

00:00:30.840 --> 00:00:34.230
I think it'll be one
lecture about Hamiltonicity.

00:00:34.230 --> 00:00:39.600
So Hamiltonian cycle and path.

00:00:39.600 --> 00:00:41.260
We've talked about this briefly.

00:00:41.260 --> 00:00:48.970
But cycle is just a cycle
visiting every vertex exactly

00:00:48.970 --> 00:00:49.470
once.

00:00:58.900 --> 00:01:02.840
And usually when you talk about
a graph being Hamiltonian,

00:01:02.840 --> 00:01:05.180
you mean that there's a
Hamiltonian cycle, also called

00:01:05.180 --> 00:01:08.840
a Hamiltonian tour, or
Hamiltonian circuit all

00:01:08.840 --> 00:01:10.440
mean the same thing.

00:01:10.440 --> 00:01:13.090
And then there's
Hamiltonian path.

00:01:13.090 --> 00:01:16.000
Another problem we
have looked at before.

00:01:16.000 --> 00:01:18.650
And same thing, but path that
visits every vertex exactly

00:01:18.650 --> 00:01:19.150
once.

00:01:19.150 --> 00:01:20.774
These are pretty much
the same problem,

00:01:20.774 --> 00:01:24.580
but different versions are
useful in different settings.

00:01:24.580 --> 00:01:26.910
In case you're curious
where this comes from,

00:01:26.910 --> 00:01:31.290
it comes from this game
introduced by Hamilton in 1857.

00:01:31.290 --> 00:01:36.410
He was the royal astronomer
of Ireland back then,

00:01:36.410 --> 00:01:40.360
but he had fun
with games as well.

00:01:40.360 --> 00:01:44.520
So here you have something like
the graph of a dodecahedron.

00:01:44.520 --> 00:01:46.890
The dual is an icosahedron,
hence the name,

00:01:46.890 --> 00:01:49.577
and you want to find a
Hamiltonian circuit through it.

00:01:49.577 --> 00:01:52.160
Or there's actually a two-player
game where one person chooses

00:01:52.160 --> 00:01:53.660
a subset of the
graph, the other one

00:01:53.660 --> 00:01:57.500
tries to find Hamiltonian
circuit in that subset.

00:01:57.500 --> 00:02:01.080
So that's where
Hamiltonicity comes from.

00:02:01.080 --> 00:02:05.280
But for us today it is a
nice NP-complete problem.

00:02:05.280 --> 00:02:11.760
We've actually seen one proof
that planar max degree four,

00:02:11.760 --> 00:02:16.730
I think, Hamiltonicity is hard.

00:02:16.730 --> 00:02:20.890
That was in the
planar SAT discussion,

00:02:20.890 --> 00:02:23.730
and this is the original
paper that does planar 3SAT.

00:02:23.730 --> 00:02:26.470
And there was this proof--
I guess it's not actually

00:02:26.470 --> 00:02:29.090
max degree four, probably a
max degree six or something.

00:02:33.140 --> 00:02:35.420
We argued the directed
case-- this apparently

00:02:35.420 --> 00:02:37.245
works for the undirected
case-- we'll get

00:02:37.245 --> 00:02:40.890
an even stronger result here.

00:02:40.890 --> 00:02:50.140
In general, the problem
is NP-complete in a lot

00:02:50.140 --> 00:02:56.090
of different special cases,
such as the one we saw.

00:02:56.090 --> 00:02:59.310
For example, if you're
looking for a path

00:02:59.310 --> 00:03:05.734
and you're given the
two end points-- so

00:03:05.734 --> 00:03:07.650
normally you'd say is
there a Hamiltonian path

00:03:07.650 --> 00:03:08.900
or is there Hamiltonian cycle?

00:03:08.900 --> 00:03:10.800
Those are both hard
in general graphs.

00:03:10.800 --> 00:03:14.740
But if I give you a graph and
I give you two nodes, s and t,

00:03:14.740 --> 00:03:18.540
and I want to know is
there-- so here's the graph,

00:03:18.540 --> 00:03:20.790
here's s and t-- I want to
know is there a path that

00:03:20.790 --> 00:03:23.420
starts at s, ends at t.

00:03:23.420 --> 00:03:25.140
This is NP-hard.

00:03:25.140 --> 00:03:30.374
By reduction from Hamiltonian
cycle, tell me what to do.

00:03:30.374 --> 00:03:34.182
AUDIENCE: You add a new node
which has connection to s

00:03:34.182 --> 00:03:35.907
and t and nothing else.

00:03:35.907 --> 00:03:37.490
ERIK DEMAINE: Add a
new node connected

00:03:37.490 --> 00:03:38.660
to s and t and nothing else.

00:03:38.660 --> 00:03:39.160
Yeah.

00:03:39.160 --> 00:03:44.294
So we'll add this new node
x, connected to s and t.

00:03:44.294 --> 00:03:45.960
What's interesting
about adding a degree

00:03:45.960 --> 00:03:48.590
two node is you know it
has to be in the cycle,

00:03:48.590 --> 00:03:52.016
so you know that these two
edges have to be in the cycle.

00:03:52.016 --> 00:03:53.515
AUDIENCE: Also, if
it's directed you

00:03:53.515 --> 00:03:55.000
can direct those two so that--

00:03:55.000 --> 00:03:57.749
ERIK DEMAINE: It's not directed.

00:03:57.749 --> 00:03:59.290
All these are going
to be undirected.

00:04:05.650 --> 00:04:09.160
This would preserve
directedness if you wanted it.

00:04:09.160 --> 00:04:11.520
So there you go.

00:04:11.520 --> 00:04:14.310
So if Hamiltonian cycle's
hard, then Hamiltonian path

00:04:14.310 --> 00:04:15.750
given two end points is hard.

00:04:15.750 --> 00:04:18.529
Easy warm-up.

00:04:18.529 --> 00:04:27.640
It's also NP-complete
for planar three regular,

00:04:27.640 --> 00:04:36.595
three connected graphs,
where every face

00:04:36.595 --> 00:04:37.790
has degree at least five.

00:04:37.790 --> 00:04:40.370
But probably already met them.

00:04:40.370 --> 00:04:43.790
It's NP-hard for
bipartite graphs.

00:04:43.790 --> 00:04:51.277
These are all various
results proved in the '70s.

00:04:51.277 --> 00:04:53.110
It's going to be hard
for squares of graphs.

00:04:57.580 --> 00:04:59.020
Squares of graphs
is interesting.

00:04:59.020 --> 00:05:02.060
This is whenever you
have a length two path,

00:05:02.060 --> 00:05:03.730
you add an edge.

00:05:03.730 --> 00:05:08.610
It's a square, and
that's still hard.

00:05:08.610 --> 00:05:12.540
Another fun problem is
computing a Hamiltonian cycle

00:05:12.540 --> 00:05:15.740
given a Hamiltonian
path is also hard.

00:05:20.720 --> 00:05:23.700
On the other hand, some
variations are easy.

00:05:23.700 --> 00:05:26.770
So you have to be a
little bit careful.

00:05:26.770 --> 00:05:29.990
There are a lot of papers
about various graphs

00:05:29.990 --> 00:05:31.860
that are always
Hamiltonian and usually

00:05:31.860 --> 00:05:34.193
when they're always Hamiltonian
there's a good algorithm

00:05:34.193 --> 00:05:35.370
to find them.

00:05:35.370 --> 00:05:37.540
Here are just a
couple of examples.

00:05:37.540 --> 00:05:41.130
One is cubes of graphs.

00:05:41.130 --> 00:05:44.410
So if you take all
length three paths

00:05:44.410 --> 00:05:46.820
and connect them by an edge,
or maybe length less than

00:05:46.820 --> 00:05:49.347
or equal to three-- I'm not
sure exactly-- that's easy.

00:05:49.347 --> 00:05:51.680
All such graphs are Hamiltonian,
where with squares it's

00:05:51.680 --> 00:05:52.910
still hard.

00:05:52.910 --> 00:05:54.290
So that's kind of a limit.

00:05:54.290 --> 00:05:57.720
And the other one
here is planar-- three

00:05:57.720 --> 00:05:59.930
connector graphs is NP-complete.

00:05:59.930 --> 00:06:02.460
Planar four connector
graphs is polynomial.

00:06:08.130 --> 00:06:12.570
This is a tough theorem,
one of many tough theorems.

00:06:12.570 --> 00:06:15.630
All such graphs are Hamiltonian.

00:06:15.630 --> 00:06:18.280
So those are a few
cases to worry about.

00:06:18.280 --> 00:06:20.190
We will see some more today.

00:06:20.190 --> 00:06:22.950
And these are relatively simple.

00:06:22.950 --> 00:06:24.710
We're going to
prove even stricter

00:06:24.710 --> 00:06:26.780
versions of this
problem NP-complete,

00:06:26.780 --> 00:06:30.490
but it starts to give you
the flavor of what's there.

00:06:34.120 --> 00:06:41.780
In fact the first
one we will prove

00:06:41.780 --> 00:06:49.150
is-- this may seem a little
weird because I wanted

00:06:49.150 --> 00:06:51.000
to do undirected,
but we're going

00:06:51.000 --> 00:06:52.620
to make it undirected
in a moment.

00:06:52.620 --> 00:06:55.240
We're going to do a
series of reductions.

00:06:55.240 --> 00:07:01.530
First one we'll do is planar
max degree three graphs.

00:07:06.180 --> 00:07:11.210
So this will be a
reduction from 3SAT.

00:07:11.210 --> 00:07:15.999
So the general idea,
and please wait why you

00:07:15.999 --> 00:07:17.290
should care about this problem.

00:07:17.290 --> 00:07:19.456
We're going to reduce it
to another more interesting

00:07:19.456 --> 00:07:21.020
version of Hamiltonicity.

00:07:21.020 --> 00:07:24.600
But here's one way to represent
3SAT as Hamiltonicity--

00:07:24.600 --> 00:07:27.300
another way, similar to
the one we did before.

00:07:27.300 --> 00:07:29.450
We got clauses here
over on the left.

00:07:29.450 --> 00:07:31.760
Here some of the
clauses have size two,

00:07:31.760 --> 00:07:34.620
but it works for the three case.

00:07:34.620 --> 00:07:38.030
Here we have the variables.

00:07:38.030 --> 00:07:43.370
And the key concept
here is this notation.

00:07:43.370 --> 00:07:48.030
This is shorthand for a
more complicated gadget,

00:07:48.030 --> 00:07:52.040
which is to say that these
two things should not

00:07:52.040 --> 00:07:53.100
be both chosen.

00:07:53.100 --> 00:07:55.910
This is an exclusive OR.

00:07:55.910 --> 00:07:57.710
Exactly one of them
should be chosen.

00:07:57.710 --> 00:08:01.210
So that forces x1 to be
the opposite of x1 bar,

00:08:01.210 --> 00:08:02.862
and it also lets you
duplicate things.

00:08:02.862 --> 00:08:04.820
So here we get multiple
copies of the variable.

00:08:04.820 --> 00:08:06.361
You keep doing that
several times you

00:08:06.361 --> 00:08:09.070
get many copies of variable
and its complement.

00:08:09.070 --> 00:08:12.790
And then we're also going to
use some connections like this.

00:08:12.790 --> 00:08:14.880
We're going to need
a crossover gadget,

00:08:14.880 --> 00:08:18.780
but this will say
that you-- well,

00:08:18.780 --> 00:08:20.910
so this is going to
be some clause which

00:08:20.910 --> 00:08:22.420
it's not literally as drawn.

00:08:22.420 --> 00:08:25.370
Again, this is notation
for a gadget the

00:08:25.370 --> 00:08:29.580
is going to force at least one
of these to be traversable.

00:08:29.580 --> 00:08:31.780
And so that overall
should represent 3SAT.

00:08:31.780 --> 00:08:33.190
We need a clause gadget.

00:08:33.190 --> 00:08:35.919
We need this exclusive
OR so that we can split,

00:08:35.919 --> 00:08:36.690
duplicate things.

00:08:36.690 --> 00:08:39.253
Overall, the cycle's
going to do this.

00:08:39.253 --> 00:08:41.419
It's going to visit all the
variables in order, then

00:08:41.419 --> 00:08:43.159
all the clauses in order.

00:08:43.159 --> 00:08:46.200
So we can't get anything
interesting out of planarity,

00:08:46.200 --> 00:08:48.157
because that graph
with these connections

00:08:48.157 --> 00:08:49.240
is not going to be planar.

00:08:49.240 --> 00:08:50.374
So we'll need a crossover.

00:08:50.374 --> 00:08:52.040
And those are the
three gadgets we need.

00:08:52.040 --> 00:08:52.465
Yeah.

00:08:52.465 --> 00:08:54.157
AUDIENCE: Why were
you using exclusively

00:08:54.157 --> 00:08:57.690
working with [INAUDIBLE]
variables [INAUDIBLE]?

00:08:57.690 --> 00:09:00.170
ERIK DEMAINE: So the idea
is here there's a choice.

00:09:00.170 --> 00:09:03.870
Do I choose this edge or this
edge in the Hamiltonian cycle.

00:09:03.870 --> 00:09:05.700
And I want the choice
for this copy of x1

00:09:05.700 --> 00:09:08.450
to be the same as
for that copy of x1.

00:09:08.450 --> 00:09:12.940
So the exclusive OR forces each
instance of x1 to be the same.

00:09:12.940 --> 00:09:14.560
In general, if
there's k instances,

00:09:14.560 --> 00:09:16.116
you'd have k of these.

00:09:16.116 --> 00:09:18.008
AUDIENCE: Can you connect that?

00:09:18.008 --> 00:09:19.924
Use the same guy to
connect it to the instance

00:09:19.924 --> 00:09:20.876
inside the clause?

00:09:24.700 --> 00:09:29.129
ERIK DEMAINE: I guess the reason
why we need two copies here is

00:09:29.129 --> 00:09:31.670
that you can't-- well, see you
can't have 2 XOR gadgets going

00:09:31.670 --> 00:09:33.680
to the same place.

00:09:33.680 --> 00:09:35.907
So it will be clear once
we've seen the XOR gadget.

00:09:35.907 --> 00:09:38.490
We want two distinct copies so
that these two things can point

00:09:38.490 --> 00:09:41.040
to different copies of x1.

00:09:41.040 --> 00:09:43.155
That's why we're making
a copy like that.

00:09:43.155 --> 00:09:44.502
Does that make sense?

00:09:44.502 --> 00:09:45.710
AUDIENCE: [INAUDIBLE].

00:09:45.710 --> 00:09:46.680
ERIK DEMAINE: OK.

00:09:46.680 --> 00:09:48.500
Excellent.

00:09:48.500 --> 00:09:49.405
Actually, same slide.

00:09:49.405 --> 00:09:51.350
I should just show them.

00:09:51.350 --> 00:09:55.220
So here is-- maybe let's
start with the XOR gadget

00:09:55.220 --> 00:09:59.010
because the clause-- ah,
clause doesn't actually use it.

00:09:59.010 --> 00:10:03.940
So the XOR gadget is if we have
two edges of opposite direction

00:10:03.940 --> 00:10:06.687
relative to the way
we're being connected.

00:10:06.687 --> 00:10:08.270
I think it also works
in the other way

00:10:08.270 --> 00:10:10.970
because these are-- no,
these are also opposite

00:10:10.970 --> 00:10:14.870
if you redraw it this way.

00:10:14.870 --> 00:10:17.570
We're just going to
have this picture, which

00:10:17.570 --> 00:10:19.540
can be traversed.

00:10:19.540 --> 00:10:21.150
Either this guy
can come in-- here

00:10:21.150 --> 00:10:24.930
we're really using direction,
directionality of the graph.

00:10:24.930 --> 00:10:27.740
You can traverse
the top edge or you

00:10:27.740 --> 00:10:32.070
can traverse the bottom edge
in the opposite direction.

00:10:32.070 --> 00:10:35.570
But you can't just turn around
because then these vertices

00:10:35.570 --> 00:10:37.580
would be uncovered.

00:10:37.580 --> 00:10:40.430
And as soon as
you've gone this far,

00:10:40.430 --> 00:10:41.800
you can't come back this way.

00:10:41.800 --> 00:10:43.780
So once you enter here
you're forced to leave there.

00:10:43.780 --> 00:10:44.743
Once you enter
here you're forced

00:10:44.743 --> 00:10:46.826
to leave there, if you
want to cover everything.

00:10:46.826 --> 00:10:48.450
So that's an exclusive
OR, and at least

00:10:48.450 --> 00:10:50.740
one of those better happen.

00:10:50.740 --> 00:10:53.340
So that's what
happens over there.

00:10:53.340 --> 00:10:55.600
And also what we'll
end up doing here,

00:10:55.600 --> 00:10:58.210
except we also need
the crossing case.

00:10:58.210 --> 00:11:00.620
On the other hand,
for the clause,

00:11:00.620 --> 00:11:07.070
the idea is basically there's a
cycle over here, which is fine.

00:11:07.070 --> 00:11:10.300
But somehow that
cycle for that clause

00:11:10.300 --> 00:11:13.530
has to be connected into the big
cycle that we've drawn already.

00:11:13.530 --> 00:11:15.020
And at least one
of the variables

00:11:15.020 --> 00:11:16.810
needs to connect to that.

00:11:16.810 --> 00:11:25.050
So the idea is we
can come up here--

00:11:25.050 --> 00:11:29.230
so also these vertices
need to be covered.

00:11:29.230 --> 00:11:33.870
So we can come up here,
go over here, loop around,

00:11:33.870 --> 00:11:34.790
and be happy.

00:11:34.790 --> 00:11:38.870
And then we've grab
the entire cycle.

00:11:38.870 --> 00:11:42.050
Also, when we've
grabbed this cycle,

00:11:42.050 --> 00:11:50.010
we can also grab these vertices.

00:11:50.010 --> 00:11:51.950
All of them.

00:11:51.950 --> 00:11:56.840
That's only going to be
possible if this is possible.

00:11:56.840 --> 00:12:02.930
So in the outer side, we can't
go here and then up here.

00:12:02.930 --> 00:12:05.450
We can go here over here.

00:12:05.450 --> 00:12:06.900
That's also fine.

00:12:06.900 --> 00:12:08.660
OK.

00:12:08.660 --> 00:12:09.341
Good.

00:12:09.341 --> 00:12:09.840
I see.

00:12:09.840 --> 00:12:13.250
So that the issue is-- so
these are actually flexible.

00:12:13.250 --> 00:12:16.430
These guys can be covered
basically from the right side

00:12:16.430 --> 00:12:18.280
or from the left
side, either way.

00:12:18.280 --> 00:12:22.520
So it doesn't matter whether
you take this path or this path.

00:12:22.520 --> 00:12:26.810
But at least one of these
sort of pairs of edges,

00:12:26.810 --> 00:12:28.800
as they're drawn
over here, you need

00:12:28.800 --> 00:12:31.380
to be able to choose
the left choice

00:12:31.380 --> 00:12:34.430
and, therefore,
get the big cycle.

00:12:34.430 --> 00:12:37.650
And the issue with that is
because you have this XOR,

00:12:37.650 --> 00:12:40.320
it's an exclusive OR, exactly
one of those two things

00:12:40.320 --> 00:12:41.190
must be true.

00:12:41.190 --> 00:12:42.810
So in some cases,
you'll be forced

00:12:42.810 --> 00:12:45.240
to choose the right thing.

00:12:45.240 --> 00:12:47.750
If this variable
chose the right path,

00:12:47.750 --> 00:12:51.340
then this one will also have to
choose the right path because

00:12:51.340 --> 00:12:54.280
of this exclusive OR,
and preventing you

00:12:54.280 --> 00:12:55.780
from grabbing the cycle.

00:12:55.780 --> 00:12:58.700
You're fine in this clause
if at least one of them

00:12:58.700 --> 00:13:00.860
you choose the left path.

00:13:00.860 --> 00:13:02.820
In fact, if you
look very closely

00:13:02.820 --> 00:13:04.570
there's some bold
edges indicating

00:13:04.570 --> 00:13:05.760
which one's got chosen here.

00:13:05.760 --> 00:13:08.650
So here, two of them were
on the right, one of them

00:13:08.650 --> 00:13:10.320
was on the left for this clause.

00:13:10.320 --> 00:13:12.630
In general, if at least
one of them is on the left

00:13:12.630 --> 00:13:16.230
you're OK for the clause.

00:13:16.230 --> 00:13:16.810
Clear.

00:13:16.810 --> 00:13:18.010
The high level now.

00:13:18.010 --> 00:13:21.170
This would work fine if we
didn't care about planarity,

00:13:21.170 --> 00:13:23.400
but I want planar
directed max degree three.

00:13:23.400 --> 00:13:27.260
At this point we should be
directed max degree three.

00:13:27.260 --> 00:13:32.050
So that's an improvement from
last time in terms of degrees.

00:13:32.050 --> 00:13:37.150
And then there's this fun
figure for the crossover.

00:13:37.150 --> 00:13:40.170
So in general, that's
just a repetition

00:13:40.170 --> 00:13:41.810
of what our XOR gadget was.

00:13:41.810 --> 00:13:46.760
Now we have crossing
XOR constraints.

00:13:46.760 --> 00:13:49.190
So here's a typical example.

00:13:49.190 --> 00:13:51.260
Let's say we have
this XOR trying

00:13:51.260 --> 00:13:55.440
to go from there to there and
it crosses these other XORs.

00:13:55.440 --> 00:13:58.510
So what we're going to
do is build something

00:13:58.510 --> 00:14:02.710
like that gadget for the
vertical connection with this,

00:14:02.710 --> 00:14:05.290
and this, and this, and this.

00:14:05.290 --> 00:14:07.270
And we duplicate these edges.

00:14:07.270 --> 00:14:10.205
That doesn't help you-- I mean
it's the same as that picture,

00:14:10.205 --> 00:14:11.820
I just happened
to duplicate them.

00:14:11.820 --> 00:14:13.319
The reason we do
that is we're going

00:14:13.319 --> 00:14:19.670
to put XORs across like this,
and this forces an alternation.

00:14:19.670 --> 00:14:22.650
So if this is in,
then this must be out,

00:14:22.650 --> 00:14:25.430
so this must be in,
so this must be out,

00:14:25.430 --> 00:14:29.030
so this must be in, and
so on all the way through.

00:14:29.030 --> 00:14:31.970
And so that forces an
XOR between this edge

00:14:31.970 --> 00:14:34.990
and that edge.

00:14:34.990 --> 00:14:36.730
Cool?

00:14:36.730 --> 00:14:41.440
So that is the crossing
x over XOR gadget, which

00:14:41.440 --> 00:14:44.000
you plug into all
of these pictures,

00:14:44.000 --> 00:14:48.310
and you end up with planar
directed max degree three.

00:14:48.310 --> 00:14:49.740
All right?

00:14:49.740 --> 00:14:53.050
So far so good.

00:14:53.050 --> 00:14:55.762
Next-- I have a goal.

00:14:55.762 --> 00:14:57.470
I'm still not going
to tell you the goal.

00:15:00.780 --> 00:15:07.980
Next one is going to be planar
bipartite max degree three.

00:15:18.715 --> 00:15:19.215
Undirected.

00:15:21.930 --> 00:15:25.320
This is going to be one of
our simplest reductions ever.

00:15:25.320 --> 00:15:27.210
There it is.

00:15:27.210 --> 00:15:29.720
So the cool thing
about max degree three

00:15:29.720 --> 00:15:33.340
directed-- I mean there are
few cases you can exclude.

00:15:33.340 --> 00:15:35.071
You can't have three
incoming edges.

00:15:35.071 --> 00:15:36.570
You can't have three
outgoing edges.

00:15:36.570 --> 00:15:38.403
It would be pretty hard
to have a cycle that

00:15:38.403 --> 00:15:40.440
includes such vertices.

00:15:40.440 --> 00:15:42.530
So you could have
degree two vertices,

00:15:42.530 --> 00:15:46.080
but I don't think
we even had any.

00:15:46.080 --> 00:15:52.500
Did I say that we had
degree two in this picture?

00:15:52.500 --> 00:15:54.100
Probably not.

00:15:54.100 --> 00:15:57.670
I mean if we did we could
double the edge or something.

00:15:57.670 --> 00:16:02.110
So that was probably actually
planar directed three regular.

00:16:02.110 --> 00:16:05.110
OK, but now undirected.

00:16:05.110 --> 00:16:06.950
But you can basically
have two edges in,

00:16:06.950 --> 00:16:11.790
one out, or one
edge in and two out.

00:16:11.790 --> 00:16:14.534
And we're going to convert that.

00:16:14.534 --> 00:16:15.950
So the interesting
thing here, you

00:16:15.950 --> 00:16:18.110
have to visit this
vertex, which means

00:16:18.110 --> 00:16:22.166
you have to visit this edge
in any Hamiltonian cycle.

00:16:22.166 --> 00:16:23.540
Because once you
come here you've

00:16:23.540 --> 00:16:24.410
got to leave on that edge.

00:16:24.410 --> 00:16:26.160
Similarly, you have
to visit this edge.

00:16:26.160 --> 00:16:27.868
You can tell that just
from this picture.

00:16:27.868 --> 00:16:29.880
So we call these forced edges.

00:16:29.880 --> 00:16:32.810
And we can represent that
by adding a vertex there.

00:16:32.810 --> 00:16:34.720
It says, hey, you've
got to visit that edge.

00:16:34.720 --> 00:16:38.950
So you're going to visit it
by that little path there.

00:16:38.950 --> 00:16:40.810
And now things are bipartite.

00:16:44.800 --> 00:16:46.590
And the bipartiteness
is essentially

00:16:46.590 --> 00:16:49.760
forcing the
directionality as well.

00:16:49.760 --> 00:16:53.800
So let's say when you come
into a vertex and you're blue,

00:16:53.800 --> 00:16:55.830
so that means
these guys have had

00:16:55.830 --> 00:16:59.840
to have been red,
whenever you leave,

00:16:59.840 --> 00:17:02.450
you first visit a red
vertex and then go.

00:17:02.450 --> 00:17:05.579
So here you're coming in
again as blue, and then

00:17:05.579 --> 00:17:07.400
before you leave you turn red.

00:17:07.400 --> 00:17:12.220
And so because you've satisfied
directionality over here,

00:17:12.220 --> 00:17:14.480
the outgoing edge here
becomes an incoming edge

00:17:14.480 --> 00:17:17.000
to the next vertex,
that means you'll

00:17:17.000 --> 00:17:19.510
be going into a blue
vertex either because it's

00:17:19.510 --> 00:17:22.250
like this or like that.

00:17:22.250 --> 00:17:26.836
And you are effectively
forcing directionality.

00:17:30.310 --> 00:17:31.810
I mean everything
could be reversed.

00:17:36.120 --> 00:17:38.675
Because you're always
coming into a blue vertex

00:17:38.675 --> 00:17:39.550
and leaving on a red.

00:17:39.550 --> 00:17:44.100
That forces you to be going
from the tail of an arrow

00:17:44.100 --> 00:17:46.530
to the head of an arrow.

00:17:46.530 --> 00:17:49.430
So same thing by symmetry.

00:17:49.430 --> 00:17:54.910
So these problems are actually
really close to each other.

00:17:54.910 --> 00:17:56.520
These were done in
different papers,

00:17:56.520 --> 00:17:59.210
but this was an older one.

00:17:59.210 --> 00:18:04.160
And then this problem was
introduced for another reason,

00:18:04.160 --> 00:18:07.110
which is grid graphs.

00:18:07.110 --> 00:18:08.602
This is where I
really want to go.

00:18:14.750 --> 00:18:19.500
So the idea with the
grid graph is you,

00:18:19.500 --> 00:18:27.405
let's say, have a set of
points on the square lattice.

00:18:35.160 --> 00:18:38.580
And then you're going to have
an edge whenever you have

00:18:38.580 --> 00:18:40.090
two points at unit distance.

00:18:45.580 --> 00:18:49.130
So let me draw an example.

00:18:49.130 --> 00:18:52.560
Cheat, and have some
examples drawn for me.

00:18:52.560 --> 00:18:56.010
This was in a much more recent
paper, but some nice pictures.

00:18:56.010 --> 00:18:59.900
So we're just choosing a set
of points in the square grid.

00:18:59.900 --> 00:19:02.180
And then whenever we
have two points that

00:19:02.180 --> 00:19:03.642
are a unit distance
apart, you're

00:19:03.642 --> 00:19:04.850
forced to have an edge there.

00:19:04.850 --> 00:19:06.100
You can't say there's no edge.

00:19:06.100 --> 00:19:08.990
That would be a sub-graph
of a grid graph.

00:19:08.990 --> 00:19:11.130
But for example, when
this point is absent,

00:19:11.130 --> 00:19:14.510
you don't get any
connections through here.

00:19:14.510 --> 00:19:17.100
So these are all
examples of grid graphs.

00:19:19.900 --> 00:19:23.210
Now there's one special
case, or in general, we

00:19:23.210 --> 00:19:26.490
distinguish-- there's sort
of three types of faces

00:19:26.490 --> 00:19:27.920
in such a planar graph.

00:19:27.920 --> 00:19:30.640
There's what you might
call pixels-- little one

00:19:30.640 --> 00:19:32.070
by one squares.

00:19:32.070 --> 00:19:35.570
There's the outside
face, and then there's

00:19:35.570 --> 00:19:37.300
everything else
which we call holes.

00:19:37.300 --> 00:19:43.195
So any non-length for
face we call hole.

00:19:43.195 --> 00:19:47.690
If there are no holes we
call it a solid grid graph.

00:19:47.690 --> 00:19:51.110
This is interesting
because solid grid

00:19:51.110 --> 00:19:53.370
graphs you can
solve Hamiltonicity

00:19:53.370 --> 00:19:55.660
in polynomial time.

00:19:55.660 --> 00:19:59.070
It's not always possible, but
there is a polynomial time

00:19:59.070 --> 00:20:02.570
algorithm for solving
the solid grid graph

00:20:02.570 --> 00:20:06.255
case by Umens and Lenhart, '97.

00:20:06.255 --> 00:20:08.800
A very complicated algorithm.

00:20:08.800 --> 00:20:10.460
Luckily, this is a
hardness proof class

00:20:10.460 --> 00:20:13.710
so I don't have to cover it.

00:20:13.710 --> 00:20:16.465
I'm going to focus on the
hardness when you allow holes.

00:20:20.270 --> 00:20:23.430
So this is where things get fun.

00:20:23.430 --> 00:20:28.200
We are going to reduce-- we did
a reduction from here to here.

00:20:28.200 --> 00:20:31.500
We're going to do a
reduction from here to here.

00:20:31.500 --> 00:20:34.050
So we're going to suppose that
we want to solve Hamiltonicity

00:20:34.050 --> 00:20:37.370
in planar bipartite max
degree three graphs,

00:20:37.370 --> 00:20:39.960
and we're going to convert such
a planar bipartite max degree

00:20:39.960 --> 00:20:40.690
three.

00:20:40.690 --> 00:20:46.370
Graph into a grid graph
that acts the same.

00:20:49.520 --> 00:20:56.900
So the first step is to
draw the graph on a grid.

00:20:56.900 --> 00:21:00.200
That's pretty obvious.

00:21:00.200 --> 00:21:02.310
So here's an example
of what we want to do,

00:21:02.310 --> 00:21:04.400
and then this is a
picture of how to do it.

00:21:04.400 --> 00:21:06.977
Suppose you have a
bipartite planar graph.

00:21:06.977 --> 00:21:08.810
Not obvious this is
planar, but it's obvious

00:21:08.810 --> 00:21:09.643
that it's bipartite.

00:21:09.643 --> 00:21:10.690
It happens to be planar.

00:21:10.690 --> 00:21:12.760
It's max degree three.

00:21:12.760 --> 00:21:16.410
And the vertices are
labeled, the XIs and the YIs,

00:21:16.410 --> 00:21:18.740
and you can see the
corresponding labeling here.

00:21:18.740 --> 00:21:22.280
So not all of the grid dots
are going to be labeled.

00:21:22.280 --> 00:21:23.740
Some of them are just auxiliary.

00:21:23.740 --> 00:21:25.680
In order to connect
to vertices we're

00:21:25.680 --> 00:21:30.150
going to have to draw paths,
orthogonal paths on the grid.

00:21:30.150 --> 00:21:33.710
But the key thing I
want is the square grid

00:21:33.710 --> 00:21:37.000
has a two-coloring inherently,
and I want that two-coloring

00:21:37.000 --> 00:21:38.740
to match this two-coloring.

00:21:38.740 --> 00:21:41.620
That's what I would call a
parity-preserving embedding

00:21:41.620 --> 00:21:44.770
of the Graph

00:21:44.770 --> 00:21:48.210
And you can see in this example,
the three XIs are white,

00:21:48.210 --> 00:21:51.300
and the three YIs are black.

00:21:51.300 --> 00:21:54.212
And if you check all the
edges they should correspond.

00:21:54.212 --> 00:21:55.670
Just ignore the
dash lines-- that's

00:21:55.670 --> 00:21:59.460
to show you the grid underlying.

00:21:59.460 --> 00:22:01.140
So this is a valid embedding.

00:22:01.140 --> 00:22:02.500
How do we do it?

00:22:02.500 --> 00:22:05.397
Well, we just take any
embedding in the grid.

00:22:05.397 --> 00:22:07.730
It's well known that if you
have a max degree four graph

00:22:07.730 --> 00:22:10.270
you can draw it in the
grid without crossings,

00:22:10.270 --> 00:22:12.580
and each edge is some
orthogonal polyline.

00:22:15.530 --> 00:22:17.990
I won't prove that here.

00:22:17.990 --> 00:22:22.130
And then suppose the parity's
wrong for some vertex.

00:22:22.130 --> 00:22:25.560
Suppose you draw vertex B
and it happens to be black,

00:22:25.560 --> 00:22:27.320
but you want it to be white?

00:22:27.320 --> 00:22:29.310
Then I'm just going to
shift it over by one

00:22:29.310 --> 00:22:32.710
and do these kinds of
wiggles, and that's it.

00:22:32.710 --> 00:22:35.610
So you scale everything
by a factor of three

00:22:35.610 --> 00:22:38.010
and you'll have room
to do those wiggles.

00:22:38.010 --> 00:22:40.500
So take an arbitrary
orthogonal grid drawing

00:22:40.500 --> 00:22:44.615
and then add the
wiggles whenever

00:22:44.615 --> 00:22:46.740
things are in the wrong
parity and now every vertex

00:22:46.740 --> 00:22:48.970
will be in the correct parity.

00:22:48.970 --> 00:22:52.730
That will be crucial
for the reduction.

00:22:52.730 --> 00:22:57.830
So at this point we've got an
orthogonal parity-preserving

00:22:57.830 --> 00:23:02.760
drawing of our given bipartite
planar max degree three graph.

00:23:02.760 --> 00:23:06.760
And the issue is there are sort
of two types of vertices here.

00:23:06.760 --> 00:23:09.169
There's the ones there
we really need to visit,

00:23:09.169 --> 00:23:10.710
and then there's
these other vertices

00:23:10.710 --> 00:23:12.890
which are representing edges.

00:23:12.890 --> 00:23:15.560
We don't need to visit every
edge-- that's the tour problem.

00:23:15.560 --> 00:23:18.830
Hamiltonian tour, we just need
to visit every vertex which

00:23:18.830 --> 00:23:22.030
are the labeled dots over here.

00:23:22.030 --> 00:23:25.730
So this is where things get fun.

00:23:25.730 --> 00:23:30.190
Here is a key gadget before we
see the overall architecture.

00:23:30.190 --> 00:23:32.597
These are called tentacles
in the original paper.

00:23:32.597 --> 00:23:34.680
I'm calling them edge
gadgets because they're just

00:23:34.680 --> 00:23:37.210
simulating a single edge
of the original graph,

00:23:37.210 --> 00:23:38.610
but tentacles is cooler.

00:23:38.610 --> 00:23:40.530
Whichever you prefer.

00:23:40.530 --> 00:23:43.400
So these are the
dots that haven't all

00:23:43.400 --> 00:23:45.570
been drawn explicitly here.

00:23:45.570 --> 00:23:48.330
And so it's just like a two
by and sort of corridor.

00:23:48.330 --> 00:23:53.160
The base version would be this,
but if you want to have turns,

00:23:53.160 --> 00:23:54.910
which we're going to
need 90 degree turns,

00:23:54.910 --> 00:23:57.050
it looks more like this.

00:23:57.050 --> 00:23:59.170
And there's basically
two ways to cover this.

00:23:59.170 --> 00:24:00.080
Sort of three ways.

00:24:00.080 --> 00:24:01.940
But the way parity
will work out,

00:24:01.940 --> 00:24:04.280
there will only be two
ways that we care about.

00:24:04.280 --> 00:24:06.695
There's not a variable gadget.

00:24:06.695 --> 00:24:09.330
It looks like maybe
a variable gadget,

00:24:09.330 --> 00:24:11.380
but that's not how
we're using it.

00:24:11.380 --> 00:24:15.340
So one way you can visit this
gadget is to zigzag like this.

00:24:15.340 --> 00:24:18.500
We've seen this in pretty
much all of our planar

00:24:18.500 --> 00:24:20.270
Hamiltonicity proofs.

00:24:20.270 --> 00:24:22.460
The core idea's the same.

00:24:22.460 --> 00:24:27.000
You could start at A and end
at C, or you could start at B

00:24:27.000 --> 00:24:29.815
and end at D, and that's
true in this version as well.

00:24:29.815 --> 00:24:31.190
Once you start
alternating you're

00:24:31.190 --> 00:24:32.590
forced to alternate
all the way through.

00:24:32.590 --> 00:24:34.630
So you could imagine
using that for a wire,

00:24:34.630 --> 00:24:36.730
but we're not going to
use the two alternations.

00:24:36.730 --> 00:24:39.580
By parity we'll be forced to
do it one way or the other.

00:24:39.580 --> 00:24:42.000
We'll be told whether
we're starting or ending

00:24:42.000 --> 00:24:45.830
in one of them, I think.

00:24:45.830 --> 00:24:47.379
Well, it won't matter.

00:24:47.379 --> 00:24:49.170
But there's this other
way you could visit,

00:24:49.170 --> 00:24:51.162
which is to just go all
the way down then come

00:24:51.162 --> 00:24:51.870
all the way back.

00:24:55.260 --> 00:24:57.920
This is going to
correspond to an edge that

00:24:57.920 --> 00:25:00.600
is in the Hamiltonian cycle.

00:25:00.600 --> 00:25:03.020
Because I want to start
at some vertex up here,

00:25:03.020 --> 00:25:06.530
and I want to end at some vertex
down here if I follow the edge.

00:25:06.530 --> 00:25:10.760
This is going to correspond
to an edge that we don't use.

00:25:10.760 --> 00:25:13.360
Because at this
vertex, I still need

00:25:13.360 --> 00:25:15.866
to cover these vertices
somehow, but I don't

00:25:15.866 --> 00:25:16.990
want that to really matter.

00:25:16.990 --> 00:25:19.210
I want this edge to
be coverable for free.

00:25:19.210 --> 00:25:21.810
So the idea is as I visit
this vertex we're just going

00:25:21.810 --> 00:25:23.530
to zip down here, zip back up.

00:25:23.530 --> 00:25:27.530
And all these vertices
get visited for free.

00:25:27.530 --> 00:25:30.270
It's not really
part of the tour.

00:25:30.270 --> 00:25:33.420
Let me show you in
some more detail.

00:25:33.420 --> 00:25:35.050
Here's what a vertex looks like.

00:25:35.050 --> 00:25:39.940
Vertex is just going to
be a 3 by 3 grid of dots.

00:25:39.940 --> 00:25:42.120
Now, remember there are
two kinds of vertices.

00:25:42.120 --> 00:25:44.630
There's the ones
that were-- so again,

00:25:44.630 --> 00:25:47.470
we're expanding everything
for this to work out.

00:25:47.470 --> 00:25:49.370
The vertices that
were originally white

00:25:49.370 --> 00:25:51.326
and the vertices that
were originally black.

00:25:51.326 --> 00:25:52.700
It doesn't matter
which is which,

00:25:52.700 --> 00:25:54.930
but there's two
classes of vertices.

00:25:54.930 --> 00:25:59.720
And we're going to attach
the edge gadgets, which were

00:25:59.720 --> 00:26:02.390
these 2 by n kind of things.

00:26:02.390 --> 00:26:05.220
So this is all edge gadget here.

00:26:05.220 --> 00:26:07.740
We're going to attach
it to a vertex that's

00:26:07.740 --> 00:26:13.370
white in this sort of flush
length two connection.

00:26:13.370 --> 00:26:16.140
So this is the variable up
here, this 3 by 3 thing,

00:26:16.140 --> 00:26:21.150
and here we're having two edges
connecting to the edge gadget.

00:26:21.150 --> 00:26:22.770
For the black
vertices we're only

00:26:22.770 --> 00:26:25.050
going to have a single
edge connecting them.

00:26:25.050 --> 00:26:29.350
This is called a pin
connection, between the wire

00:26:29.350 --> 00:26:33.650
gadget or the tentacle,
and the 3 by 3 down here.

00:26:33.650 --> 00:26:34.300
OK.

00:26:34.300 --> 00:26:34.800
Why?

00:26:37.410 --> 00:26:40.240
Because.

00:26:40.240 --> 00:26:43.420
So here let's
consider two vertices

00:26:43.420 --> 00:26:45.750
that are attached by an edge.

00:26:45.750 --> 00:26:47.050
So they have opposite parity.

00:26:47.050 --> 00:26:49.170
One's-- I've forgotten
which is which.

00:26:49.170 --> 00:26:51.287
This is white and
this black I think.

00:26:51.287 --> 00:26:52.620
Here we have the pin connection.

00:26:52.620 --> 00:26:55.200
Here we have the
length two connection.

00:26:55.200 --> 00:26:58.280
And the idea is there's exactly
two ways to traverse this edge,

00:26:58.280 --> 00:26:59.091
as we saw.

00:26:59.091 --> 00:27:00.590
But now you can see
the connections.

00:27:00.590 --> 00:27:02.060
Let me put it that way.

00:27:02.060 --> 00:27:03.727
So the idea is, well,
maybe you choose

00:27:03.727 --> 00:27:05.560
to use that edge in the
cycle, and so I want

00:27:05.560 --> 00:27:07.340
to be able to just traverse it.

00:27:07.340 --> 00:27:08.500
Everything is good.

00:27:08.500 --> 00:27:10.130
And so here I know
that I'm entering

00:27:10.130 --> 00:27:11.540
at this point, which
means I know that I'll

00:27:11.540 --> 00:27:12.660
have to be exiting here.

00:27:12.660 --> 00:27:14.610
So the parities are forced.

00:27:14.610 --> 00:27:17.610
So the zigzag parity is forced.

00:27:17.610 --> 00:27:20.200
The other possibility, because
there's only one connection

00:27:20.200 --> 00:27:23.980
here, you couldn't traverse
this way and then come back.

00:27:23.980 --> 00:27:27.250
But from this side you could
traverse and then come back.

00:27:27.250 --> 00:27:29.620
And it doesn't touch
the vertex at all.

00:27:29.620 --> 00:27:32.370
So the idea is you could
ignore this edge entirely

00:27:32.370 --> 00:27:35.765
and it gets covered for free,
provided once you erase this,

00:27:35.765 --> 00:27:40.970
this edge is in the
Hamiltonian tour.

00:27:40.970 --> 00:27:44.710
And at this point I should
mention what all this labeling

00:27:44.710 --> 00:27:46.500
means on the vertex gadget.

00:27:46.500 --> 00:27:48.480
The idea is for
this vertex, if you

00:27:48.480 --> 00:27:52.350
start at any of the PIs,
any of the four corners--

00:27:52.350 --> 00:27:55.700
any of the private
investigators-- then

00:27:55.700 --> 00:28:01.450
you can end at any other
PI, PJ in such a way

00:28:01.450 --> 00:28:03.710
that you visit all
three of the EIs.

00:28:06.590 --> 00:28:08.030
AUDIENCE: There
are four of them.

00:28:08.030 --> 00:28:09.571
ERIK DEMAINE: There
are four of them.

00:28:09.571 --> 00:28:12.890
EI, EO, EIEI-O. No, OK.

00:28:12.890 --> 00:28:15.940
So let me get to the point.

00:28:15.940 --> 00:28:17.810
You could start
at PI, end at PJ,

00:28:17.810 --> 00:28:23.620
and visit all the vertices and
all of the EIs, all of the EKs.

00:28:23.620 --> 00:28:26.420
So for example, if I want
to go from here to here,

00:28:26.420 --> 00:28:30.360
I can go like this,
visited all the edges.

00:28:30.360 --> 00:28:32.530
If I want to go
from here to here,

00:28:32.530 --> 00:28:36.530
I can go like this,
visited all the vertices,

00:28:36.530 --> 00:28:38.530
visited all the EIs.

00:28:38.530 --> 00:28:41.560
So that's good because
each of these EIs

00:28:41.560 --> 00:28:44.670
is potentially attached
to an edge gadget

00:28:44.670 --> 00:28:46.950
and we might want to visit
all of the things out there

00:28:46.950 --> 00:28:48.770
and come back.

00:28:48.770 --> 00:28:50.570
OK?

00:28:50.570 --> 00:28:58.740
So you see the reason why we
only want a pin connection here

00:28:58.740 --> 00:29:02.480
is if we had a full
connection with two edges,

00:29:02.480 --> 00:29:04.400
you might imagine that
you come out here,

00:29:04.400 --> 00:29:07.120
do something, eventually
do other stuff,

00:29:07.120 --> 00:29:09.039
and then come back on this path.

00:29:09.039 --> 00:29:10.830
But because we have a
pin connection always

00:29:10.830 --> 00:29:13.820
on one of the two
sides, you can't have

00:29:13.820 --> 00:29:15.710
two separate traversal paths.

00:29:15.710 --> 00:29:18.370
As soon as you get here you
have to turn back around.

00:29:18.370 --> 00:29:19.870
If you went this
way, then this guy

00:29:19.870 --> 00:29:23.230
would never be
visible in a cycle.

00:29:23.230 --> 00:29:24.670
So that's the key thing.

00:29:24.670 --> 00:29:26.870
This was one of the
EIs, and so the idea

00:29:26.870 --> 00:29:28.876
is you can completely
forget about this path.

00:29:28.876 --> 00:29:30.500
You can just think
about going from one

00:29:30.500 --> 00:29:31.961
of these white
vertices to another.

00:29:31.961 --> 00:29:33.460
In general, it's
going to correspond

00:29:33.460 --> 00:29:38.050
to which edge gadgets that
vertex gadget is connected to.

00:29:42.502 --> 00:29:44.210
So you can go from
one vertex to another.

00:29:44.210 --> 00:29:45.310
You will visit this edge.

00:29:45.310 --> 00:29:48.070
And so you can add in this
part if you don't use the edge.

00:29:48.070 --> 00:29:49.632
If you do use the
edge, then you'll

00:29:49.632 --> 00:29:51.465
be starting from one
of these white vertices

00:29:51.465 --> 00:29:53.410
and you want to go to this one.

00:29:53.410 --> 00:29:55.239
And then you'll
follow this path.

00:29:55.239 --> 00:29:56.780
And then you get to
this vertex, then

00:29:56.780 --> 00:29:58.279
you'll go from one
of black vertices

00:29:58.279 --> 00:30:01.020
to one of the other
four corners, and so on.

00:30:01.020 --> 00:30:01.520
Question?

00:30:01.520 --> 00:30:04.280
AUDIENCE: Should that
line of three white dots,

00:30:04.280 --> 00:30:06.030
shouldn't they all be black?

00:30:06.030 --> 00:30:08.170
ERIK DEMAINE: Yes,
this should be black.

00:30:08.170 --> 00:30:09.040
It's not my fault.

00:30:09.040 --> 00:30:11.470
It could be the
scanner or it could

00:30:11.470 --> 00:30:14.010
be-- this is a hand-drawn
figure as you might guess.

00:30:14.010 --> 00:30:15.890
So yeah, that should be black.

00:30:15.890 --> 00:30:17.380
Everything should alternate.

00:30:17.380 --> 00:30:20.020
So you can tell the
parity's a vertex based

00:30:20.020 --> 00:30:23.620
on the color of the corners.

00:30:23.620 --> 00:30:28.366
Any other questions
about that proof?

00:30:28.366 --> 00:30:28.866
OK.

00:30:31.790 --> 00:30:33.910
So this is pretty cool.

00:30:33.910 --> 00:30:37.290
And I would say
Hamiltonicity in grid graphs

00:30:37.290 --> 00:30:40.620
is used a lot as a base
problem for reductions

00:30:40.620 --> 00:30:45.530
in computational geometry,
especially tour-like problems.

00:30:45.530 --> 00:30:47.350
And you'll notice a theme.

00:30:47.350 --> 00:30:50.100
Every reduction so far, except
the very first one I guess,

00:30:50.100 --> 00:30:51.880
was from one type of
Hamiltonian circuit

00:30:51.880 --> 00:30:53.505
to another type of
Hamiltonian circuit.

00:30:53.505 --> 00:30:57.287
And this tends to be common that
you can work within Hamiltonian

00:30:57.287 --> 00:30:59.370
circuit and modify your
graph in all sorts of ways

00:30:59.370 --> 00:31:02.440
to get to a very simplified
version of Hamiltonian circuit.

00:31:02.440 --> 00:31:04.270
And that's cool.

00:31:04.270 --> 00:31:07.320
And so you get a lot of mileage
just within the Hamiltonian

00:31:07.320 --> 00:31:08.565
circuit family.

00:31:12.160 --> 00:31:12.710
Cool.

00:31:12.710 --> 00:31:16.420
Let me give you a couple of
applications right off the bat.

00:31:16.420 --> 00:31:17.280
What?

00:31:17.280 --> 00:31:19.030
AUDIENCE: This is going
back a little bit,

00:31:19.030 --> 00:31:22.600
but are there any sort of
natural families of graphs

00:31:22.600 --> 00:31:24.340
for which finding
a Hamiltonian path

00:31:24.340 --> 00:31:26.490
is strictly easier
than finding a circle?

00:31:29.420 --> 00:31:33.450
ERIK DEMAINE: I think the only--
this problem would be easy.

00:31:33.450 --> 00:31:35.580
Find a Hamiltonian path
given a Hamiltonian path.

00:31:35.580 --> 00:31:40.300
But I'm not aware of any other
problems where a Hamiltonian

00:31:40.300 --> 00:31:43.360
path is easier than cycle.

00:31:43.360 --> 00:31:44.940
I mean in general,
you can reduce one

00:31:44.940 --> 00:31:47.250
to the other somehow.

00:31:47.250 --> 00:31:49.990
That's maybe a little tricky
without the two given end

00:31:49.990 --> 00:31:52.090
points.

00:31:52.090 --> 00:31:53.830
And if you have
lots of structure,

00:31:53.830 --> 00:31:57.120
like planarity and through
regularity it's not so clear,

00:31:57.120 --> 00:31:59.950
but definitely Hamiltonian path
is still hard in this problem.

00:31:59.950 --> 00:32:02.880
I think one easy
way to do that is

00:32:02.880 --> 00:32:05.220
to just do the same
chain of reductions,

00:32:05.220 --> 00:32:08.030
but start with Hamiltonian
path instead of cycle

00:32:08.030 --> 00:32:10.240
and follow through, and
pretty much every step

00:32:10.240 --> 00:32:13.020
should still be path-based.

00:32:13.020 --> 00:32:14.880
So it's actually useful.

00:32:14.880 --> 00:32:19.010
We'll want Hamiltonian path and
grid graphs also at some point.

00:32:19.010 --> 00:32:21.429
But what I showed was
Hamiltonian cycle.

00:32:21.429 --> 00:32:23.720
So for pretty much everywhere
they seem to be the same,

00:32:23.720 --> 00:32:25.594
but it would be cool to
find an example where

00:32:25.594 --> 00:32:28.790
they have different complexity.

00:32:28.790 --> 00:32:30.170
OK.

00:32:30.170 --> 00:32:32.916
So here's another problem.

00:32:32.916 --> 00:32:34.130
Euclidean TSP.

00:32:39.330 --> 00:32:40.970
Traveling salesman problem.

00:32:40.970 --> 00:32:45.300
You're given a set of
points in the plane.

00:32:45.300 --> 00:32:48.810
Better not make it too big
because this might be hard.

00:32:48.810 --> 00:32:52.185
And I want to find a tour.

00:32:52.185 --> 00:32:55.270
It visits every
point exactly once,

00:32:55.270 --> 00:32:58.700
and has minimum total
length, Euclidean length.

00:32:58.700 --> 00:33:02.066
So the usual notion of length.

00:33:02.066 --> 00:33:04.260
I claim this is NP-hard.

00:33:04.260 --> 00:33:05.496
Now, this is a little scary.

00:33:05.496 --> 00:33:08.120
Most of the problems we've been
working with are very discrete.

00:33:08.120 --> 00:33:09.911
I mean the output here
is sort of discrete.

00:33:09.911 --> 00:33:13.090
You choose a permutation
on the points.

00:33:13.090 --> 00:33:15.880
But it feels like there's
almost no control here.

00:33:15.880 --> 00:33:18.720
I mean how would I construct
localized gadgets when

00:33:18.720 --> 00:33:22.100
I can just jump from any point
to any other point at any time

00:33:22.100 --> 00:33:25.190
as long as that point
hasn't already been used.

00:33:25.190 --> 00:33:27.760
But it's really easy to
prove this is NP-hard

00:33:27.760 --> 00:33:29.920
given what we just did.

00:33:29.920 --> 00:33:33.814
Oh, I should say, here's
a full worked out example,

00:33:33.814 --> 00:33:35.480
so this is what I
should be pointing at.

00:33:35.480 --> 00:33:41.430
This was the parity-preserving
graph that we drew before.

00:33:41.430 --> 00:33:44.190
And this is what you
get in the reduction,

00:33:44.190 --> 00:33:46.230
along with actual
solution, which is

00:33:46.230 --> 00:33:49.880
the one drawn in orange here.

00:33:49.880 --> 00:33:52.960
So you can see read that
off, because wherever

00:33:52.960 --> 00:33:57.530
you see zigzags, that's where
you're using the path here.

00:33:57.530 --> 00:34:02.130
So these correspond, and
then this corresponds.

00:34:02.130 --> 00:34:04.000
And then up and over.

00:34:04.000 --> 00:34:08.400
And then the unused edges,
the not orange ones,

00:34:08.400 --> 00:34:10.870
that's where we get
these kinds of loops,

00:34:10.870 --> 00:34:14.810
starting from the
vertices of one parity,

00:34:14.810 --> 00:34:18.460
I guess the white ones, and
then going to the black ones

00:34:18.460 --> 00:34:21.770
and turning around
at the pin joint.

00:34:21.770 --> 00:34:22.800
Cool.

00:34:22.800 --> 00:34:26.654
So given this is hard,
why is this hard?

00:34:30.170 --> 00:34:32.190
So the decision
problem, let's say,

00:34:32.190 --> 00:34:34.010
is I give you a set of points.

00:34:34.010 --> 00:34:36.630
I give you the desired
length of the tour.

00:34:36.630 --> 00:34:39.900
I want to know is there a tour,
visits every point exactly

00:34:39.900 --> 00:34:44.066
once, and has length at
most that given length.

00:34:44.066 --> 00:34:48.467
AUDIENCE: So if you
look at a grid graph,

00:34:48.467 --> 00:34:50.284
you'll have some
number of nodes,

00:34:50.284 --> 00:34:53.124
which means the tour would
have to necessarily have-- it

00:34:53.124 --> 00:34:54.900
can just choose those points.

00:34:54.900 --> 00:34:57.090
The tour would necessarily
have at least-- exactly

00:34:57.090 --> 00:35:00.562
that many edges,
and each edge would

00:35:00.562 --> 00:35:02.370
have to have length
at least one,

00:35:02.370 --> 00:35:06.010
because the close [INAUDIBLE]
points is one apart.

00:35:06.010 --> 00:35:06.760
ERIK DEMAINE: Yup.

00:35:06.760 --> 00:35:08.759
AUDIENCE: And so if you
just counter [INAUDIBLE]

00:35:08.759 --> 00:35:11.327
those points and say
that that's the desired

00:35:11.327 --> 00:35:12.910
length of your tour,
then you can only

00:35:12.910 --> 00:35:15.410
do that if you can get through
this by following only edges

00:35:15.410 --> 00:35:16.724
that are length one.

00:35:16.724 --> 00:35:17.640
ERIK DEMAINE: Exactly.

00:35:17.640 --> 00:35:20.560
So we're going to reduce
from this problem.

00:35:20.560 --> 00:35:23.620
Given such a grid
graph, the reduction

00:35:23.620 --> 00:35:26.080
just looks at the vertices,
throws away the edges.

00:35:26.080 --> 00:35:31.280
That is our input-- those
points are the input to TSP.

00:35:31.280 --> 00:35:34.200
And then the claim
is that every tour--

00:35:34.200 --> 00:35:36.620
let's say there are end
points in this picture.

00:35:36.620 --> 00:35:38.862
Every tour has to have length
at least n, as you say,

00:35:38.862 --> 00:35:41.070
because they're end points,
the total number of edges

00:35:41.070 --> 00:35:44.010
is n in a cycle, a
Hamiltonian cycle,

00:35:44.010 --> 00:35:47.520
and every edge must have
length at least one,

00:35:47.520 --> 00:35:49.600
because that's the nearest pair.

00:35:49.600 --> 00:35:52.311
And so that's a lower bound.

00:35:52.311 --> 00:35:53.810
And then on the
other hand, if there

00:35:53.810 --> 00:35:58.437
is a tour that
has length only n,

00:35:58.437 --> 00:36:00.270
then it must actually
be a Hamiltonian cycle

00:36:00.270 --> 00:36:02.280
in this graph,
because then you're

00:36:02.280 --> 00:36:04.837
only using edges that
exist in the grid graph.

00:36:04.837 --> 00:36:06.170
So it's really the same problem.

00:36:06.170 --> 00:36:08.670
Euclidean TSP really is
a special case of this.

00:36:11.780 --> 00:36:14.310
Cool.

00:36:14.310 --> 00:36:16.190
This problem was proved
hard much earlier.

00:36:18.890 --> 00:36:22.710
Hamiltonicity and grid graph.

00:36:26.100 --> 00:36:29.700
But here is now a nice simple
proof using what we know.

00:36:32.580 --> 00:36:36.200
I'll tell you more
reasons in a little bit,

00:36:36.200 --> 00:36:40.870
but I have one more at this
point, which is platform games.

00:36:44.830 --> 00:36:46.560
I don't have a graphic
because there's

00:36:46.560 --> 00:36:49.790
so many games that
could apply here,

00:36:49.790 --> 00:36:51.790
Super Mario Brothers among them.

00:36:51.790 --> 00:36:56.440
Suppose you have a little
dude, you can walk around.

00:36:56.440 --> 00:36:59.630
And you've got some
kind of coins--

00:36:59.630 --> 00:37:01.290
I don't know how to draw coins.

00:37:01.290 --> 00:37:02.630
They almost look like eyeballs.

00:37:02.630 --> 00:37:04.840
But anyway, you've
got a bunch of coins

00:37:04.840 --> 00:37:07.712
which you want to collect.

00:37:07.712 --> 00:37:09.670
And you have some way
that you can walk around.

00:37:09.670 --> 00:37:11.790
If you're a top-down
game, then that's

00:37:11.790 --> 00:37:14.450
pretty much the
entire reduction.

00:37:14.450 --> 00:37:17.890
And then also you have a timer.

00:37:17.890 --> 00:37:26.490
So timer plus collectibles--
ables or ibles?

00:37:26.490 --> 00:37:28.630
Ables.

00:37:28.630 --> 00:37:34.160
And any such game is
NP-hard, at least,

00:37:34.160 --> 00:37:36.520
because if you want to get
all of these coins, that's

00:37:36.520 --> 00:37:38.350
like vertices you need to visit.

00:37:38.350 --> 00:37:41.930
As I say, a top-down game
you're walking in a grid graph.

00:37:41.930 --> 00:37:45.580
The time limit will
prevent us from going out

00:37:45.580 --> 00:37:48.141
into the white space because
there's no coins there.

00:37:48.141 --> 00:37:50.640
And so if the timeline limit
is exactly the number of coins,

00:37:50.640 --> 00:37:53.170
and every step you make
you have to get a coin,

00:37:53.170 --> 00:37:56.950
then that will force you to only
follow-- the edges in the grid

00:37:56.950 --> 00:37:59.165
graph can't go out here.

00:37:59.165 --> 00:38:01.990
No obstacles needed.

00:38:01.990 --> 00:38:04.410
And you understand that in
the real game, of course,

00:38:04.410 --> 00:38:06.010
there might be stuff
happening here.

00:38:06.010 --> 00:38:08.985
Maybe there's a ladder
so you can go up here.

00:38:08.985 --> 00:38:11.110
You just have to set up
all these traversal lengths

00:38:11.110 --> 00:38:14.652
to take the same amount of
time in under optimal play.

00:38:14.652 --> 00:38:17.110
And then you can simulate a
ton of video games in this way.

00:38:20.330 --> 00:38:22.120
This is a result.

00:38:22.120 --> 00:38:26.290
This is in Fun 2010 by Forishek.

00:38:26.290 --> 00:38:28.530
So some reasons why you care.

00:38:28.530 --> 00:38:31.650
A lot of games map
naturally onto grids.

00:38:31.650 --> 00:38:36.620
A lot of real problems
can map onto grids.

00:38:36.620 --> 00:38:38.270
In general, grids
will be very helpful.

00:38:42.110 --> 00:38:47.750
So next problem I
want to solve is--

00:38:47.750 --> 00:38:52.250
by solve, I mean
show hard, as usual.

00:38:52.250 --> 00:38:58.715
Let's say, max degree
three grid graphs.

00:39:03.670 --> 00:39:05.500
I don't have a great
motivation-- well,

00:39:05.500 --> 00:39:07.650
I have a motivation for this.

00:39:07.650 --> 00:39:09.250
Probably others that
I'm not aware of.

00:39:09.250 --> 00:39:12.300
I didn't actually know about
this result until recently.

00:39:12.300 --> 00:39:13.420
It's pretty cool.

00:39:13.420 --> 00:39:15.829
If you look at this reduction,
there are some vertices

00:39:15.829 --> 00:39:17.620
that-- I mean here
we're drawing the cycle,

00:39:17.620 --> 00:39:19.240
but some vertices
have degree four.

00:39:19.240 --> 00:39:23.270
Of course, every grid
graph is max degree four.

00:39:23.270 --> 00:39:28.440
And max degree two is pretty
easy to solve Hamiltonicity.

00:39:28.440 --> 00:39:30.600
So what's left is
max degree three.

00:39:30.600 --> 00:39:33.230
So a natural question in
between is can you do max degree

00:39:33.230 --> 00:39:34.485
three grid graphs.

00:39:34.485 --> 00:39:36.870
The claim is that is also hard.

00:39:36.870 --> 00:39:38.890
And it's going to be
basically the same proof,

00:39:38.890 --> 00:39:43.507
but we're going to change all
the gadgets, most of them.

00:39:43.507 --> 00:39:44.590
There's one shared author.

00:39:44.590 --> 00:39:47.900
This was Eti Papadimitriou
and Szwarcfiter.

00:39:50.620 --> 00:39:53.890
And then this is
Papadimitriou and Vazirani

00:39:53.890 --> 00:39:55.860
a couple years later.

00:39:55.860 --> 00:39:59.815
So this is actually
very similar to the edge

00:39:59.815 --> 00:40:00.690
gadget we saw before.

00:40:00.690 --> 00:40:03.730
Here's the old edge gadget.

00:40:03.730 --> 00:40:06.430
Before when we had a turn
we had a degree four vertex.

00:40:06.430 --> 00:40:08.940
I want to get rid of that,
and I'm going to get rid of it

00:40:08.940 --> 00:40:11.880
by just sort of shifting these
things apart and blowing up

00:40:11.880 --> 00:40:14.240
this circle, this cycle.

00:40:14.240 --> 00:40:16.430
So I end up with a
bigger cycle here,

00:40:16.430 --> 00:40:18.240
end up with an edge
connection there.

00:40:18.240 --> 00:40:22.020
But effectively, it's the
same kind of topology.

00:40:22.020 --> 00:40:26.932
If you're coming in
and alternating--

00:40:26.932 --> 00:40:28.640
I guess you have to
get the parity right.

00:40:28.640 --> 00:40:31.190
If you're coming in from this
side and you're alternating,

00:40:31.190 --> 00:40:33.930
then you can come around
and visit like that,

00:40:33.930 --> 00:40:36.090
and everything is OK.

00:40:36.090 --> 00:40:38.450
Back and forth.

00:40:38.450 --> 00:40:39.260
Cool.

00:40:39.260 --> 00:40:41.150
That was drawn right over here.

00:40:41.150 --> 00:40:42.080
That's a zigzag path.

00:40:42.080 --> 00:40:44.570
The return path
is just as before.

00:40:44.570 --> 00:40:47.550
And so we can use this
edge gadget exactly

00:40:47.550 --> 00:40:51.810
as we did before, but now it's
max degree three everywhere.

00:40:51.810 --> 00:40:52.520
So that's easy.

00:40:52.520 --> 00:40:55.420
In general, using
this trick that here

00:40:55.420 --> 00:40:57.980
we had a corner
with a vertex on it.

00:40:57.980 --> 00:40:59.574
You can turn that
into a longer path

00:40:59.574 --> 00:41:00.740
with various vertices on it.

00:41:00.740 --> 00:41:03.750
That will act the same from
a Hamiltonicity perspective.

00:41:03.750 --> 00:41:05.250
So that's the key
thing we're doing.

00:41:05.250 --> 00:41:08.475
And then it's a matter
of putting things

00:41:08.475 --> 00:41:11.310
to fit on the grid.

00:41:11.310 --> 00:41:13.689
So that's the first change.

00:41:13.689 --> 00:41:15.980
Now, the second change is
going to be a little bit more

00:41:15.980 --> 00:41:18.630
drastic, a little weirder.

00:41:18.630 --> 00:41:21.420
The vertex gadget used
to be this 3 by 3 thing.

00:41:21.420 --> 00:41:23.270
Very hard to get
rid of that, vertex

00:41:23.270 --> 00:41:25.590
would have to be
four in the center.

00:41:25.590 --> 00:41:27.670
Well, if you did
that, you would be

00:41:27.670 --> 00:41:30.720
left with a little
square, an empty square.

00:41:30.720 --> 00:41:33.980
And we're going to
need two of those.

00:41:33.980 --> 00:41:37.760
So this is the
dumbbell picture used

00:41:37.760 --> 00:41:40.350
in many theoretical results.

00:41:40.350 --> 00:41:43.670
So we have two of these squares.

00:41:43.670 --> 00:41:46.240
We're going to separate
them by a fairly long path

00:41:46.240 --> 00:41:48.330
of the right parity.

00:41:48.330 --> 00:41:51.850
And the idea is you can have
up to two connections over here

00:41:51.850 --> 00:41:54.190
to edges, and up to two
connections over here

00:41:54.190 --> 00:41:55.960
for edges.

00:41:55.960 --> 00:41:57.940
And typical
connections are going

00:41:57.940 --> 00:42:00.750
to look just like we
had before, but it's not

00:42:00.750 --> 00:42:02.550
going quite all be like this.

00:42:02.550 --> 00:42:05.830
So it used to be we could
have a full edge connection

00:42:05.830 --> 00:42:12.040
or we could have a pin
connection as before.

00:42:12.040 --> 00:42:15.010
When this edge turns it's going
to use the weirder turn gadget.

00:42:15.010 --> 00:42:17.780
So the edges look
basically the same,

00:42:17.780 --> 00:42:21.090
it's just the turns that we
changed in the last slide.

00:42:21.090 --> 00:42:23.790
OK.

00:42:23.790 --> 00:42:28.650
This almost works, but I
have to specify some details.

00:42:28.650 --> 00:42:31.070
So for example, easy case.

00:42:31.070 --> 00:42:33.020
Degree two vertex.

00:42:33.020 --> 00:42:35.520
Suppose the original graph
has a degree two vertex--

00:42:35.520 --> 00:42:37.740
we had that in our reduction.

00:42:37.740 --> 00:42:40.030
Because in fact, every
other vertex pretty much

00:42:40.030 --> 00:42:44.622
was degree two, if you
track all of these things.

00:42:44.622 --> 00:42:46.080
When we went from
the directed case

00:42:46.080 --> 00:42:48.220
to the bipartite case we
added in lots of vertices,

00:42:48.220 --> 00:42:49.630
lots of degree two vertices.

00:42:49.630 --> 00:42:52.170
So if we want to simulate
a degree two vertex,

00:42:52.170 --> 00:42:55.930
we will just have one of
the edges attaching up here,

00:42:55.930 --> 00:42:58.360
and one of the edges
attaching down here.

00:42:58.360 --> 00:43:02.550
And again-- in this picture
it's one on the left side,

00:43:02.550 --> 00:43:03.810
one on the right side.

00:43:03.810 --> 00:43:05.610
And again, we have
this feature that if we

00:43:05.610 --> 00:43:10.850
start at any of the PIs we
can get to one of the PJs

00:43:10.850 --> 00:43:14.920
by visiting all the EI edges.

00:43:14.920 --> 00:43:19.705
So for example, if we start
here we go like this over here.

00:43:19.705 --> 00:43:20.580
And we have a choice.

00:43:20.580 --> 00:43:23.070
We can either go like this,
end at P3 or go like this

00:43:23.070 --> 00:43:23.770
and end at P4.

00:43:23.770 --> 00:43:26.170
We visited all the EIs.

00:43:26.170 --> 00:43:29.500
But we can't start
at P1 and end at P2.

00:43:29.500 --> 00:43:31.050
We want to visit everything.

00:43:31.050 --> 00:43:32.100
Start at P1.

00:43:32.100 --> 00:43:34.710
If you go out there,
you can never come back.

00:43:34.710 --> 00:43:37.510
To come around here,
you've already visited P2.

00:43:37.510 --> 00:43:40.150
So we cannot start and
end on the left side.

00:43:40.150 --> 00:43:42.090
We cannot start and
end on the right side.

00:43:42.090 --> 00:43:43.864
So for a degree two
vertex, that's fine.

00:43:43.864 --> 00:43:45.280
We just put one
of the connections

00:43:45.280 --> 00:43:48.620
on one side, one on the
other, and we'll come in,

00:43:48.620 --> 00:43:50.110
visit everything, come out.

00:43:50.110 --> 00:43:52.220
And because we
visit all the EIs,

00:43:52.220 --> 00:43:57.870
we can do this kind of
traversal every time.

00:43:57.870 --> 00:44:00.374
Now, for a degree
three vertex, this

00:44:00.374 --> 00:44:01.540
is a little bit troublesome.

00:44:04.150 --> 00:44:08.885
Remember our picture.

00:44:19.394 --> 00:44:21.060
What do degree three
vertices look like?

00:44:21.060 --> 00:44:23.310
If you follow through
the chain of reductions,

00:44:23.310 --> 00:44:30.760
we had this case, and we
had this case, and this one

00:44:30.760 --> 00:44:35.490
we converted into that.

00:44:35.490 --> 00:44:45.001
And this one we converted
into that I think.

00:44:45.001 --> 00:44:45.500
Yup.

00:44:45.500 --> 00:44:47.500
Because this was a forced edge.

00:44:47.500 --> 00:44:52.050
This was a forced edge and so we
added a dot to represent that.

00:44:52.050 --> 00:44:54.720
So the good news is every
time we have a degree three

00:44:54.720 --> 00:45:00.520
vertex in the starting graph,
one of the edges is forced.

00:45:00.520 --> 00:45:01.987
One of the three
edges is forced.

00:45:01.987 --> 00:45:04.153
So it's really a choice
between do you take this one

00:45:04.153 --> 00:45:05.152
or do you take this one.

00:45:05.152 --> 00:45:08.160
I mean that's, of course,
what we had over here.

00:45:08.160 --> 00:45:10.900
So what we're going to do is
take these two edges, which

00:45:10.900 --> 00:45:12.750
are exclusively OR'd together.

00:45:12.750 --> 00:45:15.400
I choose exactly one of these.

00:45:15.400 --> 00:45:19.210
We're going to put that on
one side, so that one of them

00:45:19.210 --> 00:45:22.350
will go up here, one of
them will go down here.

00:45:22.350 --> 00:45:25.910
And then the forced edge we'll
put over on the other side.

00:45:25.910 --> 00:45:27.570
Forced edge is always
chosen, so that

00:45:27.570 --> 00:45:31.450
means we'll come in either P1
or P2, or leave on P1 or P2,

00:45:31.450 --> 00:45:33.710
depending on which of
those two cases we're in.

00:45:33.710 --> 00:45:38.870
And then we will leave
or enter from P3 or P4,

00:45:38.870 --> 00:45:43.761
according to which of
the two edges you choose.

00:45:43.761 --> 00:45:44.260
Happy?

00:45:44.260 --> 00:45:44.910
No?

00:45:44.910 --> 00:45:45.810
AUDIENCE: I'm understanding
that we're actually

00:45:45.810 --> 00:45:48.630
reducing from a sub-problem
of [INAUDIBLE] bipartite,

00:45:48.630 --> 00:45:51.300
max degree three graphs in
that every vertex is connected

00:45:51.300 --> 00:45:54.990
to at least one
degree two vertex?

00:45:54.990 --> 00:45:57.220
ERIK DEMAINE: Yeah.

00:45:57.220 --> 00:45:57.720
Right.

00:45:57.720 --> 00:46:03.450
So we could say at this
point-- in fact, it's planar

00:46:03.450 --> 00:46:07.110
bipartite max degree three
graphs where every degree three

00:46:07.110 --> 00:46:11.270
vertex is adjacent to
exactly one, or no,

00:46:11.270 --> 00:46:15.290
at least one degree two vertex.

00:46:15.290 --> 00:46:18.060
And then we can
carry that condition

00:46:18.060 --> 00:46:19.810
through all the
reductions, and that would

00:46:19.810 --> 00:46:21.740
make this an actual reduction.

00:46:21.740 --> 00:46:24.490
Or you can think of this as
a reduction going from here,

00:46:24.490 --> 00:46:26.220
just copying all the details.

00:46:26.220 --> 00:46:26.720
Yeah.

00:46:29.244 --> 00:46:29.910
Other questions?

00:46:33.500 --> 00:46:35.510
OK.

00:46:35.510 --> 00:46:38.589
I'm a little confused because
there's one more gadget.

00:46:38.589 --> 00:46:40.130
But I didn't seem
to use that gadget.

00:46:40.130 --> 00:46:45.690
So I'm not sure whether
this is necessary.

00:46:45.690 --> 00:46:48.182
But here's another
thing you can do,

00:46:48.182 --> 00:46:49.890
which they're using
for the forced edges.

00:46:49.890 --> 00:46:54.390
You can have one wire--
sorry, this is the picture.

00:46:54.390 --> 00:46:56.790
You can have one edge
gadget that attaches

00:46:56.790 --> 00:46:59.420
to both ends of the dumbbell.

00:46:59.420 --> 00:47:02.080
So then you have a
choice whether you end up

00:47:02.080 --> 00:47:06.540
connecting that edge to
the bottom of the dumbbell

00:47:06.540 --> 00:47:09.980
or to the top of the dumbbell.

00:47:09.980 --> 00:47:11.170
Sorry.

00:47:11.170 --> 00:47:14.040
This is connecting to the
top, and this is connecting

00:47:14.040 --> 00:47:16.060
to the bottom, the dumbbell.

00:47:16.060 --> 00:47:18.980
So that's another way to do
the same kind of degree three

00:47:18.980 --> 00:47:19.480
vertex.

00:47:19.480 --> 00:47:23.550
You could have this guy coming
in-- this is the forced edge,

00:47:23.550 --> 00:47:26.450
and the forced edge has
to come to this vertex.

00:47:26.450 --> 00:47:29.090
You get a choice of whether you
start up here and then leave

00:47:29.090 --> 00:47:33.420
along this non-forced
edge, or you first

00:47:33.420 --> 00:47:35.510
traverse down this way
and then leave along

00:47:35.510 --> 00:47:37.740
this non-forced edge.

00:47:37.740 --> 00:47:40.910
So that's another way to do
it, but it seems just as good

00:47:40.910 --> 00:47:44.720
as the way I described, which
was to put forced edge only

00:47:44.720 --> 00:47:48.130
a one side, and then the other
two guys on the other side.

00:47:48.130 --> 00:47:49.970
Unless there's a parity issue.

00:47:49.970 --> 00:47:54.880
It could be that this
connection and this connection

00:47:54.880 --> 00:47:59.580
have the opposite parities,
which is not good.

00:47:59.580 --> 00:48:06.030
Because we want the two
connections-- in this case,

00:48:06.030 --> 00:48:08.980
both of these are
going to be white.

00:48:08.980 --> 00:48:11.270
And in this case both of
these are going to be black.

00:48:11.270 --> 00:48:13.780
So the two non-forced
edges connect

00:48:13.780 --> 00:48:16.260
to vertices of the same color.

00:48:16.260 --> 00:48:19.100
And I think if you try to
attach one of them over here

00:48:19.100 --> 00:48:21.850
and one of them over
here on a variable,

00:48:21.850 --> 00:48:24.570
they will have the wrong colors,
they'll have opposite colors.

00:48:24.570 --> 00:48:26.430
I think that's why
you need this gadget.

00:48:26.430 --> 00:48:30.580
Because now this left connection
and this other left connection

00:48:30.580 --> 00:48:34.570
will have the same parity
because this count is odd

00:48:34.570 --> 00:48:36.290
I think.

00:48:36.290 --> 00:48:38.620
I think that's why you need it.

00:48:38.620 --> 00:48:39.790
And that preserves parity.

00:48:39.790 --> 00:48:40.710
So it's a bit subtle.

00:48:40.710 --> 00:48:44.640
You have to be careful all the
connections preserve parity.

00:48:44.640 --> 00:48:46.370
Cool.

00:48:46.370 --> 00:48:51.852
So that was max degree
three grid graphs.

00:48:51.852 --> 00:48:52.685
Any other questions?

00:48:56.130 --> 00:49:00.740
Here is one motivation from this
Papadimitriou/Vazirani paper

00:49:00.740 --> 00:49:15.080
for this problem related to
Euclidean traveling salesman

00:49:15.080 --> 00:49:15.580
problem.

00:49:29.920 --> 00:49:32.630
It's this notion of
degree-bounded minimum spanning

00:49:32.630 --> 00:49:33.340
tree.

00:49:33.340 --> 00:49:36.180
Minimum spanning tree normally
is a polynomial problem.

00:49:36.180 --> 00:49:39.890
We're given some graph, you
want to find a spanning tree.

00:49:39.890 --> 00:49:42.030
Tree that this is
all the vertices,

00:49:42.030 --> 00:49:45.850
but it can be a tree
instead of just a path.

00:49:45.850 --> 00:49:49.060
And it's minimum in that it
has minimum total length of all

00:49:49.060 --> 00:49:49.560
the edges.

00:49:49.560 --> 00:49:51.700
So that's a polynomial problem.

00:49:51.700 --> 00:49:54.270
If I say, well, I want
a minimum spanning tree

00:49:54.270 --> 00:49:58.060
where all of the
vertices in the tree

00:49:58.060 --> 00:50:01.996
have max degree two,
that is Hamiltonian path,

00:50:01.996 --> 00:50:03.870
or I guess really
traveling salesman problem.

00:50:03.870 --> 00:50:10.430
So we already proved Euclidean
max degree two minimum spanning

00:50:10.430 --> 00:50:11.300
tree is hard.

00:50:11.300 --> 00:50:12.490
What about max degree three?

00:50:12.490 --> 00:50:15.060
Does that somehow-- does the
branching make it easier,

00:50:15.060 --> 00:50:17.170
and the answer is no.

00:50:17.170 --> 00:50:20.230
You start from this problem.

00:50:20.230 --> 00:50:22.420
And the cool thing
about a max degree

00:50:22.420 --> 00:50:28.030
three grid graph is if you look
at any point, at most three

00:50:28.030 --> 00:50:32.870
of its neighboring spots
are actual vertices.

00:50:32.870 --> 00:50:36.000
One of them has to be absent
in a max degree three.

00:50:36.000 --> 00:50:42.880
So what I'm going to do is add a
point really close to that one.

00:50:42.880 --> 00:50:47.290
And now you can show in
any minimum spanning tree,

00:50:47.290 --> 00:50:51.962
these guys must be connected,
and this one basically

00:50:51.962 --> 00:50:54.170
has to be a leaf because
everything else is quite far

00:50:54.170 --> 00:50:55.130
away.

00:50:55.130 --> 00:51:00.330
I mean at most you have
these guys occupied.

00:51:00.330 --> 00:51:02.850
You know that this
is completely absent.

00:51:02.850 --> 00:51:04.300
So I add this point.

00:51:04.300 --> 00:51:05.910
I'm going to have
to connect this.

00:51:05.910 --> 00:51:09.200
it won't be able to connect
any other way if I'm using

00:51:09.200 --> 00:51:10.520
the shortest possible length.

00:51:10.520 --> 00:51:13.510
And so at that point, if
this has degree three,

00:51:13.510 --> 00:51:16.300
there's only two
incident edges left,

00:51:16.300 --> 00:51:20.390
and so it's Hamiltonian path
again in the grid graph.

00:51:20.390 --> 00:51:23.550
So this is why
they were motivated

00:51:23.550 --> 00:51:26.950
to define max degree grid
graphs and prove that hard.

00:51:30.380 --> 00:51:31.250
Cool.

00:51:31.250 --> 00:51:33.800
Some more geometry.

00:51:33.800 --> 00:51:35.300
All right.

00:51:35.300 --> 00:51:36.910
So for a long time--
you know, this

00:51:36.910 --> 00:51:39.650
is all done in the '80s,
all the grid graph stuff.

00:51:39.650 --> 00:51:42.340
We only had square grids.

00:51:42.340 --> 00:51:46.630
We couldn't afford
triangles back in the day.

00:51:46.630 --> 00:51:50.220
But recently, people started
to think about triangular grids

00:51:50.220 --> 00:51:51.040
and hex grids.

00:51:51.040 --> 00:51:53.620
Those are the only
tiling regular n-gons.

00:51:53.620 --> 00:51:56.460
So you can define the
same kind of thing.

00:51:56.460 --> 00:51:58.790
A triangular grid graph,
a hexagonal grid graph.

00:51:58.790 --> 00:52:02.170
Again, you take a set of
points in the triangular

00:52:02.170 --> 00:52:03.935
lattice or the hex lattice.

00:52:03.935 --> 00:52:05.930
Is the hex actually a lattice?

00:52:05.930 --> 00:52:08.750
Well, anyway, you know
what I mean, the hex grid.

00:52:08.750 --> 00:52:13.630
And you connect
any two points when

00:52:13.630 --> 00:52:16.430
they're a unit distance
apart, where that's

00:52:16.430 --> 00:52:18.990
defined to be one and one.

00:52:18.990 --> 00:52:22.160
So again, we have the notion of
solid, triangular, or hex grid

00:52:22.160 --> 00:52:23.520
graph, and there are no holes.

00:52:23.520 --> 00:52:26.620
Again, we can characterize the
pixels-- they're not really

00:52:26.620 --> 00:52:29.430
pixels-- hexels and trigles?

00:52:29.430 --> 00:52:30.590
I don't know.

00:52:30.590 --> 00:52:32.580
In the paper they're
all just called pixels.

00:52:32.580 --> 00:52:34.180
There's those types of faces.

00:52:34.180 --> 00:52:35.510
There's the outside face.

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.

00:52:41.400 --> 00:52:43.690
OK.

00:52:43.690 --> 00:52:45.190
Cool.

00:52:45.190 --> 00:52:47.840
They define some other
terms, which I will get to.

00:52:55.330 --> 00:52:58.425
Let me tell you what's known
about all of these problems.

00:53:10.060 --> 00:53:33.800
So first thing, so these are--
So first thing that's known

00:53:33.800 --> 00:53:38.090
is that if you have
a solid grid graph,

00:53:38.090 --> 00:53:41.330
then the triangular
case is also polynomial.

00:53:41.330 --> 00:53:45.110
So I mentioned solid
square grid graphs are

00:53:45.110 --> 00:53:46.850
easy to solve Hamiltonicity in.

00:53:46.850 --> 00:53:48.650
Turns out solid
triangular grid graphs

00:53:48.650 --> 00:53:52.410
are also easy to solve grid
graphs-- solve Hamiltonicity

00:53:52.410 --> 00:53:52.910
in.

00:53:52.910 --> 00:53:55.511
Almost all of them are
Hamiltonian in a certain sense,

00:53:55.511 --> 00:53:57.260
as long as you check
for some basic things

00:53:57.260 --> 00:53:59.950
you shouldn't have.

00:53:59.950 --> 00:54:02.410
But hex is open.

00:54:02.410 --> 00:54:05.000
So there's actually a ton
of nice open problems still.

00:54:07.790 --> 00:54:13.090
Next case is called
a super thin.

00:54:28.040 --> 00:54:30.800
So what is super thin?

00:54:30.800 --> 00:54:36.500
Super thin means
there are no pixels.

00:54:36.500 --> 00:54:40.130
Every face is either a
hole or the outside face.

00:54:40.130 --> 00:54:43.880
I don't have an example here,
but this kind of connection

00:54:43.880 --> 00:54:46.150
is what you would have
in super thin graphs.

00:54:46.150 --> 00:54:50.620
So you've got the whole face
here, a whole face there.

00:54:50.620 --> 00:54:53.360
You shouldn't have any of
these pixels to be super thin.

00:54:53.360 --> 00:54:56.380
That case turns out to
be polynomial for squares

00:54:56.380 --> 00:54:59.250
and hexes, open for triangles.

00:54:59.250 --> 00:55:02.660
All right, next
case is called thin.

00:55:12.091 --> 00:55:14.670
That one right there implies.

00:55:14.670 --> 00:55:19.330
In the thin case, both the
triangle and the square,

00:55:19.330 --> 00:55:21.810
problems are NP-hard,
hexes are open.

00:55:21.810 --> 00:55:23.210
What does thin mean?

00:55:23.210 --> 00:55:27.750
Thin means every vertex
is on the boundary.

00:55:27.750 --> 00:55:31.950
So super thin is something like
every edge is on the boundary.

00:55:31.950 --> 00:55:34.200
Thin is that every vertex
is on the boundary.

00:55:34.200 --> 00:55:36.910
So for example, this
part here is thin.

00:55:36.910 --> 00:55:39.320
The banner's actually
drawn in bold here.

00:55:39.320 --> 00:55:42.070
If every vertex has bold
edges incident to it,

00:55:42.070 --> 00:55:43.320
then we call that thin.

00:55:43.320 --> 00:55:47.510
So it's a little bit
thicker than super thin.

00:55:47.510 --> 00:55:52.270
So it's also easier to think
of the dual if you care to.

00:55:52.270 --> 00:55:56.330
If you draw a vertex for every
pixel, in the super thin case

00:55:56.330 --> 00:55:58.282
there are no
vertices in the dual.

00:55:58.282 --> 00:56:03.470
In the thin case, the
dual is super thin.

00:56:03.470 --> 00:56:06.200
I don't know if that's
easier to think about.

00:56:06.200 --> 00:56:08.370
But these cases
are actually hard,

00:56:08.370 --> 00:56:10.710
at least in two out
of the three pictures.

00:56:10.710 --> 00:56:12.185
One of them we have
already proved.

00:56:16.150 --> 00:56:20.200
If you have a max
degree three grid graph,

00:56:20.200 --> 00:56:23.460
if max degree is
three then it must

00:56:23.460 --> 00:56:26.200
be on the boundary because
of that absent pixel.

00:56:26.200 --> 00:56:29.040
So we already showed the thin
case for squares is hard.

00:56:29.040 --> 00:56:34.450
Max degree thin implies
thin, four squares.

00:56:34.450 --> 00:56:41.710
And so you might ask
what about triangles?

00:56:41.710 --> 00:56:47.024
OK, so finally we get
to an actual proof.

00:56:47.024 --> 00:56:48.690
It's going to be the
same kind of thing.

00:56:48.690 --> 00:56:52.360
I'll skip this detail, but this
is the planar and betting part.

00:56:52.360 --> 00:56:57.710
So again, we're going to reduce
from bipartite max degree three

00:56:57.710 --> 00:57:02.190
planar Hamiltonicity
as we did before.

00:57:02.190 --> 00:57:04.770
And then we're going
to draw it in the plane

00:57:04.770 --> 00:57:06.770
in some kind of
parity-preserving sense

00:57:06.770 --> 00:57:11.860
with edges routed on
the triangular grid.

00:57:11.860 --> 00:57:14.900
That's not hard.

00:57:14.900 --> 00:57:18.420
Then we have very
similar looking gadgets.

00:57:18.420 --> 00:57:21.400
Although in this case,
a vertex can just

00:57:21.400 --> 00:57:24.460
be a little triangle of dots.

00:57:24.460 --> 00:57:26.490
The edge gadget's going
to look pretty similar.

00:57:26.490 --> 00:57:31.244
It's like a ladder, but now the
ladder has funny rungs on it.

00:57:31.244 --> 00:57:32.785
Turns are just what
you would expect.

00:57:35.500 --> 00:57:40.322
Notice we get degree five here.

00:57:40.322 --> 00:57:41.780
But otherwise,
things are the same.

00:57:41.780 --> 00:57:45.154
You can traverse either in
the loopback configuration.

00:57:45.154 --> 00:57:46.570
When you have this
pin joint there

00:57:46.570 --> 00:57:48.690
you'll be forced to
turn around there.

00:57:48.690 --> 00:57:51.490
Or you zigzag all
the way through,

00:57:51.490 --> 00:57:54.224
and then that's used
for present edges.

00:57:54.224 --> 00:57:56.390
So this is edges you don't
use in Hamiltonian cycle.

00:57:56.390 --> 00:57:57.940
These are edges you do use.

00:57:57.940 --> 00:57:59.620
And there are two
types of vertices.

00:57:59.620 --> 00:58:05.690
There's the ones of one parity
where you always meet-- here,

00:58:05.690 --> 00:58:07.860
you're kind of meeting
with three edges,

00:58:07.860 --> 00:58:11.270
but you're kind of meeting
on a whole edge, like that.

00:58:11.270 --> 00:58:13.100
And from here you
have the choice

00:58:13.100 --> 00:58:15.880
whether you do this or do this.

00:58:15.880 --> 00:58:20.826
Two of them will be zigzags,
one of them will be double-back.

00:58:20.826 --> 00:58:22.450
And then there's the
other parity class

00:58:22.450 --> 00:58:23.800
where you only have pin joints.

00:58:23.800 --> 00:58:25.841
These are, again, just
connected by single edges,

00:58:25.841 --> 00:58:28.240
so they act just
like we had before.

00:58:28.240 --> 00:58:32.750
So pretty much the same
reduction, but with different--

00:58:32.750 --> 00:58:35.451
in some ways, this is an
easier reduction I think.

00:58:38.600 --> 00:58:39.100
Cool.

00:58:39.100 --> 00:58:41.600
Now, that was max degree five.

00:58:41.600 --> 00:58:43.790
What about max degree four?

00:58:43.790 --> 00:58:48.060
So here we had degree
five vertex there.

00:58:48.060 --> 00:58:52.080
If we kind of do our same
trick of spreading them around,

00:58:52.080 --> 00:58:55.560
you end up with
degree four at most.

00:58:55.560 --> 00:58:57.550
And it acts the same.

00:58:57.550 --> 00:59:04.870
And the vertices we're going
to explode into a hexagon.

00:59:04.870 --> 00:59:08.030
And it works.

00:59:08.030 --> 00:59:22.480
So I should say max degree
four triangle is NP-hard.

00:59:25.700 --> 00:59:28.790
This reduction
should also be thin.

00:59:28.790 --> 00:59:30.750
Previous one may
have also been thin,

00:59:30.750 --> 00:59:34.410
but again, all of the
vertices are on the boundary.

00:59:34.410 --> 00:59:37.590
So this is the thin
triangle is hard.

00:59:37.590 --> 00:59:39.644
Max degree four
triangle is hard.

00:59:39.644 --> 00:59:40.310
We did this one.

00:59:40.310 --> 00:59:44.070
So we've done all
the hardest proofs.

00:59:44.070 --> 00:59:47.720
That will cease to be
the case in a moment.

00:59:47.720 --> 00:59:51.470
OK, here's one more thing.

00:59:51.470 --> 00:59:55.480
Max-- so what about hex grids.

00:59:55.480 --> 00:59:58.580
I haven't mentioned any
hardness for hex grids yet.

00:59:58.580 --> 01:00:01.680
And one thing we know
is max degree three,

01:00:01.680 --> 01:00:09.610
writing new squares, but
also hexagons are NP-hard.

01:00:09.610 --> 01:00:11.550
Now, this is not so impressive.

01:00:11.550 --> 01:00:15.090
Every vertex in the hex grid
has a degree at most three.

01:00:15.090 --> 01:00:18.307
But you can't hope
for two, so that's

01:00:18.307 --> 01:00:20.640
the best you can hope for in
max degree characterization

01:00:20.640 --> 01:00:21.710
with respect to hex grid.

01:00:24.220 --> 01:00:26.195
This proof is tricky.

01:00:30.910 --> 01:00:35.390
Maybe before I go there let me
just mention one other result.

01:00:35.390 --> 01:00:37.630
So this is delayed.

01:00:37.630 --> 01:00:42.810
One other notion you can
think about for grid graphs

01:00:42.810 --> 01:00:46.170
is called polygonal
grid graphs, and that's

01:00:46.170 --> 01:00:48.050
what's supposed to
be illustrated here.

01:00:48.050 --> 01:00:50.840
Polygonal's kind of the
opposite of super thin.

01:00:50.840 --> 01:00:53.570
So super thin we
had an edge that

01:00:53.570 --> 01:00:58.340
had non-pixels on both sides.

01:00:58.340 --> 01:01:01.770
In polygonal, every edge
has a pixel on at least one

01:01:01.770 --> 01:01:03.690
of the two sides.

01:01:03.690 --> 01:01:06.690
So you never have an
edge between two holes

01:01:06.690 --> 01:01:08.900
or a hole in the outside face.

01:01:08.900 --> 01:01:10.405
That's a polygonal situation.

01:01:13.350 --> 01:01:15.080
So that's something
you might assume.

01:01:15.080 --> 01:01:17.030
It's sort of like
saying you had a polygon

01:01:17.030 --> 01:01:19.280
and then you sort of took
the interior of the polygon,

01:01:19.280 --> 01:01:20.710
whereas here, this
was not really

01:01:20.710 --> 01:01:23.519
a polygon because it's like
there was a doubled edge there

01:01:23.519 --> 01:01:24.060
or something.

01:01:24.060 --> 01:01:26.884
That's not really
a nice picture.

01:01:26.884 --> 01:01:28.300
So polygonal's
something you might

01:01:28.300 --> 01:01:31.120
hope for in the
practical applications,

01:01:31.120 --> 01:01:33.510
which we will get to soon.

01:01:33.510 --> 01:01:38.420
Funny thing is for polygonal
triangular grid graphs,

01:01:38.420 --> 01:01:40.120
the problem is polynomial.

01:01:40.120 --> 01:01:48.410
And for polygonal hex grid
graphs, the problem is NP-hard.

01:01:48.410 --> 01:01:53.460
And for polygonal square
grid graphs, we don't know.

01:01:53.460 --> 01:01:54.490
Another open problem.

01:01:57.390 --> 01:01:59.220
I won't prove this.

01:01:59.220 --> 01:02:02.270
I think, again, this is
almost always feasible.

01:02:02.270 --> 01:02:05.220
It's almost always
a Hamiltonian path.

01:02:05.220 --> 01:02:09.540
For this, I'm guessing it
follows from the same proof.

01:02:09.540 --> 01:02:17.590
Let's go into this
proof, hex grid hardness.

01:02:17.590 --> 01:02:19.140
Again, there's a drawing step.

01:02:19.140 --> 01:02:21.780
You're given some
bipartite max degree

01:02:21.780 --> 01:02:28.280
three graph, and bipartite
planar max three degree graph.

01:02:28.280 --> 01:02:31.540
And then we're going to
draw on the hex grid.

01:02:31.540 --> 01:02:33.540
In this case, we're going
to represent variables

01:02:33.540 --> 01:02:38.330
by sort of horizontal strips,
just because that's what

01:02:38.330 --> 01:02:40.110
is a little bit easier to do.

01:02:40.110 --> 01:02:43.700
So it turns out-- I think turns
are really annoying on the hex

01:02:43.700 --> 01:02:44.260
grid.

01:02:44.260 --> 01:02:45.480
Hard to do a turn.

01:02:45.480 --> 01:02:49.090
So we're going to focus
our turn attention

01:02:49.090 --> 01:02:50.430
within these little rectangles.

01:02:50.430 --> 01:02:52.680
And it turns out you can
draw everything in such a way

01:02:52.680 --> 01:02:56.260
that all of the edges are
straight lines, straight line

01:02:56.260 --> 01:02:59.510
segments, if you grow the
vertices to be these longer

01:02:59.510 --> 01:03:01.220
horizontal things.

01:03:01.220 --> 01:03:05.280
So believe that.

01:03:05.280 --> 01:03:11.021
Then main idea is a very
similar kind of thing.

01:03:11.021 --> 01:03:13.020
In this case, they're
going to draw the pictures

01:03:13.020 --> 01:03:15.269
and they're going to draw
all of the forced edges that

01:03:15.269 --> 01:03:17.540
must be in there,
and here they haven't

01:03:17.540 --> 01:03:18.850
drawn the part in the middle.

01:03:18.850 --> 01:03:19.970
There's two ways to fill it in.

01:03:19.970 --> 01:03:21.850
Essentially, you could
zigzag back and forth,

01:03:21.850 --> 01:03:22.950
just like before.

01:03:22.950 --> 01:03:25.760
Or you could go there and
come back, just like before.

01:03:25.760 --> 01:03:28.225
So edge gadget looks
pretty reasonable.

01:03:31.530 --> 01:03:33.670
These are some more gadgets.

01:03:33.670 --> 01:03:37.210
These are like sub-routines
they're going to use.

01:03:37.210 --> 01:03:40.100
Their named and they have color
patterns to give you a sense.

01:03:40.100 --> 01:03:43.150
This is going to be
the center of a vertex,

01:03:43.150 --> 01:03:45.850
and there's a few different
things you could do with that.

01:03:45.850 --> 01:03:48.171
This is some kind
of turn gadget.

01:03:48.171 --> 01:03:49.170
That's what I called it.

01:03:49.170 --> 01:03:51.030
They called it something
a little different.

01:03:51.030 --> 01:03:52.620
I think a rosette.

01:03:52.620 --> 01:03:57.250
But you can sort of
zigzag, or you can kind of

01:03:57.250 --> 01:03:59.340
go there and double-back,
but you end up

01:03:59.340 --> 01:04:01.180
with different
orientations at the end.

01:04:01.180 --> 01:04:04.080
This is what they call a U turn.

01:04:04.080 --> 01:04:05.330
Again, these edges are forced.

01:04:05.330 --> 01:04:07.590
You can either use
it as a zigzag,

01:04:07.590 --> 01:04:10.220
or they could both kind
of cancel each other out.

01:04:10.220 --> 01:04:12.450
Sort of don't meet each other.

01:04:12.450 --> 01:04:15.670
So you could do different
kind of connectivity.

01:04:15.670 --> 01:04:21.390
With that in mind, here
is all the vertex gadgets.

01:04:21.390 --> 01:04:26.421
So I don't know all
the details here.

01:04:26.421 --> 01:04:28.940
But I think there's
a lot of cases

01:04:28.940 --> 01:04:31.780
because of the different ways
things could be connected.

01:04:31.780 --> 01:04:35.080
You could have like one
on top of the-- notice

01:04:35.080 --> 01:04:37.740
the dash things are the
rectangles that I had before.

01:04:37.740 --> 01:04:39.790
Normally they'd be
really spread out.

01:04:39.790 --> 01:04:42.020
So maybe you have two in
the bottom, one on the top,

01:04:42.020 --> 01:04:44.190
here I have two on the
top, one on the bottom.

01:04:44.190 --> 01:04:47.970
And they could be oriented like
this, or oriented like that.

01:04:47.970 --> 01:04:50.680
So there's a lot of
different cases as a result.

01:04:50.680 --> 01:04:53.310
The core part in the
middle is the same.

01:04:53.310 --> 01:04:54.960
It's pretty much
like the examples

01:04:54.960 --> 01:04:59.370
we had before of
essentially like a little 3

01:04:59.370 --> 01:05:02.010
by 3 square for the square
case, or a little triangle

01:05:02.010 --> 01:05:03.057
in the triangle case.

01:05:03.057 --> 01:05:04.265
A little bit bigger in a hex.

01:05:04.265 --> 01:05:08.360
It's basically a cycle is
an extra dot in the middle.

01:05:08.360 --> 01:05:11.380
But then this was
a U turn gadgets,

01:05:11.380 --> 01:05:14.080
so if something
was coming up here,

01:05:14.080 --> 01:05:16.080
you could just sort
of turn back around

01:05:16.080 --> 01:05:19.320
if you don't want
to use the edge.

01:05:19.320 --> 01:05:21.210
I think these are
prob-- well, yeah,

01:05:21.210 --> 01:05:24.170
so there's probably
also two parity classes.

01:05:24.170 --> 01:05:26.330
There's the turn gadgets.

01:05:26.330 --> 01:05:30.680
And it works, but
it's complicated.

01:05:35.140 --> 01:05:38.245
I think that's all I'll say
about various grid graphs.

01:05:38.245 --> 01:05:38.870
AUDIENCE: Yeah.

01:05:38.870 --> 01:05:41.349
You said that in
hexagonal grids were open?

01:05:41.349 --> 01:05:42.349
Did you mean the vertex?

01:05:42.349 --> 01:05:43.343
Every vertex on the boundary--

01:05:43.343 --> 01:05:45.509
ERIK DEMAINE: It means every
vertex on the boundary.

01:05:45.509 --> 01:05:47.320
AUDIENCE: --[INAUDIBLE].

01:05:47.320 --> 01:05:48.140
ERIK DEMAINE: No.

01:05:48.140 --> 01:05:49.520
It's not necessarily the same.

01:05:49.520 --> 01:05:52.510
So if you have hex grid--
I mean this could still

01:05:52.510 --> 01:05:54.230
be a boundary
cycle and you still

01:05:54.230 --> 01:05:56.520
have a degree three vertex.

01:05:56.520 --> 01:05:59.150
Something like
this part is thin.

01:05:59.150 --> 01:06:01.820
And I'm guessing you
could complete that.

01:06:01.820 --> 01:06:03.420
So they're probably
very special,

01:06:03.420 --> 01:06:06.080
so I could imagine the thin
hex grids are polynomial,

01:06:06.080 --> 01:06:07.450
but it's not known.

01:06:07.450 --> 01:06:08.990
OK.

01:06:08.990 --> 01:06:10.340
One more picture.

01:06:10.340 --> 01:06:13.270
This is an actual explicitly
constructed example

01:06:13.270 --> 01:06:17.762
from that graph to
this crazy gadgets.

01:06:17.762 --> 01:06:19.220
But now you can
see a little better

01:06:19.220 --> 01:06:20.469
what the rectangles look like.

01:06:20.469 --> 01:06:22.290
If you want to
stretch something out,

01:06:22.290 --> 01:06:24.870
there's always horizontal
wires that you can stretch out.

01:06:24.870 --> 01:06:26.135
And I keep calling them wires.

01:06:26.135 --> 01:06:28.330
So those horizontal
pieces of edge gadgets

01:06:28.330 --> 01:06:32.050
that you can stretch out
so that you end up firing

01:06:32.050 --> 01:06:35.770
and hitting the next vertex,
which is this rectangle.

01:06:35.770 --> 01:06:37.360
And when you spread
out the rectangles

01:06:37.360 --> 01:06:41.620
you have to stretch out
these diagonal shots.

01:06:41.620 --> 01:06:42.420
Cool.

01:06:42.420 --> 01:06:43.726
Those hex grid graphs.

01:06:43.726 --> 01:06:45.600
Why do we care about
hex grid graphs so much?

01:06:45.600 --> 01:06:50.680
Because Settlers of Catan,
and various other board games

01:06:50.680 --> 01:06:53.620
that have a hex grid.

01:06:53.620 --> 01:06:56.980
Now, has anyone here not
played Settlers of Catan?

01:06:56.980 --> 01:06:59.510
OK, a few.

01:06:59.510 --> 01:07:01.760
There's a whole game to it.

01:07:01.760 --> 01:07:02.608
But--

01:07:02.608 --> 01:07:04.480
[LAUGHTER]

01:07:04.480 --> 01:07:08.520
What I'm going to
focus on is this card.

01:07:08.520 --> 01:07:11.110
It's called longest road.

01:07:11.110 --> 01:07:13.990
So in general, you're
constructing cities.

01:07:13.990 --> 01:07:15.510
Don't worry about cities.

01:07:15.510 --> 01:07:17.500
But you're constructing
these road segments.

01:07:17.500 --> 01:07:19.590
They're edges on the hex grid.

01:07:19.590 --> 01:07:23.370
And the longest road says that
you get two points, two victory

01:07:23.370 --> 01:07:26.910
points, if you have the longest
road, meaning the longest

01:07:26.910 --> 01:07:29.270
path that can be
formed using edges

01:07:29.270 --> 01:07:31.980
of your color versus edges
of anyone else's color,

01:07:31.980 --> 01:07:33.790
then you get two points.

01:07:33.790 --> 01:07:36.142
So here is the idea.

01:07:36.142 --> 01:07:38.350
Settlers of Catan has
randomness and stuff like that,

01:07:38.350 --> 01:07:40.870
but again, if we look
at a mate-in-1 problem,

01:07:40.870 --> 01:07:42.247
that goes out the window.

01:07:42.247 --> 01:07:43.580
Just can I win in this one move.

01:07:43.580 --> 01:07:45.680
There's no randomness to that.

01:07:45.680 --> 01:07:47.810
Let's suppose you have
tons of resources.

01:07:47.810 --> 01:07:49.850
This is what you
need to build a road.

01:07:49.850 --> 01:07:52.440
And inconveniently,
your opponents

01:07:52.440 --> 01:07:56.099
have built cities and things
in all of these white spots,

01:07:56.099 --> 01:07:57.890
so you're not allowed
to build roads there.

01:07:57.890 --> 01:07:59.870
That's just part of the rules.

01:07:59.870 --> 01:08:02.140
So that's the opponent's
form obstacles.

01:08:02.140 --> 01:08:04.940
And then because you
have infinite cash,

01:08:04.940 --> 01:08:08.130
you can basically build
the entire grid graph here.

01:08:08.130 --> 01:08:11.300
And then to figure out whether
there's a really long road,

01:08:11.300 --> 01:08:15.130
namely a road length n, where
n is the number of pixels that

01:08:15.130 --> 01:08:17.779
were not occupied by opponents.

01:08:17.779 --> 01:08:21.050
Number of dots that are
not occupied by opponents

01:08:21.050 --> 01:08:23.470
is NP-complete.

01:08:23.470 --> 01:08:23.970
Cool?

01:08:23.970 --> 01:08:26.740
And your opponent has a
slightly shorter road,

01:08:26.740 --> 01:08:31.125
so you really have to
distinguish whether you

01:08:31.125 --> 01:08:32.000
had the longest road.

01:08:32.000 --> 01:08:35.270
In fact, I like to say
mate-in-0 is NP-complete,

01:08:35.270 --> 01:08:39.550
deciding whether you've already
won the game is NP-complete.

01:08:39.550 --> 01:08:40.790
Now you don't even need cash.

01:08:40.790 --> 01:08:43.189
It's just I give
you a configuration.

01:08:43.189 --> 01:08:45.979
Do you have the longest
road is NP-hard.

01:08:45.979 --> 01:08:49.720
So it's the only mate-in-0
hardness result I know of.

01:08:49.720 --> 01:08:52.060
Maybe we can find more.

01:08:52.060 --> 01:08:55.990
OK, so that's why
hex grids are cool.

01:08:55.990 --> 01:08:58.100
Let's do some more games.

01:08:58.100 --> 01:09:00.899
Here is another Nikoli
puzzle, Slither Link.

01:09:00.899 --> 01:09:03.410
Their more famous one.

01:09:03.410 --> 01:09:05.260
So you're given a
grid of squares.

01:09:05.260 --> 01:09:08.100
Each square is either blank,
meaning no constraint,

01:09:08.100 --> 01:09:10.510
or there's a number saying
there should be exactly two

01:09:10.510 --> 01:09:12.146
edges among those four.

01:09:12.146 --> 01:09:14.520
And there should be exactly
three edges among those four.

01:09:14.520 --> 01:09:17.550
Your goal is to find a
cycle-- not Hamiltonian

01:09:17.550 --> 01:09:21.390
but just a cycle, doesn't visit
all the dots-- that satisfies

01:09:21.390 --> 01:09:23.420
that neighboring constraint.

01:09:23.420 --> 01:09:24.899
So here there were exactly two.

01:09:24.899 --> 01:09:30.270
Here there are exactly
three edges in your cycle.

01:09:30.270 --> 01:09:30.899
OK?

01:09:30.899 --> 01:09:32.950
This is the very first
puzzle on the website.

01:09:32.950 --> 01:09:35.660
Again, there are books
on Slither Link puzzles.

01:09:35.660 --> 01:09:40.290
And here is a little
overkill of a hardness proof,

01:09:40.290 --> 01:09:42.010
but in one slide.

01:09:42.010 --> 01:09:48.130
So this is a reduction from
Hamiltonicity in planar graphs.

01:09:48.130 --> 01:09:50.890
So you take any planar graph
and draw it in the grid.

01:09:50.890 --> 01:09:54.380
This is one of the very
first steps we did today.

01:09:54.380 --> 01:09:56.944
And then if you do that, there
are two types of vertices.

01:09:56.944 --> 01:09:58.360
There's the ones
you have to visit

01:09:58.360 --> 01:10:00.234
and there's the ones
you don't have to visit.

01:10:00.234 --> 01:10:02.530
Now, we know grid
graphs are hard.

01:10:02.530 --> 01:10:05.080
So we could actually
assume all of the vertices

01:10:05.080 --> 01:10:06.690
have to be visited.

01:10:06.690 --> 01:10:10.410
But for whatever reason,
this proof did not do that.

01:10:10.410 --> 01:10:12.640
This is back in 2000,
so at that point maybe

01:10:12.640 --> 01:10:14.990
it was not so well known.

01:10:14.990 --> 01:10:16.980
But these days, grid
graphs, Hamiltonicity

01:10:16.980 --> 01:10:20.180
is used a lot, but
probably not so much then.

01:10:20.180 --> 01:10:22.110
So anyway, there's
this gadget which

01:10:22.110 --> 01:10:25.840
is you can do whatever
you want, basically.

01:10:25.840 --> 01:10:28.560
These are the vertices that
don't need to be visited.

01:10:28.560 --> 01:10:30.800
The key gadget is this one.

01:10:30.800 --> 01:10:32.680
So let's focus our
attention here.

01:10:32.680 --> 01:10:36.600
We have these ones which means
the cycle must come here.

01:10:36.600 --> 01:10:40.070
And so collectively these are
going to form Hamiltonian cycle

01:10:40.070 --> 01:10:41.200
constraints.

01:10:41.200 --> 01:10:43.890
You're building a cycle and
you have to visit these ones.

01:10:43.890 --> 01:10:46.640
Now it turns out no matter
which end you come in

01:10:46.640 --> 01:10:49.320
and which end you leave, you
can visit all of the ones.

01:10:49.320 --> 01:10:51.450
You could be adjacent
to all of the ones.

01:10:51.450 --> 01:10:54.740
So different turns
are going straight.

01:10:54.740 --> 01:10:56.660
And so if there is
a Hamiltonian cycle,

01:10:56.660 --> 01:10:59.170
you'll be able to
visit all the ones.

01:10:59.170 --> 01:11:01.850
And conversely, if you
can visit all the ones,

01:11:01.850 --> 01:11:03.460
that must be a
Hamiltonian cycle.

01:11:03.460 --> 01:11:05.294
The one extra thing
we need to say,

01:11:05.294 --> 01:11:06.960
if you just glue these
gadgets together,

01:11:06.960 --> 01:11:11.720
then there's no-- you can go
from anywhere to anywhere.

01:11:11.720 --> 01:11:14.100
So you just add in
some zeroes here

01:11:14.100 --> 01:11:16.940
if you don't want there to be a
connection from left to right.

01:11:16.940 --> 01:11:19.220
So you can use that to
delineate the boundary.

01:11:19.220 --> 01:11:21.450
So this could actually do
a sub-graph of a grid graph

01:11:21.450 --> 01:11:25.255
even more special, or you leave
a clear if there's an edge.

01:11:25.255 --> 01:11:28.470
And so you get a
picture like this.

01:11:28.470 --> 01:11:31.150
In this case, they're
using these bunch of zeroes

01:11:31.150 --> 01:11:33.470
to say, well, you
don't have to visit

01:11:33.470 --> 01:11:36.755
these pixels because they're
just simulating a big edge.

01:11:36.755 --> 01:11:38.130
But we really have
infrastructure

01:11:38.130 --> 01:11:38.880
to simulate edges.

01:11:38.880 --> 01:11:41.120
We don't really need that.

01:11:41.120 --> 01:11:42.850
So that's a really easy proof.

01:11:45.069 --> 01:11:46.610
I would say in
general, what you have

01:11:46.610 --> 01:11:49.350
to be careful about here
is that edges are free,

01:11:49.350 --> 01:11:51.050
because in Hamiltonian
cycle you're not

01:11:51.050 --> 01:11:52.300
supposed to pay for the edges.

01:11:52.300 --> 01:11:54.740
You just have to
visit every vertex.

01:11:54.740 --> 01:11:57.380
But that's really easy
in this kind of set up.

01:11:57.380 --> 01:12:03.850
Another Nikoli puzzle,
Hashiwokakero, bridge building.

01:12:03.850 --> 01:12:06.250
You have a bunch of
dots in the plane.

01:12:06.250 --> 01:12:11.290
Each dot has a number on it,
specifying a degree request.

01:12:11.290 --> 01:12:15.126
And your goal is to make
a connected structure.

01:12:15.126 --> 01:12:17.150
It looks like it's
usually a tree,

01:12:17.150 --> 01:12:19.050
but that's not part
of the constraints.

01:12:19.050 --> 01:12:21.426
Where every vertex
has that degree,

01:12:21.426 --> 01:12:22.550
you can use multiple edges.

01:12:22.550 --> 01:12:25.700
You could build multiple bridges
between the same two cities.

01:12:25.700 --> 01:12:28.849
And so there's four incident to
that, eight incident to that,

01:12:28.849 --> 01:12:30.015
and everything's orthogonal.

01:12:30.015 --> 01:12:31.960
It can only build
horizontal, vertical.

01:12:31.960 --> 01:12:34.190
You can't build a
bridge like this.

01:12:34.190 --> 01:12:35.670
You're not allowed
to make turns.

01:12:35.670 --> 01:12:37.045
AUDIENCE: Same as
standard coding

01:12:37.045 --> 01:12:39.932
where you've only got two
parallel edges per [INAUDIBLE].

01:12:39.932 --> 01:12:40.640
ERIK DEMAINE: Ah.

01:12:40.640 --> 01:12:41.139
OK.

01:12:41.139 --> 01:12:46.800
So also standard is that max
double-edge, no triple-edge.

01:12:46.800 --> 01:12:47.870
Thank you.

01:12:47.870 --> 01:12:51.020
Obviously, i haven't
actually played.

01:12:51.020 --> 01:12:52.590
It won't matter
in this reduction.

01:12:52.590 --> 01:12:56.540
So here we are reducing from
Hamiltonicity in grid graphs.

01:12:56.540 --> 01:12:59.330
So these are edges that
we might want to allow.

01:12:59.330 --> 01:13:02.250
In general, we're going to use
these little ones to delineate

01:13:02.250 --> 01:13:03.690
the boundary.

01:13:03.690 --> 01:13:07.470
It's just the same kind
of trick we use here

01:13:07.470 --> 01:13:10.320
with Euclidean degree three MST.

01:13:10.320 --> 01:13:13.386
We added a little dot
just off to the side.

01:13:13.386 --> 01:13:15.260
It's not a metric problem
here, so we're just

01:13:15.260 --> 01:13:16.752
adding it one unit over.

01:13:16.752 --> 01:13:17.960
That delineates the boundary.

01:13:17.960 --> 01:13:21.399
It basically is forced to
connect into the only neighbor.

01:13:21.399 --> 01:13:23.190
If you tried to do this
kind of connection,

01:13:23.190 --> 01:13:24.523
you'd end up being disconnected.

01:13:24.523 --> 01:13:26.490
You'd just get a
single edge there.

01:13:26.490 --> 01:13:29.060
Because ones will
only face ones.

01:13:29.060 --> 01:13:29.560
Sorry.

01:13:29.560 --> 01:13:31.310
The other constraint
is you're not allowed

01:13:31.310 --> 01:13:33.570
to have crossing bridges.

01:13:33.570 --> 01:13:35.852
That won't matter here.

01:13:35.852 --> 01:13:37.560
So we delineate the
boundary at the ones,

01:13:37.560 --> 01:13:39.060
and then every other
vertex is going

01:13:39.060 --> 01:13:42.370
to have value two plus the
number of boundary edges

01:13:42.370 --> 01:13:43.000
incident to it.

01:13:43.000 --> 01:13:45.660
So here it happens to be four,
here it happens to be three.

01:13:45.660 --> 01:13:46.990
So I could have gone like this.

01:13:46.990 --> 01:13:48.073
That would have been fine.

01:13:48.073 --> 01:13:51.790
But in the cycle, I happened
to go around that way.

01:13:51.790 --> 01:13:53.290
That's representing the cycle.

01:13:53.290 --> 01:13:55.450
So again, very easy.

01:13:55.450 --> 01:13:58.890
This shows you how useful it
is once you have grid graphs.

01:13:58.890 --> 01:14:01.760
You can do any problem on any
grid, pretty much, that has

01:14:01.760 --> 01:14:04.020
any kind of tour-like thing.

01:14:04.020 --> 01:14:06.940
That will be hard
using these reductions.

01:14:06.940 --> 01:14:08.520
So that's why we care.

01:14:11.470 --> 01:14:12.310
All right.

01:14:12.310 --> 01:14:14.410
Here's some
practical motivation.

01:14:14.410 --> 01:14:15.620
Well, I have a game here.

01:14:15.620 --> 01:14:17.740
But suppose you're
mowing your lawn.

01:14:17.740 --> 01:14:21.560
And so usually a lawnmower
has a circular cutting tool,

01:14:21.560 --> 01:14:24.550
but in this game it happens
to be a square cutting tool.

01:14:24.550 --> 01:14:26.030
It's basically the same.

01:14:26.030 --> 01:14:32.271
And you have some polygon with
holes that you want to mow.

01:14:32.271 --> 01:14:34.145
There's actually two
versions of the problem.

01:14:45.344 --> 01:14:50.020
And they were introduced by
Arkin, Fekete and Mitchell,

01:14:50.020 --> 01:14:51.271
2000.

01:14:51.271 --> 01:14:52.790
One's called Lawn Mowing.

01:14:57.690 --> 01:15:00.350
So Lawn Mowing you're
given a polygon.

01:15:00.350 --> 01:15:04.010
You have to visit, let's say,
if we're using a square cutter,

01:15:04.010 --> 01:15:05.900
you have to visit every
pixel of the polygon.

01:15:05.900 --> 01:15:07.441
You have to visit
the entire-- you're

01:15:07.441 --> 01:15:08.780
moving a unit square around.

01:15:08.780 --> 01:15:11.300
You've got to visit everything
to cut the entire lawn.

01:15:11.300 --> 01:15:13.260
But you're also allowed
to leave the polygon,

01:15:13.260 --> 01:15:15.600
because for a lawn mower you
can go outside the grass.

01:15:15.600 --> 01:15:17.010
You can go onto the pavement.

01:15:17.010 --> 01:15:18.940
Most lawnmowers that
doesn't break it.

01:15:18.940 --> 01:15:21.160
So that's called Lawn Mowing.

01:15:21.160 --> 01:15:23.090
You can go outside if you want.

01:15:26.360 --> 01:15:28.275
And the other problem
is called Milling.

01:15:31.800 --> 01:15:33.970
And with Milling,
you can't go outside.

01:15:37.196 --> 01:15:39.570
That video game is probably
some hybrid between these two

01:15:39.570 --> 01:15:41.307
problems, but both
problems have been

01:15:41.307 --> 01:15:43.390
considered a lot, especially
from an approximation

01:15:43.390 --> 01:15:44.690
standpoint.

01:15:44.690 --> 01:15:48.670
But there are lots of situations
where this kind of problem

01:15:48.670 --> 01:15:49.370
comes up.

01:15:49.370 --> 01:15:50.890
Suppose you're laser cutting.

01:15:50.890 --> 01:15:52.540
This is one of the
first laser cutter

01:15:52.540 --> 01:15:56.410
projects we did with
George Hart, back in 2003,

01:15:56.410 --> 01:15:59.002
where cutting out these
two-headed salamanders

01:15:59.002 --> 01:16:00.460
like that and then
assembling them.

01:16:00.460 --> 01:16:05.770
If you've ever been to G6 in
Stata, it's hanging there.

01:16:05.770 --> 01:16:08.060
So you can think of this
laser cutting problems,

01:16:08.060 --> 01:16:11.340
you have a lot of dots and
you have to cut them all.

01:16:11.340 --> 01:16:13.610
That is literally what
happens to laser cutter

01:16:13.610 --> 01:16:16.150
is pulsing with little dots.

01:16:16.150 --> 01:16:17.780
And in this case it
looks pretty clear

01:16:17.780 --> 01:16:18.988
how to connect them together.

01:16:18.988 --> 01:16:22.380
But if you're cutting many
salamanders out of one sheet,

01:16:22.380 --> 01:16:24.910
and you think of the
salamander's pretty small,

01:16:24.910 --> 01:16:27.640
that's like a TSP problem
or really a milling problem.

01:16:27.640 --> 01:16:30.000
You have to visit all
these things using

01:16:30.000 --> 01:16:32.619
the shortest-- it's really
a lawn mowing problem.

01:16:32.619 --> 01:16:34.160
So you can turn off
the laser and you

01:16:34.160 --> 01:16:39.640
can move around somewhere else
that you don't want to visit.

01:16:39.640 --> 01:16:43.870
3D printing is like lawn
mowing problem in each layer.

01:16:43.870 --> 01:16:46.520
So 3D printing is done
by printing each layer

01:16:46.520 --> 01:16:48.630
and then stacking
them up one at a time.

01:16:48.630 --> 01:16:51.990
So in each layer you have
to deposit material in FDM,

01:16:51.990 --> 01:16:53.700
say we're additive printing.

01:16:53.700 --> 01:16:55.529
You have to deposit material.

01:16:55.529 --> 01:16:57.570
If you're doing laser
curing, same kind of thing.

01:16:57.570 --> 01:17:01.260
How do you move the laser with
the shortest amount of work.

01:17:01.260 --> 01:17:02.810
It's called milling.

01:17:02.810 --> 01:17:04.270
I don't have an image for this.

01:17:04.270 --> 01:17:06.495
Because if you're doing NC
milling you have a drill

01:17:06.495 --> 01:17:09.810
and you're moving the drill
around to cut out some shape

01:17:09.810 --> 01:17:11.435
or to cut a region.

01:17:14.464 --> 01:17:16.630
There you're not allowed
to go outside the shape you

01:17:16.630 --> 01:17:20.346
want to cut, because you go
outside, you cut too much.

01:17:20.346 --> 01:17:22.220
And you don't want to
have to pay to retract.

01:17:22.220 --> 01:17:24.761
There are other versions of the
problem where you can retract

01:17:24.761 --> 01:17:28.320
the cutting bit and so on.

01:17:28.320 --> 01:17:32.010
So of course we proved
milling is hard.

01:17:32.010 --> 01:17:34.280
That is exactly the
Hamilton [INAUDIBLE]

01:17:34.280 --> 01:17:36.926
graphs if you're not
allowed to leave the region.

01:17:36.926 --> 01:17:39.050
Of course, that also shows
that lawn mowing is hard

01:17:39.050 --> 01:17:41.190
because you never want
to go outside the region.

01:17:41.190 --> 01:17:43.430
One fun result is lawn
mowing is hard even when you

01:17:43.430 --> 01:17:45.360
have no holes in your region.

01:17:45.360 --> 01:17:48.197
So if you cut these little
slits, from a lawn mowing

01:17:48.197 --> 01:17:50.030
perspective it basically
makes no difference

01:17:50.030 --> 01:17:51.795
because you could
still go over it,

01:17:51.795 --> 01:17:53.420
and it doesn't really
save you anything

01:17:53.420 --> 01:17:55.050
to not have to cut that.

01:17:55.050 --> 01:17:57.925
So lawn mowing is hard
even without holes.

01:18:01.350 --> 01:18:02.060
Cool.

01:18:02.060 --> 01:18:03.540
I have one more problem.

01:18:03.540 --> 01:18:05.330
Do you want to see it?

01:18:05.330 --> 01:18:07.520
OK.

01:18:07.520 --> 01:18:10.230
So here's-- sorry--
a brief warm-up.

01:18:10.230 --> 01:18:12.700
Suppose you have a grid graph.

01:18:12.700 --> 01:18:14.650
You rotate it 45 degrees.

01:18:14.650 --> 01:18:19.200
You can represent each of these
vertices as a vertical segment

01:18:19.200 --> 01:18:22.260
if they're black parity
or horizontal segment.

01:18:22.260 --> 01:18:25.230
If they're white parity
such that segments

01:18:25.230 --> 01:18:28.580
intersect, if and only if
there's an edge joining.

01:18:28.580 --> 01:18:30.180
So these are unit
orthogonal segments.

01:18:30.180 --> 01:18:31.679
This is called an
intersection graph

01:18:31.679 --> 01:18:33.810
where the vertices
are the objects,

01:18:33.810 --> 01:18:37.430
and the edges are
whether things intersect.

01:18:37.430 --> 01:18:41.790
I need that, so Hamiltonicity
in these graphs is hard.

01:18:41.790 --> 01:18:45.270
Here's a problem called
minimum turn milling.

01:18:45.270 --> 01:18:49.590
So a big issue for 3D
printing, for milling,

01:18:49.590 --> 01:18:52.710
usually when you're cutting
or you're depositing material,

01:18:52.710 --> 01:18:55.061
you can move really
fast in a straight line.

01:18:55.061 --> 01:18:56.560
But when you need
to make a turn you

01:18:56.560 --> 01:19:00.050
have to basically come to a
stop and then speed up again.

01:19:00.050 --> 01:19:05.100
So suppose you have infinite
acceleration, so to speak,

01:19:05.100 --> 01:19:06.630
or close to infinite
acceleration.

01:19:06.630 --> 01:19:08.800
So once you're going straight
you can go arbitrarily

01:19:08.800 --> 01:19:10.610
far for the same cost,
and what you really

01:19:10.610 --> 01:19:13.060
pay for is the slowing
down and speeding back up

01:19:13.060 --> 01:19:14.102
at every corner.

01:19:14.102 --> 01:19:16.310
So then you want to minimize
the number of turns, not

01:19:16.310 --> 01:19:17.760
the lengths.

01:19:17.760 --> 01:19:19.610
This is one of my
first hardness proofs

01:19:19.610 --> 01:19:22.050
that was not about puzzles.

01:19:22.050 --> 01:19:23.940
I think the original
paper was 2000,

01:19:23.940 --> 01:19:26.090
the journal version's 2005.

01:19:26.090 --> 01:19:29.170
So suppose you have one of these
rectangle intersection graphs.

01:19:29.170 --> 01:19:34.130
What we're going to do is
replace each of these things

01:19:34.130 --> 01:19:38.100
with a cycle, and then
thicken that cycle.

01:19:38.100 --> 01:19:44.090
This is a thin grid
graph, not super thin.

01:19:44.090 --> 01:19:46.640
Maybe super thin.

01:19:46.640 --> 01:19:48.820
Here it's super
thin, and here you

01:19:48.820 --> 01:19:51.790
have a little square
that you're cutting with.

01:19:51.790 --> 01:19:55.780
So each of these things you
have to make four turns.

01:19:55.780 --> 01:19:58.770
Then also, to go from one
of these to one of these,

01:19:58.770 --> 01:20:02.590
to go from one vertex to
the next, you need a turn.

01:20:02.590 --> 01:20:05.520
So in general, you're going
to need 5n turns in order

01:20:05.520 --> 01:20:08.341
to visit n of these
original segments.

01:20:08.341 --> 01:20:10.090
And you can do that
if and only if there's

01:20:10.090 --> 01:20:12.510
a Hamiltonian cycle
in the original graph,

01:20:12.510 --> 01:20:14.190
which was this picture.

01:20:14.190 --> 01:20:17.760
Basically, if you
come in one position--

01:20:17.760 --> 01:20:22.320
so here's one of these
rectangles you want to visit.

01:20:22.320 --> 01:20:24.420
You come in one
place and you know

01:20:24.420 --> 01:20:26.600
that you want to leave
on some other place.

01:20:26.600 --> 01:20:29.520
So you double this edge--
you're going to cut it twice.

01:20:29.520 --> 01:20:31.170
That's allowed in this model.

01:20:31.170 --> 01:20:32.580
And then you loop around.

01:20:32.580 --> 01:20:35.660
And the number of turns here
is exactly one to come in,

01:20:35.660 --> 01:20:37.560
four to go around, and
then one to come out.

01:20:37.560 --> 01:20:41.080
In general, it's one
per edge in the cycle,

01:20:41.080 --> 01:20:43.350
and four per vertex
in the cycle.

01:20:43.350 --> 01:20:47.679
So again, Hamiltonicity
gives us what we want.

01:20:47.679 --> 01:20:49.470
Even where we minimize
the number of turns,

01:20:49.470 --> 01:20:55.740
we can simulate that by counting
vertices as turns, basically.

01:20:55.740 --> 01:20:58.040
And that's it for Hamiltonicity.