SlideShare a Scribd company logo
1 of 18

Home
 GATE Subjects
 B.Tech Subjects
 GATE 2022
 GATE CSE Books
 Job Opportunities
 Contact Us
 Subscribe
Tag: Travelling Salesman Problem Example with Solution PPT
Travelling Salesman Problem | Branch & Bound
Design & Analysis of Algorithms
Travelling Salesman Problem-
You are given-
 A set of some cities
 Distance between every pair of cities
Travelling Salesman Problem states-
 A salesman has to visit every city exactly once.
 He has to come back to the city from where he starts his journey.
 What is the shortest possible route that the salesman must follow to complete his tour?
Example-
The following graph shows a set of cities and distance between every pair of cities-
If salesman starting city is A, then a TSP tour in the graph is-
A → B → D → C → A
Cost of the tour
= 10 + 25 + 30 + 15
= 80 units
In this article, we will discuss how to solve travelling salesman problem using branch and bound
approach with example.
PRACTICE PROBLEM BASED ON TRAVELLING
SALESMAN PROBLEM USING BRANCH AND
BOUND APPROACH-
Problem-
Solve Travelling Salesman Problem using Branch and Bound Algorithm in the following graph-
Solution-
Step-01:
Write the initial cost matrix and reduce it-
Rules
 To reduce a matrix, perform the row reduction and column reduction of the matrix
separately.
 A row or a column is said to be reduced if it contains at least one entry ‘0’ in it.
Row Reduction-
Consider the rows of above matrix one by one.
If the row already contains an entry ‘0’, then-
 There is no need to reduce that row.
If the row does not contains an entry ‘0’, then-
 Reduce that particular row.
 Select the least value element from that row.
 Subtract that element from each element of that row.
 This will create an entry ‘0’ in that row, thus reducing that row.
Following this, we have-
 Reduce the elements of row-1 by 4.
 Reduce the elements of row-2 by 5.
 Reduce the elements of row-3 by 6.
 Reduce the elements of row-4 by 2.
Performing this, we obtain the following row-reduced matrix-
Column Reduction-
Consider the columns of above row-reduced matrix one by one.
If the column already contains an entry ‘0’, then-
 There is no need to reduce that column.
If the column does not contains an entry ‘0’, then-
 Reduce that particular column.
 Select the least value element from that column.
 Subtract that element from each element of that column.
 This will create an entry ‘0’ in that column, thus reducing that column.
Following this, we have-
 There is no need to reduce column-1.
 There is no need to reduce column-2.
 Reduce the elements of column-3 by 1.
 There is no need to reduce column-4.
Performing this, we obtain the following column-reduced matrix-
Finally, the initial distance matrix is completely reduced.
Now, we calculate the cost of node-1 by adding all the reduction elements.
Cost(1)
= Sum of all reduction elements
= 4 + 5 + 6 + 2 + 1
= 18
Step-02:
 We consider all other vertices one by one.
 We select the best vertex where we can land upon to minimize the tour cost.
Choosing To Go To Vertex-B: Node-2 (Path A → B)
 From the reduced matrix of step-01, M[A,B] = 0
 Set row-A and column-B to ∞
 Set M[B,A] = ∞
Now, resulting cost matrix is-
Now,
 We reduce this matrix.
 Then, we find out the cost of node-02.
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 Reduce all the elements of row-2 by 13.
 There is no need to reduce row-3.
 There is no need to reduce row-4.
Performing this, we obtain the following row-reduced matrix-
Column Reduction-
 Reduce the elements of column-1 by 5.
 We can not reduce column-2 as all its elements are ∞.
 There is no need to reduce column-3.
 There is no need to reduce column-4.
Performing this, we obtain the following column-reduced matrix-
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-2.
Cost(2)
= Cost(1) + Sum of reduction elements + M[A,B]
= 18 + (13 + 5) + 0
= 36
Choosing To Go To Vertex-C: Node-3 (Path A → C)
 From the reduced matrix of step-01, M[A,C] = 7
 Set row-A and column-C to ∞
 Set M[C,A] = ∞
Now, resulting cost matrix is-
Now,
 We reduce this matrix.
 Then, we find out the cost of node-03.
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 There is no need to reduce row-2.
 There is no need to reduce row-3.
 There is no need to reduce row-4.
Thus, the matrix is already row-reduced.
Column Reduction-
 There is no need to reduce column-1.
 There is no need to reduce column-2.
 We can not reduce column-3 as all its elements are ∞.
 There is no need to reduce column-4.
Thus, the matrix is already column reduced.
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-3.
Cost(3)
= Cost(1) + Sum of reduction elements + M[A,C]
= 18 + 0 + 7
= 25
Choosing To Go To Vertex-D: Node-4 (Path A → D)
 From the reduced matrix of step-01, M[A,D] = 3
 Set row-A and column-D to ∞
 Set M[D,A] = ∞
Now, resulting cost matrix is-
Now,
 We reduce this matrix.
 Then, we find out the cost of node-04.
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 There is no need to reduce row-2.
 Reduce all the elements of row-3 by 5.
 There is no need to reduce row-4.
Performing this, we obtain the following row-reduced matrix-
Column Reduction-
 There is no need to reduce column-1.
 There is no need to reduce column-2.
 There is no need to reduce column-3.
 We can not reduce column-4 as all its elements are ∞.
Thus, the matrix is already column-reduced.
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-4.
Cost(4)
= Cost(1) + Sum of reduction elements + M[A,D]
= 18 + 5 + 3
= 26
Thus, we have-
 Cost(2) = 36 (for Path A → B)
 Cost(3) = 25 (for Path A → C)
 Cost(4) = 26 (for Path A → D)
We choose the node with the lowest cost.
Since cost for node-3 is lowest, so we prefer to visit node-3.
Thus, we choose node-3 i.e. path A → C.
Step-03:
We explore the vertices B and D from node-3.
We now start from the cost matrix at node-3 which is-
Cost(3) = 25
Choosing To Go To Vertex-B: Node-5 (Path A → C → B)
 From the reduced matrix of step-02, M[C,B] = ∞
 Set row-C and column-B to ∞
 Set M[B,A] = ∞
Now, resulting cost matrix is-
Now,
 We reduce this matrix.
 Then, we find out the cost of node-5.
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 Reduce all the elements of row-2 by 13.
 We can not reduce row-3 as all its elements are ∞.
 Reduce all the elements of row-4 by 8.
Performing this, we obtain the following row-reduced matrix-
Column Reduction-
 There is no need to reduce column-1.
 We can not reduce column-2 as all its elements are ∞.
 We can not reduce column-3 as all its elements are ∞.
 There is no need to reduce column-4.
Thus, the matrix is already column reduced.
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-5.
Cost(5)
= cost(3) + Sum of reduction elements + M[C,B]
= 25 + (13 + 8) + ∞
= ∞
Choosing To Go To Vertex-D: Node-6 (Path A → C → D)
 From the reduced matrix of step-02, M[C,D] = ∞
 Set row-C and column-D to ∞
 Set M[D,A] = ∞
Now, resulting cost matrix is-
Now,
 We reduce this matrix.
 Then, we find out the cost of node-6.
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 There is no need to reduce row-2.
 We can not reduce row-3 as all its elements are ∞.
 We can not reduce row-4 as all its elements are ∞.
Thus, the matrix is already row reduced.
Column Reduction-
 There is no need to reduce column-1.
 We can not reduce column-2 as all its elements are ∞.
 We can not reduce column-3 as all its elements are ∞.
 We can not reduce column-4 as all its elements are ∞.
Thus, the matrix is already column reduced.
Finally, the matrix is completely reduced.
Now, we calculate the cost of node-6.
Cost(6)
= cost(3) + Sum of reduction elements + M[C,D]
= 25 + 0 + 0
= 25
Thus, we have-
 Cost(5) = ∞ (for Path A → C → B)
 Cost(6) = 25 (for Path A → C → D)
We choose the node with the lowest cost.
Since cost for node-6 is lowest, so we prefer to visit node-6.
Thus, we choose node-6 i.e. path C → D.
Step-04:
We explore vertex B from node-6.
We start with the cost matrix at node-6 which is-
Cost(6) = 25
Choosing To Go To Vertex-B: Node-7 (Path A → C → D → B)
 From the reduced matrix of step-03, M[D,B] = 0
 Set row-D and column-B to ∞
 Set M[B,A] = ∞
Now, resulting cost matrix is-
Now,
 We reduce this matrix.
 Then, we find out the cost of node-7.
Row Reduction-
 We can not reduce row-1 as all its elements are ∞.
 We can not reduce row-2 as all its elements are ∞.
 We can not reduce row-3 as all its elements are ∞.
 We can not reduce row-4 as all its elements are ∞.
Column Reduction-
 We can not reduce column-1 as all its elements are ∞.
 We can not reduce column-2 as all its elements are ∞.
 We can not reduce column-3 as all its elements are ∞.
 We can not reduce column-4 as all its elements are ∞.
Thus, the matrix is already column reduced.
Finally, the matrix is completely reduced.
All the entries have become ∞.
Now, we calculate the cost of node-7.
Cost(7)
= cost(6) + Sum of reduction elements + M[D,B]
= 25 + 0 + 0
= 25
Thus,
 Optimal path is: A → C → D → B → A
 Cost of Optimal path = 25 units
To gain better understanding about Travelling Salesman Problem,
Watch this Video Lecture
Get more notes and other study material of Design and Analysis of Algorithms.
Watch video lectures by visiting our YouTube channel LearnVidFun.
Follow us on Facebook
Choose your Subject
GATE Subjects
Database Management System
Computer Networks
Operating System
Computer Organization & Architecture
Data Structures
Theory of Automata & Computation
Compiler Design
Graph Theory
Design & Analysis of Algorithms
Digital Design
Number System
Discrete Mathematics
B.Tech Subjects
Computer Graphics
Machine Learning
Artificial Intelligence
Pattern Recognition
Software Engineering
Job Opportunities
Subscribe to get Email Notifications
First Name Last Name Email AddressSubmit
GATE Exam Corner
Important Topics For GATE Exam
Standard GATE Textbooks
Gate Vidyalay © 2020Managed by MetaDiv Systems

More Related Content

What's hot

2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functionssmiller5
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
Linear functions
Linear functionsLinear functions
Linear functionshalcr1ja
 
ICSE class X maths booklet with model paper 2015
ICSE class X  maths booklet with model paper 2015ICSE class X  maths booklet with model paper 2015
ICSE class X maths booklet with model paper 2015APEX INSTITUTE
 
Geo 3.6&7 slope
Geo 3.6&7 slopeGeo 3.6&7 slope
Geo 3.6&7 slopeejfischer
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...
Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...
Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...Soumen Santra
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
Hermite cubic spline curve
Hermite cubic spline curveHermite cubic spline curve
Hermite cubic spline curveDeepak Antil
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsThirunavukarasu Mani
 
Linear functions
Linear functionsLinear functions
Linear functionsrugunia
 
Time series analysis 101
Time series analysis 101Time series analysis 101
Time series analysis 101Balvinder Hira
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmMahesh Kodituwakku
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.Mohd Arif
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Inverse Matrix & Determinants
Inverse Matrix & DeterminantsInverse Matrix & Determinants
Inverse Matrix & Determinantsitutor
 

What's hot (20)

2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functions
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Linear functions
Linear functionsLinear functions
Linear functions
 
ICSE class X maths booklet with model paper 2015
ICSE class X  maths booklet with model paper 2015ICSE class X  maths booklet with model paper 2015
ICSE class X maths booklet with model paper 2015
 
Geo 3.6&7 slope
Geo 3.6&7 slopeGeo 3.6&7 slope
Geo 3.6&7 slope
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...
Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...
Traveling salesman problem: Game Scheduling Problem Solution: Ant Colony Opti...
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Hermite cubic spline curve
Hermite cubic spline curveHermite cubic spline curve
Hermite cubic spline curve
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Linear functions
Linear functionsLinear functions
Linear functions
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
 
Time series analysis 101
Time series analysis 101Time series analysis 101
Time series analysis 101
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Matrix2 english
Matrix2 englishMatrix2 english
Matrix2 english
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Inverse Matrix & Determinants
Inverse Matrix & DeterminantsInverse Matrix & Determinants
Inverse Matrix & Determinants
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 

Similar to Tsp bn b

Similar to Tsp bn b (20)

travelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdftravelingsalesmanproblem-170122053648.pdf
travelingsalesmanproblem-170122053648.pdf
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Asssignment problem
Asssignment problemAsssignment problem
Asssignment problem
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Data structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithmData structure - traveling sales person and mesh algorithm
Data structure - traveling sales person and mesh algorithm
 
Simplex method - Maximisation Case
Simplex method - Maximisation CaseSimplex method - Maximisation Case
Simplex method - Maximisation Case
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Hungarian Assignment Problem
Hungarian Assignment ProblemHungarian Assignment Problem
Hungarian Assignment Problem
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
 
Simplex algorithm
Simplex algorithmSimplex algorithm
Simplex algorithm
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structures
 
2. determinantes
2. determinantes2. determinantes
2. determinantes
 
Travelling salaseman problem (1).pptx
Travelling salaseman problem (1).pptxTravelling salaseman problem (1).pptx
Travelling salaseman problem (1).pptx
 
Lec20
Lec20Lec20
Lec20
 
Roba new
Roba newRoba new
Roba new
 
Combined
CombinedCombined
Combined
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
 
Unit-2 Branch & Bound Design of Algorithms.ppt
Unit-2 Branch & Bound Design of Algorithms.pptUnit-2 Branch & Bound Design of Algorithms.ppt
Unit-2 Branch & Bound Design of Algorithms.ppt
 

Recently uploaded

Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 

Recently uploaded (20)

Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 

Tsp bn b

  • 1.  Home  GATE Subjects  B.Tech Subjects  GATE 2022  GATE CSE Books  Job Opportunities  Contact Us  Subscribe Tag: Travelling Salesman Problem Example with Solution PPT Travelling Salesman Problem | Branch & Bound Design & Analysis of Algorithms Travelling Salesman Problem- You are given-  A set of some cities  Distance between every pair of cities Travelling Salesman Problem states-  A salesman has to visit every city exactly once.  He has to come back to the city from where he starts his journey.  What is the shortest possible route that the salesman must follow to complete his tour? Example- The following graph shows a set of cities and distance between every pair of cities-
  • 2. If salesman starting city is A, then a TSP tour in the graph is- A → B → D → C → A Cost of the tour = 10 + 25 + 30 + 15 = 80 units In this article, we will discuss how to solve travelling salesman problem using branch and bound approach with example. PRACTICE PROBLEM BASED ON TRAVELLING SALESMAN PROBLEM USING BRANCH AND BOUND APPROACH- Problem- Solve Travelling Salesman Problem using Branch and Bound Algorithm in the following graph-
  • 3. Solution- Step-01: Write the initial cost matrix and reduce it- Rules  To reduce a matrix, perform the row reduction and column reduction of the matrix separately.  A row or a column is said to be reduced if it contains at least one entry ‘0’ in it.
  • 4. Row Reduction- Consider the rows of above matrix one by one. If the row already contains an entry ‘0’, then-  There is no need to reduce that row. If the row does not contains an entry ‘0’, then-  Reduce that particular row.  Select the least value element from that row.  Subtract that element from each element of that row.  This will create an entry ‘0’ in that row, thus reducing that row. Following this, we have-  Reduce the elements of row-1 by 4.  Reduce the elements of row-2 by 5.  Reduce the elements of row-3 by 6.  Reduce the elements of row-4 by 2. Performing this, we obtain the following row-reduced matrix- Column Reduction- Consider the columns of above row-reduced matrix one by one.
  • 5. If the column already contains an entry ‘0’, then-  There is no need to reduce that column. If the column does not contains an entry ‘0’, then-  Reduce that particular column.  Select the least value element from that column.  Subtract that element from each element of that column.  This will create an entry ‘0’ in that column, thus reducing that column. Following this, we have-  There is no need to reduce column-1.  There is no need to reduce column-2.  Reduce the elements of column-3 by 1.  There is no need to reduce column-4. Performing this, we obtain the following column-reduced matrix- Finally, the initial distance matrix is completely reduced. Now, we calculate the cost of node-1 by adding all the reduction elements. Cost(1) = Sum of all reduction elements = 4 + 5 + 6 + 2 + 1 = 18
  • 6. Step-02:  We consider all other vertices one by one.  We select the best vertex where we can land upon to minimize the tour cost. Choosing To Go To Vertex-B: Node-2 (Path A → B)  From the reduced matrix of step-01, M[A,B] = 0  Set row-A and column-B to ∞  Set M[B,A] = ∞ Now, resulting cost matrix is- Now,  We reduce this matrix.  Then, we find out the cost of node-02. Row Reduction-  We can not reduce row-1 as all its elements are ∞.  Reduce all the elements of row-2 by 13.  There is no need to reduce row-3.  There is no need to reduce row-4. Performing this, we obtain the following row-reduced matrix-
  • 7. Column Reduction-  Reduce the elements of column-1 by 5.  We can not reduce column-2 as all its elements are ∞.  There is no need to reduce column-3.  There is no need to reduce column-4. Performing this, we obtain the following column-reduced matrix- Finally, the matrix is completely reduced. Now, we calculate the cost of node-2. Cost(2)
  • 8. = Cost(1) + Sum of reduction elements + M[A,B] = 18 + (13 + 5) + 0 = 36 Choosing To Go To Vertex-C: Node-3 (Path A → C)  From the reduced matrix of step-01, M[A,C] = 7  Set row-A and column-C to ∞  Set M[C,A] = ∞ Now, resulting cost matrix is- Now,  We reduce this matrix.  Then, we find out the cost of node-03. Row Reduction-  We can not reduce row-1 as all its elements are ∞.  There is no need to reduce row-2.  There is no need to reduce row-3.  There is no need to reduce row-4. Thus, the matrix is already row-reduced.
  • 9. Column Reduction-  There is no need to reduce column-1.  There is no need to reduce column-2.  We can not reduce column-3 as all its elements are ∞.  There is no need to reduce column-4. Thus, the matrix is already column reduced. Finally, the matrix is completely reduced. Now, we calculate the cost of node-3. Cost(3) = Cost(1) + Sum of reduction elements + M[A,C] = 18 + 0 + 7 = 25 Choosing To Go To Vertex-D: Node-4 (Path A → D)  From the reduced matrix of step-01, M[A,D] = 3  Set row-A and column-D to ∞  Set M[D,A] = ∞ Now, resulting cost matrix is-
  • 10. Now,  We reduce this matrix.  Then, we find out the cost of node-04. Row Reduction-  We can not reduce row-1 as all its elements are ∞.  There is no need to reduce row-2.  Reduce all the elements of row-3 by 5.  There is no need to reduce row-4. Performing this, we obtain the following row-reduced matrix- Column Reduction-  There is no need to reduce column-1.  There is no need to reduce column-2.  There is no need to reduce column-3.  We can not reduce column-4 as all its elements are ∞. Thus, the matrix is already column-reduced. Finally, the matrix is completely reduced. Now, we calculate the cost of node-4. Cost(4)
  • 11. = Cost(1) + Sum of reduction elements + M[A,D] = 18 + 5 + 3 = 26 Thus, we have-  Cost(2) = 36 (for Path A → B)  Cost(3) = 25 (for Path A → C)  Cost(4) = 26 (for Path A → D) We choose the node with the lowest cost. Since cost for node-3 is lowest, so we prefer to visit node-3. Thus, we choose node-3 i.e. path A → C. Step-03: We explore the vertices B and D from node-3. We now start from the cost matrix at node-3 which is- Cost(3) = 25 Choosing To Go To Vertex-B: Node-5 (Path A → C → B)  From the reduced matrix of step-02, M[C,B] = ∞
  • 12.  Set row-C and column-B to ∞  Set M[B,A] = ∞ Now, resulting cost matrix is- Now,  We reduce this matrix.  Then, we find out the cost of node-5. Row Reduction-  We can not reduce row-1 as all its elements are ∞.  Reduce all the elements of row-2 by 13.  We can not reduce row-3 as all its elements are ∞.  Reduce all the elements of row-4 by 8. Performing this, we obtain the following row-reduced matrix-
  • 13. Column Reduction-  There is no need to reduce column-1.  We can not reduce column-2 as all its elements are ∞.  We can not reduce column-3 as all its elements are ∞.  There is no need to reduce column-4. Thus, the matrix is already column reduced. Finally, the matrix is completely reduced. Now, we calculate the cost of node-5. Cost(5) = cost(3) + Sum of reduction elements + M[C,B] = 25 + (13 + 8) + ∞ = ∞ Choosing To Go To Vertex-D: Node-6 (Path A → C → D)  From the reduced matrix of step-02, M[C,D] = ∞  Set row-C and column-D to ∞  Set M[D,A] = ∞ Now, resulting cost matrix is-
  • 14. Now,  We reduce this matrix.  Then, we find out the cost of node-6. Row Reduction-  We can not reduce row-1 as all its elements are ∞.  There is no need to reduce row-2.  We can not reduce row-3 as all its elements are ∞.  We can not reduce row-4 as all its elements are ∞. Thus, the matrix is already row reduced. Column Reduction-  There is no need to reduce column-1.  We can not reduce column-2 as all its elements are ∞.  We can not reduce column-3 as all its elements are ∞.  We can not reduce column-4 as all its elements are ∞. Thus, the matrix is already column reduced. Finally, the matrix is completely reduced. Now, we calculate the cost of node-6. Cost(6)
  • 15. = cost(3) + Sum of reduction elements + M[C,D] = 25 + 0 + 0 = 25 Thus, we have-  Cost(5) = ∞ (for Path A → C → B)  Cost(6) = 25 (for Path A → C → D) We choose the node with the lowest cost. Since cost for node-6 is lowest, so we prefer to visit node-6. Thus, we choose node-6 i.e. path C → D. Step-04: We explore vertex B from node-6. We start with the cost matrix at node-6 which is- Cost(6) = 25 Choosing To Go To Vertex-B: Node-7 (Path A → C → D → B)  From the reduced matrix of step-03, M[D,B] = 0  Set row-D and column-B to ∞
  • 16.  Set M[B,A] = ∞ Now, resulting cost matrix is- Now,  We reduce this matrix.  Then, we find out the cost of node-7. Row Reduction-  We can not reduce row-1 as all its elements are ∞.  We can not reduce row-2 as all its elements are ∞.  We can not reduce row-3 as all its elements are ∞.  We can not reduce row-4 as all its elements are ∞. Column Reduction-  We can not reduce column-1 as all its elements are ∞.  We can not reduce column-2 as all its elements are ∞.  We can not reduce column-3 as all its elements are ∞.  We can not reduce column-4 as all its elements are ∞. Thus, the matrix is already column reduced. Finally, the matrix is completely reduced. All the entries have become ∞.
  • 17. Now, we calculate the cost of node-7. Cost(7) = cost(6) + Sum of reduction elements + M[D,B] = 25 + 0 + 0 = 25 Thus,  Optimal path is: A → C → D → B → A  Cost of Optimal path = 25 units To gain better understanding about Travelling Salesman Problem, Watch this Video Lecture Get more notes and other study material of Design and Analysis of Algorithms. Watch video lectures by visiting our YouTube channel LearnVidFun. Follow us on Facebook Choose your Subject GATE Subjects Database Management System Computer Networks Operating System
  • 18. Computer Organization & Architecture Data Structures Theory of Automata & Computation Compiler Design Graph Theory Design & Analysis of Algorithms Digital Design Number System Discrete Mathematics B.Tech Subjects Computer Graphics Machine Learning Artificial Intelligence Pattern Recognition Software Engineering Job Opportunities Subscribe to get Email Notifications First Name Last Name Email AddressSubmit GATE Exam Corner Important Topics For GATE Exam Standard GATE Textbooks Gate Vidyalay © 2020Managed by MetaDiv Systems