SlideShare a Scribd company logo
Approximation Algorithms
for NP – Hard Problems
Dr. P. Subathra
Professor
Dept. of IT
KAMARAJ College of Engg. & Tech.
(AUTONOMOUS)
Madurai
1
Approximation Algorithms
• We discuss a different approach to handling
difficult problems of combinatorial
optimization
• Traveling salesman problem and the knapsack
problem
• The decision versions of these problems are
NP-complete.
• The optimization versions fall in the class of
NP-hard problems
2
Approximation Algorithms
• There are no known polynomial-time
algorithms for these problems
• So how do we handle them?
• If an instance of the problem in question is
very small
– exhaustive-search algorithm
– dynamic programming technique
– branch-and-bound technique (comparatively
larger problems can be solved)
3
Approximation Algorithms
• There is a radically different way of dealing
with difficult optimization problems:
• solve them approximately by a fast algorithm.
• applications where a good but not necessarily
optimal solution will suffice
• approximation algorithms run based on some
problem-specific heuristic.
4
Approximation Algorithms
• A heuristic is a common-sense rule drawn
from experience rather than from a
mathematically proved assertion.
5
How accurate this approximation is?
• The accuracy of an approximate solution sa to
a problem of minimizing some function f by
the size of the relative error of this
approximation,
where s ∗ is an exact solution to the problem.
6
How accurate this approximation is?
• accuracy ratio
• Minimization Problem
• Maximization Problem
• The closer r(sa) is to 1, the better the
approximate solution is.
7
POLYNOMIAL-TIME APPROXIMATION
ALGORITHM
DEFINITION
• A polynomial-time approximation algorithm is said to
be a c-approximation algorithm, where c ≥ 1, if the
accuracy ratio of the approximation it produces does
not exceed c for any instance of the problem in
question:
• The best (i.e., the smallest) value of c is called the
performance ratio of the algorithm and denoted RA.
8
POLYNOMIAL-TIME APPROXIMATION
ALGORITHM
• We would like to have approximation
algorithms with RA as close to 1 as possible.
• Some approximation algorithms have infinitely
large performance ratios (RA=∞).
9
Travelling Salesman Problem
Approximation Algorithms
10
Travelling Salesman Problem
• There are more than a dozen approximation
algorithms that solve TSP in a reasonable
amount of time producing an approximate
solution.
• Example:
– Greedy Algorithms for the TSP
– Minimum-Spanning-Tree–Based Algorithms
– Local Search Heuristics
11
Travelling Salesman Problem
– Greedy Algorithms for the TSP
• Nearest-neighbor algorithm
• Multifragment-heuristic algorithm
– Minimum-Spanning-Tree–Based Algorithms
• Twice-around-the-tree algorithm
• Christofides Algorithm
– Local Search Heuristics
• 2-opt algorithms
• 3-opt algorithms
• Lin-Kernighan algorithms
12
Approximation Algorithm for TSP
Greedy Algorithms for the TSP
• Nearest-neighbor algorithm
• Multifragment-heuristic algorithm
13
Greedy Algorithms for the TSP:
Nearest-neighbor algorithm
Nearest-neighbor algorithm
• Algorithm:
Step 1 Choose an arbitrary city as the start.
Step 2 Repeat the following operation until
all the cities have been visited:
go to the unvisited city nearest the one
visited last (ties can be broken arbitrarily).
Step 3 Return to the starting city.
14
Nearest-neighbor algorithm
With a as the starting vertex,
the nearest-neighbor algorithm
yields the tour (Hamiltonian
circuit) sa:
a − b − c − d − a of length 10.
15
Nearest-neighbor algorithm
An optimal solution can be s*:
a − c − d − b − a of length 8.
16
Nearest-neighbor algorithm
The accuracy ratio of this
approximation is
• If the last links weight is ∞,
then the cost of the solution
will be infinity.
• Hence, RA =∞for this
algorithm
17
Greedy Algorithms for the TSP:
Multifragment-heuristic algorithm
Multifragment-heuristic algorithm
• It is problem of finding a minimum-weight
collection of edges in a given complete
weighted graph so that all the vertices have
degree 2.
18
Multifragment-heuristic algorithm
• Step 1
– Sort the edges in increasing order of their weights. (Ties
can be broken arbitrarily.)
– Initialize the set of tour edges to be constructed to the
empty set.
• Step 2
– Repeat this step n times, where n is the number of cities in
the instance being solved:
– add the next edge on the sorted edge list to the set of tour
edges, provided this addition does not create a vertex of
degree 3 or a cycle of length less than n;
– otherwise, skip the edge.
• Step 3
– Return the set of tour edges.
19
Multifragment-heuristic algorithm
• Sorted Edges as per weights:
{(a,b), (c,d), (b,c), (a,c), (b,d), (a,d)}
{ 1 , 1 , 2 , 3 , 3 , 6 }
• Initial Tour Set = {}
• Inset edge to Tour Set = {(a,b)} - OK
• Inset edge to Tour Set = {(c,d)} – OK
• Inset edge to Tour Set = {(b,c)} - OK
• Inset edge to Tour Set = {(a,c)} – NO
• Inset edge to Tour Set = {(b,d)} – NO
• Inset edge to Tour Set = {(a,d)} - OK
20
Multifragment-heuristic algorithm
• This method is applied to Eucledian Graphs
which follows the below conditions:
– triangle inequality d[i, j ]≤ d[i, k]+ d[k, j] for any
triple of cities i, j, and K
– symmetry d[i, j ]= d[j, i] for any pair of cities i and j
• Accuracy ratio satisfy the following inequality
21
Approximation Algorithm for TSP
Minimum-Spanning-Tree–Based Algorithms
• Twice-around-the-tree algorithm
• Christofides Algorithm
• There are approximation algorithms for the
traveling salesman problem that exploit a
connection between Hamiltonian circuits and
spanning trees of the same graph.
• Removing an edge from a Hamiltonian circuit
yields a spanning tree, so we use Min Span Tree
to produce a TSP tour
22
Minimum-Spanning-Tree–Based Algorithms
Twice-around-the-tree algorithm
• Step 1 Construct a minimum spanning tree of the graph
corresponding to a given instance of the traveling salesman
problem.
• Step 2 Starting at an arbitrary vertex, perform a walk around the
minimum spanning tree recording all the vertices passed by. (DFS
traversal.)
• Step 3 Scan the vertex list obtained in Step 2 and eliminate from it
all repeated occurrences of the same vertex except the starting one
at the end of the list. The vertices remaining on the list will form a
Hamiltonian circuit, which is the output of the algorithm.
23
Twice-around-the-tree algorithm
Initial Graph Minimum Spanning Tree
24
Twice-around-the-tree algorithm
Minimum Spanning Tree DFS - a, b, c, b, d, e, d, b, a.
25
Twice-around-the-tree algorithm
DFS - a, b, c, b, d, e, d, b, a. Eliminating the Second
Occurrences
a – b – c – d – e - a
26
Twice-around-the-tree algorithm
Initial Graph TSP : Cost = 4+6+10+7+12 = 39
27
Minimum-Spanning-Tree–Based Algorithms
Christofides Algorithm
• It also uses a minimum spanning tree like twice-
around-the-tree algorithm
• Eulerian circuit exists in a connected multigraph if and
only if all its vertices have even degrees.
• The Christofides algorithm obtains such a multigraph
by adding to the graph the edges of a minimum-weight
matching of all the odd-degree vertices in its minimum
spanning tree.
• Then the algorithm finds an Eulerian circuit in the
multigraph and transforms it into a Hamiltonian circuit
28
Christofides Algorithm
Algorithm
Step 1. Find a minimum spanning tree T
Step 2. Find a minimum matching M for the odd-
degree vertices in T
Step 3. Add M to T
Step 4. Find an Euler tour
Step 5. Cut short
29
Christofides Algorithm – Step 1
Initial Graph Minimum Spanning Tree
30
Christofides Algorithm – Step 2
• Odd degree edges:
a, b, c, e
• Possible matching pairs
with cost are :
(a,b) & (c,e) = 4+11 = 15
(a,c) & (b,e) = 8+ 9 = 17
(a,e) & (b,c) = 12+ 6 = 18
• Minimum of it is:
(a,b) & (c,e) = 4+11 = 15
31
Christofides Algorithm – Step 2
• Odd degree edges:
a, b, c, e
• Possible matching pairs
with cost are :
(a,b) & (c,e) = 4+11 = 15
(a,c) & (b,e) = 8+ 9 = 17
(a,e) & (b,c) = 12+ 6 = 18
• Minimum of it is:
(a,b) & (c,e) = 4+11 = 15
32
Christofides Algorithm – Step 3
Minimum Spanning Tree Matching Pair Added to MST
33
Christofides Algorithm – Step 4
Matching Pair Added to MST Euler Tour / Euler Circuit
a – b- c – e – d – b - a
34
Christofides Algorithm – Step 5
Initial Graph Cut Short - Eliminate Repetition
a – b- c – e – d – b - a
a – b - c – e – d - a
Hamiltonian Circuit
35
Approximation Algorithm for TSP
Local Search Heuristics
• 2-opt algorithms
• 3-opt algorithms
• Lin-Kernighan algorithms
• Good approximations to optimal tours can be
obtained by iterative-improvement algorithms,
which are also called local search heuristics.
36
LOCAL SEARCH HEURISTICS
• These algorithms start with some initial tour
• On each iteration, the algorithm explores a
neighborhood around the current tour by replacing a
few edges in the current tour by other edges.
• If the changes produce a shorter tour, the algorithm
makes it the current tour and continues by exploring its
neighborhood in the same manner
• otherwise, the current tour is returned as the
algorithm’s output and the algorithm stops
37
LOCAL SEARCH HEURISTICS
2-OPT ALGORITHMS
• The 2-opt algorithm works by deleting a pair
of nonadjacent edges in a tour and
reconnecting their endpoints by the different
pair of edges to obtain another Tour
• This operation is called the 2-change.
38
2-OPT ALGORITHMS
39
2-OPT ALGORITHM
• Choice 1
40
2-OPT ALGORITHM
• Choice 2
41
2-OPT ALGORITHM
• Choice 3
42
2-OPT ALGORITHM
• Choice 4
43
3-OPT ALGORITHMS
• 2 different options
44
Lin-Kernighan algorithm
• The Lin-Kernighan algorithm is a variable-opt
algorithm: its move can be viewed as a 3-opt
move followed by a sequence of 2-opt moves.
45
Approximation Algorithms for TSP
– Greedy Algorithms for the TSP
• Nearest-neighbor algorithm
• Multifragment-heuristic algorithm
– Minimum-Spanning-Tree–Based Algorithms
• Twice-around-the-tree algorithm
• Christofides Algorithm
– Local Search Heuristics
• 2-opt algorithms
• 3-opt algorithms
• Lin-Kernighan algorithms
46
Approximation Algorithms for TSP
47
APPLICATIONS OF TSP
• Circuit Board and VLSI – chip fabrication
• X-ray crystallography
• Genetic Engineering
48

More Related Content

PPT
HCI - Chapter 1
PDF
VTU internet of things(IOT) notes by Nithin,VVCE, Mysuru
PPTX
Transformers in Vision: From Zero to Hero
DOCX
VIRTUALIZATION STRUCTURES TOOLS.docx
PDF
Iot lab manual new
PDF
Entrepreneurship, Entrepreneurs and Startups
PPT
HCI - Chapter 4
PPTX
Lexical analysis - Compiler Design
HCI - Chapter 1
VTU internet of things(IOT) notes by Nithin,VVCE, Mysuru
Transformers in Vision: From Zero to Hero
VIRTUALIZATION STRUCTURES TOOLS.docx
Iot lab manual new
Entrepreneurship, Entrepreneurs and Startups
HCI - Chapter 4
Lexical analysis - Compiler Design

What's hot (20)

PDF
I.BEST FIRST SEARCH IN AI
PDF
P, NP, NP-Complete, and NP-Hard
PPT
Bellman Ford's Algorithm
PPT
5 csp
PPTX
Knapsack problem using greedy approach
PPTX
Alpha-beta pruning (Artificial Intelligence)
PPTX
Lecture 14 Heuristic Search-A star algorithm
PPT
Lower bound
PPTX
Min-Max algorithm
PDF
I. Hill climbing algorithm II. Steepest hill climbing algorithm
PPTX
Predicate logic
PPT
Randomized algorithms ver 1.0
PPT
UNIT-1-PPTS-DAA.ppt
PPT
Dinive conquer algorithm
PDF
AI 7 | Constraint Satisfaction Problem
PPTX
Travelling Salesman Problem
PPTX
Problem solving in Artificial Intelligence.pptx
PPTX
Job sequencing with deadline
PPTX
Heuristics Search Techniques in AI
PPT
Heuristic Search Techniques Unit -II.ppt
I.BEST FIRST SEARCH IN AI
P, NP, NP-Complete, and NP-Hard
Bellman Ford's Algorithm
5 csp
Knapsack problem using greedy approach
Alpha-beta pruning (Artificial Intelligence)
Lecture 14 Heuristic Search-A star algorithm
Lower bound
Min-Max algorithm
I. Hill climbing algorithm II. Steepest hill climbing algorithm
Predicate logic
Randomized algorithms ver 1.0
UNIT-1-PPTS-DAA.ppt
Dinive conquer algorithm
AI 7 | Constraint Satisfaction Problem
Travelling Salesman Problem
Problem solving in Artificial Intelligence.pptx
Job sequencing with deadline
Heuristics Search Techniques in AI
Heuristic Search Techniques Unit -II.ppt
Ad

Similar to Approximation Algorithms TSP (20)

PDF
Data Analysis and Algorithms Lecture 1: Introduction
PPT
3 Greedy-lec.pptggggghhhhhhhyyyyyyyyyyyyyy
PPTX
Undecidable Problems and Approximation Algorithms
PPTX
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
PPTX
unit-4-dynamic programming
PDF
Algorithms Lab PPT
PPT
Least Square Optimization and Sparse-Linear Solver
PDF
PDF
Computer algorithm(Dynamic Programming).pdf
PPTX
7. Algorithm Design and analysis ppt.pptx
PPTX
10_support_vector_machines (1).pptx
PPTX
Approximation algorithms
PPTX
Chapter 5.pptx
PPT
Discrete Computaional Geometry
PDF
Introduction to Greedy method, 0/1 Knapsack problem
PDF
Unit3_1.pdf
PPT
Order Picking include Pick Sequencing and Batching
PPTX
Greedy Strategy.pptxbfasjbjfn asnfn anjn
PPTX
PPTX
AAC ch 3 Advance strategies (Dynamic Programming).pptx
Data Analysis and Algorithms Lecture 1: Introduction
3 Greedy-lec.pptggggghhhhhhhyyyyyyyyyyyyyy
Undecidable Problems and Approximation Algorithms
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
unit-4-dynamic programming
Algorithms Lab PPT
Least Square Optimization and Sparse-Linear Solver
Computer algorithm(Dynamic Programming).pdf
7. Algorithm Design and analysis ppt.pptx
10_support_vector_machines (1).pptx
Approximation algorithms
Chapter 5.pptx
Discrete Computaional Geometry
Introduction to Greedy method, 0/1 Knapsack problem
Unit3_1.pdf
Order Picking include Pick Sequencing and Batching
Greedy Strategy.pptxbfasjbjfn asnfn anjn
AAC ch 3 Advance strategies (Dynamic Programming).pptx
Ad

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai (20)

PPTX
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
PPTX
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
PPTX
PDF
PDF
The stable marriage problem iterative improvement method
PDF
Maximum matching in bipartite graphs iterative improvement method
PDF
Knapsack dynamic programming formula top down (1)
PDF
PDF
Multiplication of integers & strassens matrix multiplication subi notes
PDF
Multiplication of large integers problem subi notes
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
The stable marriage problem iterative improvement method
Maximum matching in bipartite graphs iterative improvement method
Knapsack dynamic programming formula top down (1)
Multiplication of integers & strassens matrix multiplication subi notes
Multiplication of large integers problem subi notes

Recently uploaded (20)

PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Sustainable Sites - Green Building Construction
DOCX
573137875-Attendance-Management-System-original
PPTX
UNIT 4 Total Quality Management .pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Welding lecture in detail for understanding
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Lecture Notes Electrical Wiring System Components
Sustainable Sites - Green Building Construction
573137875-Attendance-Management-System-original
UNIT 4 Total Quality Management .pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
OOP with Java - Java Introduction (Basics)
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Welding lecture in detail for understanding
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Embodied AI: Ushering in the Next Era of Intelligent Systems
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx

Approximation Algorithms TSP

  • 1. Approximation Algorithms for NP – Hard Problems Dr. P. Subathra Professor Dept. of IT KAMARAJ College of Engg. & Tech. (AUTONOMOUS) Madurai 1
  • 2. Approximation Algorithms • We discuss a different approach to handling difficult problems of combinatorial optimization • Traveling salesman problem and the knapsack problem • The decision versions of these problems are NP-complete. • The optimization versions fall in the class of NP-hard problems 2
  • 3. Approximation Algorithms • There are no known polynomial-time algorithms for these problems • So how do we handle them? • If an instance of the problem in question is very small – exhaustive-search algorithm – dynamic programming technique – branch-and-bound technique (comparatively larger problems can be solved) 3
  • 4. Approximation Algorithms • There is a radically different way of dealing with difficult optimization problems: • solve them approximately by a fast algorithm. • applications where a good but not necessarily optimal solution will suffice • approximation algorithms run based on some problem-specific heuristic. 4
  • 5. Approximation Algorithms • A heuristic is a common-sense rule drawn from experience rather than from a mathematically proved assertion. 5
  • 6. How accurate this approximation is? • The accuracy of an approximate solution sa to a problem of minimizing some function f by the size of the relative error of this approximation, where s ∗ is an exact solution to the problem. 6
  • 7. How accurate this approximation is? • accuracy ratio • Minimization Problem • Maximization Problem • The closer r(sa) is to 1, the better the approximate solution is. 7
  • 8. POLYNOMIAL-TIME APPROXIMATION ALGORITHM DEFINITION • A polynomial-time approximation algorithm is said to be a c-approximation algorithm, where c ≥ 1, if the accuracy ratio of the approximation it produces does not exceed c for any instance of the problem in question: • The best (i.e., the smallest) value of c is called the performance ratio of the algorithm and denoted RA. 8
  • 9. POLYNOMIAL-TIME APPROXIMATION ALGORITHM • We would like to have approximation algorithms with RA as close to 1 as possible. • Some approximation algorithms have infinitely large performance ratios (RA=∞). 9
  • 11. Travelling Salesman Problem • There are more than a dozen approximation algorithms that solve TSP in a reasonable amount of time producing an approximate solution. • Example: – Greedy Algorithms for the TSP – Minimum-Spanning-Tree–Based Algorithms – Local Search Heuristics 11
  • 12. Travelling Salesman Problem – Greedy Algorithms for the TSP • Nearest-neighbor algorithm • Multifragment-heuristic algorithm – Minimum-Spanning-Tree–Based Algorithms • Twice-around-the-tree algorithm • Christofides Algorithm – Local Search Heuristics • 2-opt algorithms • 3-opt algorithms • Lin-Kernighan algorithms 12
  • 13. Approximation Algorithm for TSP Greedy Algorithms for the TSP • Nearest-neighbor algorithm • Multifragment-heuristic algorithm 13
  • 14. Greedy Algorithms for the TSP: Nearest-neighbor algorithm Nearest-neighbor algorithm • Algorithm: Step 1 Choose an arbitrary city as the start. Step 2 Repeat the following operation until all the cities have been visited: go to the unvisited city nearest the one visited last (ties can be broken arbitrarily). Step 3 Return to the starting city. 14
  • 15. Nearest-neighbor algorithm With a as the starting vertex, the nearest-neighbor algorithm yields the tour (Hamiltonian circuit) sa: a − b − c − d − a of length 10. 15
  • 16. Nearest-neighbor algorithm An optimal solution can be s*: a − c − d − b − a of length 8. 16
  • 17. Nearest-neighbor algorithm The accuracy ratio of this approximation is • If the last links weight is ∞, then the cost of the solution will be infinity. • Hence, RA =∞for this algorithm 17
  • 18. Greedy Algorithms for the TSP: Multifragment-heuristic algorithm Multifragment-heuristic algorithm • It is problem of finding a minimum-weight collection of edges in a given complete weighted graph so that all the vertices have degree 2. 18
  • 19. Multifragment-heuristic algorithm • Step 1 – Sort the edges in increasing order of their weights. (Ties can be broken arbitrarily.) – Initialize the set of tour edges to be constructed to the empty set. • Step 2 – Repeat this step n times, where n is the number of cities in the instance being solved: – add the next edge on the sorted edge list to the set of tour edges, provided this addition does not create a vertex of degree 3 or a cycle of length less than n; – otherwise, skip the edge. • Step 3 – Return the set of tour edges. 19
  • 20. Multifragment-heuristic algorithm • Sorted Edges as per weights: {(a,b), (c,d), (b,c), (a,c), (b,d), (a,d)} { 1 , 1 , 2 , 3 , 3 , 6 } • Initial Tour Set = {} • Inset edge to Tour Set = {(a,b)} - OK • Inset edge to Tour Set = {(c,d)} – OK • Inset edge to Tour Set = {(b,c)} - OK • Inset edge to Tour Set = {(a,c)} – NO • Inset edge to Tour Set = {(b,d)} – NO • Inset edge to Tour Set = {(a,d)} - OK 20
  • 21. Multifragment-heuristic algorithm • This method is applied to Eucledian Graphs which follows the below conditions: – triangle inequality d[i, j ]≤ d[i, k]+ d[k, j] for any triple of cities i, j, and K – symmetry d[i, j ]= d[j, i] for any pair of cities i and j • Accuracy ratio satisfy the following inequality 21
  • 22. Approximation Algorithm for TSP Minimum-Spanning-Tree–Based Algorithms • Twice-around-the-tree algorithm • Christofides Algorithm • There are approximation algorithms for the traveling salesman problem that exploit a connection between Hamiltonian circuits and spanning trees of the same graph. • Removing an edge from a Hamiltonian circuit yields a spanning tree, so we use Min Span Tree to produce a TSP tour 22
  • 23. Minimum-Spanning-Tree–Based Algorithms Twice-around-the-tree algorithm • Step 1 Construct a minimum spanning tree of the graph corresponding to a given instance of the traveling salesman problem. • Step 2 Starting at an arbitrary vertex, perform a walk around the minimum spanning tree recording all the vertices passed by. (DFS traversal.) • Step 3 Scan the vertex list obtained in Step 2 and eliminate from it all repeated occurrences of the same vertex except the starting one at the end of the list. The vertices remaining on the list will form a Hamiltonian circuit, which is the output of the algorithm. 23
  • 25. Twice-around-the-tree algorithm Minimum Spanning Tree DFS - a, b, c, b, d, e, d, b, a. 25
  • 26. Twice-around-the-tree algorithm DFS - a, b, c, b, d, e, d, b, a. Eliminating the Second Occurrences a – b – c – d – e - a 26
  • 27. Twice-around-the-tree algorithm Initial Graph TSP : Cost = 4+6+10+7+12 = 39 27
  • 28. Minimum-Spanning-Tree–Based Algorithms Christofides Algorithm • It also uses a minimum spanning tree like twice- around-the-tree algorithm • Eulerian circuit exists in a connected multigraph if and only if all its vertices have even degrees. • The Christofides algorithm obtains such a multigraph by adding to the graph the edges of a minimum-weight matching of all the odd-degree vertices in its minimum spanning tree. • Then the algorithm finds an Eulerian circuit in the multigraph and transforms it into a Hamiltonian circuit 28
  • 29. Christofides Algorithm Algorithm Step 1. Find a minimum spanning tree T Step 2. Find a minimum matching M for the odd- degree vertices in T Step 3. Add M to T Step 4. Find an Euler tour Step 5. Cut short 29
  • 30. Christofides Algorithm – Step 1 Initial Graph Minimum Spanning Tree 30
  • 31. Christofides Algorithm – Step 2 • Odd degree edges: a, b, c, e • Possible matching pairs with cost are : (a,b) & (c,e) = 4+11 = 15 (a,c) & (b,e) = 8+ 9 = 17 (a,e) & (b,c) = 12+ 6 = 18 • Minimum of it is: (a,b) & (c,e) = 4+11 = 15 31
  • 32. Christofides Algorithm – Step 2 • Odd degree edges: a, b, c, e • Possible matching pairs with cost are : (a,b) & (c,e) = 4+11 = 15 (a,c) & (b,e) = 8+ 9 = 17 (a,e) & (b,c) = 12+ 6 = 18 • Minimum of it is: (a,b) & (c,e) = 4+11 = 15 32
  • 33. Christofides Algorithm – Step 3 Minimum Spanning Tree Matching Pair Added to MST 33
  • 34. Christofides Algorithm – Step 4 Matching Pair Added to MST Euler Tour / Euler Circuit a – b- c – e – d – b - a 34
  • 35. Christofides Algorithm – Step 5 Initial Graph Cut Short - Eliminate Repetition a – b- c – e – d – b - a a – b - c – e – d - a Hamiltonian Circuit 35
  • 36. Approximation Algorithm for TSP Local Search Heuristics • 2-opt algorithms • 3-opt algorithms • Lin-Kernighan algorithms • Good approximations to optimal tours can be obtained by iterative-improvement algorithms, which are also called local search heuristics. 36
  • 37. LOCAL SEARCH HEURISTICS • These algorithms start with some initial tour • On each iteration, the algorithm explores a neighborhood around the current tour by replacing a few edges in the current tour by other edges. • If the changes produce a shorter tour, the algorithm makes it the current tour and continues by exploring its neighborhood in the same manner • otherwise, the current tour is returned as the algorithm’s output and the algorithm stops 37
  • 38. LOCAL SEARCH HEURISTICS 2-OPT ALGORITHMS • The 2-opt algorithm works by deleting a pair of nonadjacent edges in a tour and reconnecting their endpoints by the different pair of edges to obtain another Tour • This operation is called the 2-change. 38
  • 44. 3-OPT ALGORITHMS • 2 different options 44
  • 45. Lin-Kernighan algorithm • The Lin-Kernighan algorithm is a variable-opt algorithm: its move can be viewed as a 3-opt move followed by a sequence of 2-opt moves. 45
  • 46. Approximation Algorithms for TSP – Greedy Algorithms for the TSP • Nearest-neighbor algorithm • Multifragment-heuristic algorithm – Minimum-Spanning-Tree–Based Algorithms • Twice-around-the-tree algorithm • Christofides Algorithm – Local Search Heuristics • 2-opt algorithms • 3-opt algorithms • Lin-Kernighan algorithms 46
  • 48. APPLICATIONS OF TSP • Circuit Board and VLSI – chip fabrication • X-ray crystallography • Genetic Engineering 48