algorithms, lecture 3 on np : nondeterministic polynomial time · 2017. 4. 6. · algorithms,...
TRANSCRIPT
![Page 1: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/1.jpg)
Algorithms,Lecture3onNP:NondeterministicPolynomialTime
![Page 2: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/2.jpg)
Lastweek:DefinedPolynomialTimeReductions:
ProblemXispolytimereducibletoYX≤PY
ifcansolveXusingpolycomputationandapolynumberofcallstoanalgorithmsolvingY.
“Uptopolyfactors,XisatleastaseasyasY”“Uptopolyfactors,YisharderthanX”
![Page 3: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/3.jpg)
Lastclass:DefinedNP:decision(yes/no)problemscancheckcertificatesforyesanswersinptime
Havepolytimeproofcheckers:ApolytimealgorithmAsothatifX(s)=yes,
thereexistsawsothatA(s,w)=yes,andifX(s)=no,
forallw,A(s,w)=no
![Page 4: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/4.jpg)
Lastclass:DefinedNP-Complete:1.X∈ NP,and2.XisNP-hard
XisNP-hardif:1.forallY∈ NP,Y≤P X,or2.CircuitSat ≤P X,or3.Y≤P X,forsomeNP-HardY,suchas
SAT,IndependentSet,VertexCover
![Page 5: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/5.jpg)
Lastclass:ProvedCircuitSAT isNP-Hard.
ProvedCircuitSAT ≤P SAT.
Infact,provedCircuitSAT ≤P 3-SAT
Where3-SATisSAT,buteachclausehasatmost3terms.
![Page 6: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/6.jpg)
Lastclass:ProvedCircuitSAT isNP-Hard.
ProvedCircuitSAT ≤P SAT.
Infact,provedCircuitSAT ≤P 3-SAT
Where3-SATisSAT,buteachclausehasatmost3terms.
Alsopossibletoforceeachvariabletoappearatmost3times
![Page 7: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/7.jpg)
Alsopossibletoforceeachvariabletoappearatmost3times
Sayavariablexappearsktimes.
Createknewvariables,x1,…,xk,oneforeachoccurrence.
Addclausesx1Vx2 ,x2Vx3 ,…,xk-1Vxk ,xk Vx1
Onlysatisfiedifallareequal.
![Page 8: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/8.jpg)
Today
WillprovemoreproblemsareNP-complete:
3-coloringHamiltonianCycleTravellingSalesmanProblem
![Page 9: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/9.jpg)
k-Coloring
GivenagraphG=(V,E),doesthereexistf:V→ {1,2,…,k}(colors)
Sothatforall(u,v)∈ Ef(u) f(v)?
3-colorable Not3-colorable
6=
![Page 10: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/10.jpg)
3-colorable Not3-colorable
k-Coloring
GivenagraphG=(V,E),doesthereexistf:V→ {1,2,…,k}(colors)
Sothatforall(u,v)∈ Ef(u) f(v)?6=
![Page 11: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/11.jpg)
k-ColoringisNP-Complete
ClearlyinNP,becausecancheckaproposedcoloringToproveNP-hard,willshow3-SAT≤P 3-Coloring
GivenacollectionofclausesC1,…,Ck,eachwithatmost3terms,onvariablesx1,…,xnproducegraphG=(V,E)thatis3-colorableiff theclausesaresatisfiable
![Page 12: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/12.jpg)
3-ColoringisNP-Complete– variablegadgets
Create3specialnodes:T,F,B(base),andonenodeforeachterm:xi andxi
x1x1 x2x2 xnxn
Inevery3-coloring,oneofxi andxiiscoloredTandoneiscoloredF
T F
B
![Page 13: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/13.jpg)
xnxnx1
Create3specialnodes:T,F,B(base),andonenodeforeachterm:xi andxi
x1 x2x2
Inevery3-coloring,oneofxi andxiiscoloredTandoneiscoloredF
3-ColoringisNP-Complete– variablegadgets
FT
B
![Page 14: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/14.jpg)
Considerclausex1Vx2 Vxn
3-ColoringisNP-Complete– clausegadgets
x1 x2 xn
Claim:3-colorableiff termscoloredtosatisfyclause
T
B
![Page 15: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/15.jpg)
3-ColoringisNP-Complete– clausegadgets
x1 x2 xn
Claim:3-colorableiff termscoloredtosatisfyclause
1.IftermsallcoloredF,thencannot3-color
T
B
![Page 16: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/16.jpg)
3-ColoringisNP-Complete– clausegadgets
x1 x2 xn
Claim:3-colorableiff termscoloredtosatisfyclause
1.IftermsallcoloredF,thencannot3-color
T
B
![Page 17: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/17.jpg)
3-ColoringisNP-Complete– clausegadgets
x1 x2 xn
Claim:3-colorableiff termscoloredtosatisfyclause
1.IftermsallcoloredF,thencannot3-color
T
B
![Page 18: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/18.jpg)
xnx2x1
3-ColoringisNP-Complete– clausegadgetsClaim:3-colorableiff termscoloredtosatisfyclause
2.Ifsometermtrue,can3-color
T
B
![Page 19: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/19.jpg)
x2x1 xn
3-ColoringisNP-Complete– clausegadgetsClaim:3-colorableiff termscoloredtosatisfyclause
2.Ifsometermtrue,can3-color
T
B
![Page 20: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/20.jpg)
xnx2x1
3-ColoringisNP-Complete– clausegadgetsClaim:3-colorableiff termscoloredtosatisfyclause
2.Ifsometermtrue,can3-color
T
B
![Page 21: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/21.jpg)
3-ColoringisNP-Complete
x1x1 x2x2 xnxnx3x3
x1Vx2 Vxn
3-colorableiffsatisfiable
FT
B
![Page 22: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/22.jpg)
3-ColoringisNP-Complete
x1x1 x2x2 xnxnx3x3
x1Vx2 Vxn x2Vx3 Vxn
3-colorableiffsatisfiable
FT
B
![Page 23: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/23.jpg)
HamiltonianCycle:Acycleinagraphthathitseachvertexonce.
DirectedHamiltonianCycle:same,butinadirectedgraph
![Page 24: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/24.jpg)
DirectedHamCycleisNP-Complete
ClearlyinNP,becausecancheckifacycleisHamiltonian
ToproveNP-hard,willshow3-SAT≤P DirectedHamCycle
ProducedirectedgraphG=(V,E)thathasHamCycleiff theclausesaresatisfiable
![Page 25: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/25.jpg)
Start:creategraphwith2n HamCycles,thencreategadgetstorestrictthem
1:
2:
3:
n:
![Page 26: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/26.jpg)
Start:creategraphwith2n HamCycles,thencreategadgetstorestrictthem
1:
2:
3:
n:
![Page 27: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/27.jpg)
Start:creategraphwith2n HamCycles,thencreategadgetstorestrictthem
s
t
1:
2:3:
n:
Mustgotop-to-bottom,andcantraverseeachrowleft-to-right(True)orright-to-left(False)
![Page 28: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/28.jpg)
Start:creategraphwith2n HamCycles,thencreategadgetstorestrictthem
Mustgotop-to-bottom,andcantraverseeachrowleft-to-right(True)orright-to-left(False)
s
t
1:
2:3:
n:
![Page 29: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/29.jpg)
Clausegadgets TrueFalse
s
t
1:
2:3:
n:
clausex1 forcestraversefirstrow
![Page 30: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/30.jpg)
x1Vx2 Vxn
Clausegadgets TrueFalse
s
t
1:
2:3:
n:
clause
Forcestraverse1,or2,orn
![Page 31: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/31.jpg)
x1Vx2 Vxn
Clausegadgets TrueFalse
2:
clause
Toseemustcomebacktosamerow,notethatifdonotisnohamiltonianpaththroughunuseddown-link
![Page 32: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/32.jpg)
x1Vx2 Vxn
Clausegadgets TrueFalse
1:
2:
n:
clause
Forcestraverse1,or2,orn
![Page 33: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/33.jpg)
x1Vx2 VxnHamcycleiff satisfiable TrueFalse
s
t
1:
2:3:
n:
Pf.Ifsatisfiable,traverseinorderindicatedbyvars,pickingupeachclauseonceusingsometrueterm.
![Page 34: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/34.jpg)
x1Vx2 VxnHamcycleiff satisfiable TrueFalse
s
t
1:
2:3:
n:
Pf.IfHamCycle,mustgotoptobottom
assignvars bydirection
ifvisiteachclausenode,thenismadetruebytermonrowfromwhichmakethevisit.
![Page 35: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/35.jpg)
voutvin
DirectedHamCycle≤PHamCycle
1. Indirectedproblem,answersameifreverseallarrows.
2.Totransformtoundirected,replaceeachvertexvwiththreevertices:vin,vbase,vout
vbuoutuin ub
u vReplacedirected(u,v)edgewith(uout ,vin )
![Page 36: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/36.jpg)
DirectedHamCycle≤PHamCycle
uoutuin ub
Claim:Iftheseareonlyedgestoub,thenineveryHamiltoniancycleub mustbeadjacenttouin
Proof:ifitisnot,thenonceenterubcannotgetout
![Page 37: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/37.jpg)
voutvin vbuoutuin ub
Replacedirected(u,v)edgewith(uout ,vin )
DirectedHamCycleinoriginal->HamCycle
woutwin wb
u v
w
DirectedHamCycle≤PHamCycle
![Page 38: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/38.jpg)
voutvin vbuoutuin ub
Replacedirected(u,v)edgewith(uout ,vin )
Lemma:EveryHamCycleintheundirectedgraphmustgoin,base,out,in,base,out,in,base,out,etc,mustcorrespondtoaHamCyc indirectedgraph
woutwin wb
u v
w
DirectedHamCycle≤PHamCycle
![Page 39: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/39.jpg)
TSP(TravellingSalespersonProblem)
Givennlocations,adistancefunctiond(u,v)andatotaldistanceD,doesthereexistatourthroughalllocationsoftotaldistanceatmostL?
http://www.tsp.gatech.edu/usa13509/usa13509_info.html
![Page 40: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/40.jpg)
TSP(TravellingSalespersonProblem)
Givennlocations,adistancefunctiond(u,v)andatotaldistanceD,doesthereexistatourthroughalllocationsoftotaldistanceatmostL?
http://www.tsp.gatech.edu/usa13509/usa13509_sol.html
![Page 41: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/41.jpg)
RL5915 optimal solutionAn optimal solution for RL5915 is given by the following tour, which has length 565530.
http://www.tsp.gatech.edu/rl5915/rl5915_sol.html
![Page 42: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/42.jpg)
TSPisNP-complete
HamCycle≤PTSP
GivengraphG=(V,E),createonelocationforeachvertex,
d(u,v)=1if(u,v)∈ E2otherwise
Targetdistance=|V|
Atourofalllocationsthatreturnstostartandhastotallength|V|mustuseexactly|V|edgesofG
![Page 43: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/43.jpg)
TSPisNP-complete
HamCycle≤PTSP
GivengraphG=(V,E),createonelocationforeachvertex,
d(u,v)=1if(u,v)∈ E2otherwise
Thisisanabstractdistancefunction.
![Page 44: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/44.jpg)
TSPisNP-complete
HamCycle≤PTSP
GivengraphG=(V,E),createonelocationforeachvertex,
d(u,v)=1if(u,v)∈ E2otherwise
Thisisanabstractdistancefunction.
RemainsNP-hardforintegerpointsinplane.
![Page 45: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/45.jpg)
IssuewithPlanarTSP
Ifinputislocationsofpoints,insteadofdistances
TheproblemisnotknowntobeinNP,becausedonotknowifcancomparedistancesinpolynomialtime.
Forintegersx1,…,xn integert,donothavepolytimealgorithmtotestif
X
i
pxi t
![Page 46: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/46.jpg)
![Page 47: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/47.jpg)
![Page 48: Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time · 2017. 4. 6. · Algorithms, Lecture 3 on NP : Nondeterministic Polynomial Time. Last week: Defined Polynomial Time](https://reader034.vdocuments.net/reader034/viewer/2022051805/5ff4553baae07d7a266e3c13/html5/thumbnails/48.jpg)