SlideShare a Scribd company logo
1 of 11
TSP  NP-Complete
Emre Can Kucukoglu
eckucukoglu@gmail.com
16.01.2016
Traveling Salesman Problem
• Given n cities 𝑐1, 𝑐2, 𝑐3, … , 𝑐 𝑛 and integer distances 𝑑 𝑐 𝑖,𝑐 𝑗
between
any two cities 𝑐𝑖 𝑎𝑛𝑑 𝑐𝑗.
• TSP asks for the total distance of the shortest tour of the cities.
• Decision version of TSP asks if there is a tour with a total distance
at most B, where B is an input.
TSP: formal description
TSP = {
<G, d, B> :
G=(V, E) is a complete undirected graph,
d is an edge cost function from VxV→Z+ ∪ {0},
B ∈ Z,
G has a Hamiltonian cycle with cost ≤ B
}
TSP  NP-Complete ?
• To prove that TSP  NP-Complete,
• First, we must show that there exists a nondeterministic algorithm in
polynomial time that solves TSP.
• TSP  NP
• Then, we will reduce the undirected Hamiltonian cycle, which is a known
NP-complete problem, to TSP:
• HAM-CYCLE ≤ 𝑝 TSP
Nondeterministic algorithm for TSP
• The following procedure is a
polynomial time non-deterministic
algorithm that terminates
successfully iff an ordering of n-
cities are distinct and sum of
distances between pairs are less
than or equal to B.
• The complexity of this non-
deterministic algorithm is O(n).
• So that; TSP  NP
Hamiltonian Circuit Problem
• Find a tour of a given unweighted graph that simply starts at one
vertex and goes through all the other vertices and ends at the
starting vertex.
• Note that the input graph G to a Hamiltonian Cycle problem need
not be a complete graph connecting all vertices.
• Hamiltonian circuit is a known NP-Complete problem.
• To transform Hamiltonian circuit/cycle problem to TSP,
• Create a graph G’ = (V, E’) from Hamiltonian cycle instance G = (V, E),
• G’ is a complete graph,
• Edges in E’ also in E have an edge cost 0,
• All other edges in E’ have an edge cost 1.
HAM-CYCLE ≤ 𝑝 TSP
• Take any instance G = (V, E) for
the Hamiltonian cycle
problem,
• Convert it into an instance
G′=(V, E′ = V×V, d), B = 0 of TSP,
• 𝑑 𝑐 𝑖,𝑐 𝑗
= { 0 if edge (𝑐𝑖, 𝑐𝑗)  E,
1 otherwise }
• Time complexity of reduction
is O(𝑛2) as there n(n-1)/2
edges on a complete graph.
HAM-CYCLE ≤ 𝑝 TSP
• Problem: Is there a TSP on G’ with total edge cost = 0 ?
• If G has a Hamiltonian circuit, algorithm will return "yes" on input (G′, C),
• If there is no Hamiltonian circuit in G, algorithm will return "no" on input (G′, C).
• If G’ has a cycle with cost = 0, every edge of that cycle has a cost = 0, thus G has a
Hamiltonian cycle.
• If Hamiltonian cycle does not exist, then there is no simple cycle in G, that visits
every vertex exactly once. Suppose that TSP has a “yes” answer. Then, there is a
cycle that visits every vertex once with total cost = 0. Since negative distance cost is
not possible, every edges have cost = 0, which implies that these edges are in the
Hamiltonian Circuit graph. It is a contradiction.
HAM-CYCLE ≤ 𝑝 TSP
TSP  NP-Complete
• It is well known that Hamiltonian Circuit is NP-Complete, every
problem ß in NP reduces to Hamiltonian Circuit in polynomial
time.
• We have reduced Hamiltonian Circuit to TSP in polynomial time, it
indicates that every problem ß in NP reduces to TSP is polynomial
time, since the sum of two polynomials is also a polynomial.
References
• http://www.csie.ntu.edu.tw/~lyuu/complexity/2004/c_20040929.pdf
• http://web.calstatela.edu/faculty/jmiller6/2014spring-
cs312/lectures/Lecture10.pdf
• https://www.quora.com/Why-is-the-traveling-salesman-problem-NP-
complete/answer/Luke-Benning

More Related Content

What's hot

daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsSwapnil Agrawal
 
Fuzzy logic and application in AI
Fuzzy logic and application in AIFuzzy logic and application in AI
Fuzzy logic and application in AIIldar Nurgaliev
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxAkhilJoseph63
 
Adaline madaline
Adaline madalineAdaline madaline
Adaline madalineNagarajan
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite AutomataAdel Al-Ofairi
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemMohammad Imam Hossain
 
Amortized Analysis of Algorithms
Amortized Analysis of Algorithms Amortized Analysis of Algorithms
Amortized Analysis of Algorithms sathish sak
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithmMohd Arif
 

What's hot (20)

daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Primality
PrimalityPrimality
Primality
 
Backtracking
Backtracking  Backtracking
Backtracking
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Sum of subset problem.pptx
Sum of subset problem.pptxSum of subset problem.pptx
Sum of subset problem.pptx
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Fuzzy logic and application in AI
Fuzzy logic and application in AIFuzzy logic and application in AI
Fuzzy logic and application in AI
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptx
 
Adaline madaline
Adaline madalineAdaline madaline
Adaline madaline
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
Amortized Analysis of Algorithms
Amortized Analysis of Algorithms Amortized Analysis of Algorithms
Amortized Analysis of Algorithms
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
A* Search Algorithm
A* Search AlgorithmA* Search Algorithm
A* Search Algorithm
 

Similar to TSP NP-Complete: Hamiltonian Cycle Reduction

chapter1 (1).ppt
chapter1 (1).pptchapter1 (1).ppt
chapter1 (1).pptNateHigger
 
lecture 29
lecture 29lecture 29
lecture 29sajinsc
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programminghodcsencet
 
Solving connectivity problems via basic Linear Algebra
Solving connectivity problems via basic Linear AlgebraSolving connectivity problems via basic Linear Algebra
Solving connectivity problems via basic Linear Algebracseiitgn
 
The Traveling Salesman Problem
The Traveling Salesman ProblemThe Traveling Salesman Problem
The Traveling Salesman ProblemMaryam Alipour
 
lecture 30
lecture 30lecture 30
lecture 30sajinsc
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpProgramming Homework Help
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsMuthu Vinayagam
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Nguyễn Công Hoàng
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERmuthukrishnavinayaga
 
Thermodynamics of Computation: Far More Than Counting Bit Erasure
Thermodynamics of Computation: Far More Than Counting Bit ErasureThermodynamics of Computation: Far More Than Counting Bit Erasure
Thermodynamics of Computation: Far More Than Counting Bit Erasureinside-BigData.com
 

Similar to TSP NP-Complete: Hamiltonian Cycle Reduction (20)

chapter1 (1).ppt
chapter1 (1).pptchapter1 (1).ppt
chapter1 (1).ppt
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
lecture 29
lecture 29lecture 29
lecture 29
 
P vs NP
P vs NP P vs NP
P vs NP
 
Reductions
ReductionsReductions
Reductions
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
 
Solving connectivity problems via basic Linear Algebra
Solving connectivity problems via basic Linear AlgebraSolving connectivity problems via basic Linear Algebra
Solving connectivity problems via basic Linear Algebra
 
Approximation
ApproximationApproximation
Approximation
 
The Traveling Salesman Problem
The Traveling Salesman ProblemThe Traveling Salesman Problem
The Traveling Salesman Problem
 
lecture 30
lecture 30lecture 30
lecture 30
 
Chap8 new
Chap8 newChap8 new
Chap8 new
 
NP Complete Problems -- Internship
NP Complete Problems -- InternshipNP Complete Problems -- Internship
NP Complete Problems -- Internship
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
 
Approx
ApproxApprox
Approx
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
 
Teori pnp
Teori pnpTeori pnp
Teori pnp
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
 
Daa chapter11
Daa chapter11Daa chapter11
Daa chapter11
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
 
Thermodynamics of Computation: Far More Than Counting Bit Erasure
Thermodynamics of Computation: Far More Than Counting Bit ErasureThermodynamics of Computation: Far More Than Counting Bit Erasure
Thermodynamics of Computation: Far More Than Counting Bit Erasure
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

TSP NP-Complete: Hamiltonian Cycle Reduction

  • 1. TSP  NP-Complete Emre Can Kucukoglu eckucukoglu@gmail.com 16.01.2016
  • 2. Traveling Salesman Problem • Given n cities 𝑐1, 𝑐2, 𝑐3, … , 𝑐 𝑛 and integer distances 𝑑 𝑐 𝑖,𝑐 𝑗 between any two cities 𝑐𝑖 𝑎𝑛𝑑 𝑐𝑗. • TSP asks for the total distance of the shortest tour of the cities. • Decision version of TSP asks if there is a tour with a total distance at most B, where B is an input.
  • 3. TSP: formal description TSP = { <G, d, B> : G=(V, E) is a complete undirected graph, d is an edge cost function from VxV→Z+ ∪ {0}, B ∈ Z, G has a Hamiltonian cycle with cost ≤ B }
  • 4. TSP  NP-Complete ? • To prove that TSP  NP-Complete, • First, we must show that there exists a nondeterministic algorithm in polynomial time that solves TSP. • TSP  NP • Then, we will reduce the undirected Hamiltonian cycle, which is a known NP-complete problem, to TSP: • HAM-CYCLE ≤ 𝑝 TSP
  • 5. Nondeterministic algorithm for TSP • The following procedure is a polynomial time non-deterministic algorithm that terminates successfully iff an ordering of n- cities are distinct and sum of distances between pairs are less than or equal to B. • The complexity of this non- deterministic algorithm is O(n). • So that; TSP  NP
  • 6. Hamiltonian Circuit Problem • Find a tour of a given unweighted graph that simply starts at one vertex and goes through all the other vertices and ends at the starting vertex. • Note that the input graph G to a Hamiltonian Cycle problem need not be a complete graph connecting all vertices. • Hamiltonian circuit is a known NP-Complete problem.
  • 7. • To transform Hamiltonian circuit/cycle problem to TSP, • Create a graph G’ = (V, E’) from Hamiltonian cycle instance G = (V, E), • G’ is a complete graph, • Edges in E’ also in E have an edge cost 0, • All other edges in E’ have an edge cost 1. HAM-CYCLE ≤ 𝑝 TSP
  • 8. • Take any instance G = (V, E) for the Hamiltonian cycle problem, • Convert it into an instance G′=(V, E′ = V×V, d), B = 0 of TSP, • 𝑑 𝑐 𝑖,𝑐 𝑗 = { 0 if edge (𝑐𝑖, 𝑐𝑗)  E, 1 otherwise } • Time complexity of reduction is O(𝑛2) as there n(n-1)/2 edges on a complete graph. HAM-CYCLE ≤ 𝑝 TSP
  • 9. • Problem: Is there a TSP on G’ with total edge cost = 0 ? • If G has a Hamiltonian circuit, algorithm will return "yes" on input (G′, C), • If there is no Hamiltonian circuit in G, algorithm will return "no" on input (G′, C). • If G’ has a cycle with cost = 0, every edge of that cycle has a cost = 0, thus G has a Hamiltonian cycle. • If Hamiltonian cycle does not exist, then there is no simple cycle in G, that visits every vertex exactly once. Suppose that TSP has a “yes” answer. Then, there is a cycle that visits every vertex once with total cost = 0. Since negative distance cost is not possible, every edges have cost = 0, which implies that these edges are in the Hamiltonian Circuit graph. It is a contradiction. HAM-CYCLE ≤ 𝑝 TSP
  • 10. TSP  NP-Complete • It is well known that Hamiltonian Circuit is NP-Complete, every problem ß in NP reduces to Hamiltonian Circuit in polynomial time. • We have reduced Hamiltonian Circuit to TSP in polynomial time, it indicates that every problem ß in NP reduces to TSP is polynomial time, since the sum of two polynomials is also a polynomial.