Farrukh Jabeen
Algorithms 510
Assignment #6
Due Date: July 13, 2009.
Assignment # 6
Week 6: Assignment 6
Due Date: July 13, 2009.
Chapter 35 Approximation Algorithms
Deliverables:
1. Define the Euclidean Traveling Salesman Problem.
2. Explain the Minimum Spanning Tree approach to solving the TSP.
3. Explain the 2-opt approach to the TSP (not in text -- research).
4. Analyze the run time of MST and 2-opt.
5. Implement both the MST and 2-opt approaches to the TSP in a software simulation.
a) randomly located cities in a unit square.
b) number of cities: 10 and 100.
c) compare result of MST and 2-opt.
d) graphic display of results (extra credit).
1. Define the Euclidean Traveling Salesman Problem.
The Travelling Salesman problem (TSP) is a problem in combinatorial optimization studied in operations
research and theoretical computer science. Given a list of cities and their pairwise distances, the task is
to find a shortest possible tour that visits each city exactly once.
TSP can be modelled as a graph: the graph’s vertices correspond to cities and the graph’s edges
correspond to connections between cities, the length of an edge is the corresponding connection’s
distance. A TSP tour is now a Hamiltonian cycle in the graph, and an optimal TSP tour is a shortest
Hamiltonian cycle
.
Symmetric TSP with four cities.
2. Explain the Minimum Spanning Tree approach to solving the TSP.
First we have to understand of MST(Minimum Spanning Tree).
Given a connected, undirected graph, a spanning tree of that graph is a subgraph which is a tree and
connects all the vertices together. A single graph can have many different spanning trees. We can also
assign a weight to each edge, which is a number representing how unfavorable it is, and use this to
assign a weight to a spanning tree by computing the sum of the weights of the edges in that spanning
tree. A minimum spanning tree (MST) or minimum weight spanning tree is then a spanning tree with
weight less than or equal to the weight of every other spanning tree. More generally, any undirected
graph (not necessarily connected) has a minimum spanning forest, which is a union of minimum
spanning trees for its connected components.
One example would be a cable TV company laying cable to a new neighborhood. If it is constrained to
bury the cable only along certain paths, then there would be a graph representing which points are
connected by those paths. Some of those paths might be more expensive, because they are longer, or
require the cable to be buried deeper; these paths would be represented by edges with larger weights.
A spanning tree for that graph would be a subset of those paths that has no cycles but still connects to
every house. There might be several spanning trees possible. A minimum spanning tree would be one
with the lowest total cost.
This means :
Spanning tree: a free tree on V (thus having |V|-1 edges that are a subset of|E|).
Minimum Spanning tree: the spanning tree with minimal total weight, where the weights of the edges
picked are summed to obtain a total weight..
Euclidean MST's (EMST's) are utilized in the event of the need to find an MST of a number of nodes in
Euclidean space, where each node is actually a vector. It can be conceived as a graph with all possible
edges existing, and the distance between two nodes is defined as:
dist (u,v) = || u - v ||
Example of the travelling salesman problem and its run time
This is a well-known problem. The object is to find the shortest route that a travelling salesman has to
take to tour a number of towns.
The salesman starts in a given town, knows all the distances between towns (This is an EMST), and is to
tour all the towns, and end up in the same place in which he started.
To find the best possible route we will use the EMST, but the problem is so complex that we will have to
use an approximation algorithm to find the solution. The solution to the TSP take at least exponential
time in |v|.
An approximate solution with a near-optimal solution may be obtained at small complexity. The more
accurate the solution needed, the greater the complexity.
The following diagrams illustrate the algorithm for solving the TSP, where the edge lengths measure the
distance in the plane, and the nodes represent points in the plane.
Initial graph with points (cities) only.
Step 1
Find MST ( time = (|E|log|V|) for an ordinary heap)
(Time = (|V|²) for an unsorted list)
Step 2
Depth-First Search (DFS) => Connections only to new cities
The cities are numbered in the order that they are to be visited.
" DFS-order tour" ( time = (|V|))
Step 3
Connect the nodes in the DFS tour, and close the tour. (Time = (|V|)
The length of this approximate tour is guaranteed to be less than, or equal to, 2* the length of the
optimal TSP.
Explain the 2-opt approach to the TSP (not in text -- research).With run time analysis
2-opt is the most basic and widely used local search heuristic for TSP. This heuristic achieves amazingly
good results on “real world” Euclidean instances both with respect to running time and approximation
ratio.
2-opt algorithm starts with an arbitrary initial tour and incrementally improves this tour by exchanging
two of the edges in the tour with two other edges. In each improving step the 2-opt algorithm selects
two edges{u1,u2} and {v1,v2} from the tour such that ui,u2,v1,v2 are distinct and appear in this order in
the tour and the algorithm replaces these edges by the edges{u1,v1} and {u2,v2}, provided this change
decreases the length of tour. The algorithm terminates in local optimum in which no further improving
step is possible. We use the term 2-change to denote a local improvement made by 2-Opt. Usually the
2-Opt hureistic needs a clearly subquadritic number of improving steps until it reaches a local
optimum and the computed solution lies within a few percentage points of the global optimum.
When talking about the number of local improvements , it is convenient to consider the state graph. The
vertices in this graph correspond to the possible tours and an arc from a vertex u to a vertex v is
contained if v is obtained from u by performing one improvement 2-Opt step. On the positive side ,
consider a 2-Opt variant for the Euclidean plane in which only steps are allowed that remove a
crossing from the tour. Observe that such steps can introduce new crossings. After O(n 3 ) steps , 2-Opt
has found a tour without any crossings.
On the negative side consider TSP instances whose state graph contains exponentially long paths , that
is 2-Opt can take an exponential number of steps before it finds a locally optimal solution. This result is
generalized to k-Opt for arbitrary K is greater than or equal to 2.
5. Implement both the MST and 2-opt approaches to the TSP in a software
simulation. a) randomly located cities in a unit square. b) number of cities: 10 and
100. c) compare result of MST and 2-opt. d) graphic display of results (extra credit).
Please see java files on my web page in the folder “ProjectTSP.zip”.Here is the implementation of both
MST and 2-opt approaches to the TSP.
For the MST, I used Prim Algorithm which is given in the book.
Case 1: Cities positions are “Random” and selected method is MST for TSP
Case 2: Cities positions are “Circle” and selected method is MST for TSP
This is the 2-opt method for TSP
Case 1: Cities positions are “Random” and selected method is 2-Opt for TSP
Case 2: Cities positions are “Circle” and selected method is 2-Opt for TSP
References:
http://en.wikipedia.org/wiki/Minimum_spanning_tree
http://en.wikipedia.org/wiki/Travelling_salesman_problem
http://www.cs.mcgill.ca/~cs251/OldCourses/1997/topic28/
http://books.google.com/books?id=EbBWmmPcjPIC&pg=PA1295&lpg=PA1295&dq=run+time+for+tsp+2
-opt&source=bl&ots=_xFFnUEdXu&sig=ydU_RO593HRTJX6_6JbfWdvY18&hl=en&ei=LNpDSryuNYb0sgPMs53oDQ&sa=X&oi=book_result&ct=result&re
snum=2
Text Book
© Copyright 2026 Paperzz