Docsity

Lab 8 CS2402 Spring 2009: Weighted Graphs and Travelling Salesman Problem - Prof. Olac Fue, Lab Reports of Data Structures and Algorithms

Toggle sidebar
bg1
1
CS2402
Spring 2009
Lab 8
Weighted Graphs
Due Friday, April 30, 2009
Instructions
Part I
Write the following methods related to graphs:
a) A method to read a weighted undirected graph from a file (see example in appendix) and
store it using adjacency list and adjacency matrix representations.
b) Minimum spanning tree
c) Single source shortest paths using Dijkstra’s algorithm
Part II
The Travelling Salesman Problem (TSP) consists of, given a list of cities and their pair wise
distances, finding a shortest possible tour that visits each city exactly once. TSP can be modeled
as a graph: the graph’s vertices correspond to cities, the graph’s edges correspond to connections
between cities, and the weight of an edge is the corresponding connection’s distance.
Write a method to solve TSP using backtracking and a stack
Appendix
Example graph file:
Vertices
El Paso
Ruidoso
Las Cruces
Edges
(El Paso,Las Cruces,43)
(Las Cruces,Ruidoso,120)
(El Paso, Ruidoso,135)

Partial preview of the text

Download Lab 8 CS2402 Spring 2009: Weighted Graphs and Travelling Salesman Problem - Prof. Olac Fue and more Lab Reports Data Structures and Algorithms in PDF only on Docsity!

CS

Spring 2009

Lab 8

Weighted Graphs

Due Friday, April 30, 2009

Instructions

Part I

Write the following methods related to graphs: a) A method to read a weighted undirected graph from a file (see example in appendix) and store it using adjacency list and adjacency matrix representations. b) Minimum spanning tree c) Single source shortest paths using Dijkstra’s algorithm

Part II

The Travelling Salesman Problem (TSP) consists of, given a list of cities and their pair wise distances, finding a shortest possible tour that visits each city exactly once. TSP can be modeled as a graph: the graph’s vertices correspond to cities, the graph’s edges correspond to connections between cities, and the weight of an edge is the corresponding connection’s distance. Write a method to solve TSP using backtracking and a stack

Appendix

Example graph file:

Vertices El Paso Ruidoso Las Cruces Edges (El Paso,Las Cruces,43) (Las Cruces,Ruidoso,120) (El Paso, Ruidoso,135)