Docsity

CSC 3102 Programming Assignment 4: Exploring Graph Functions - Prof. B. Karki, Assignments of Computer Science

Toggle sidebar
bg1
CSC 3102 Programming Assignment 4
Exploring Graph Functions
Due: December 3, Thursday (by class time)
Points: 5
Submit your work as instructed towards the end of this document. Contact TA Di Lin by e-
mail to [email protected] or me by e-mail to [email protected] for help. Late submission is not
allowed.
Objective: To demonstrate the various functions and problems related to graphs.
Background: You have learned about various interesting functions and problems related to
graph. They include single-source shortest path, topological sorting, DFS and BFS graph
traversals, minimum spanning tree and transitive closure. The given menu-driven application
allows you to solve these graph problems. The menu interface is as follows:
BASIC WEIGHTED GRAPH APPLICATION
==================================
[1] Adjacency Matrix
[2] Transitive Matrix
[3] Single-source Shortest Path
[4] Perform DFS Traversal
[5] Perform BFS Traversal
[6] Current number of edges
[7] Topological Sort Labeling
[8] Prim’s Minimum Spanning Tree
[0] Quit
When option 1 is selected, an adjacency matrix for the graph should be displayed, where the
(i, j) entry is the weight on the i to j directed edge. When option 2 is selected the transitive
closure matrix for the weighted graph should be displayed. When option 3 is selected, the
user should be prompted for the search keys for the source and destination vertices. The
program should display the shortest path from the source to the destination, showing
intermediate cites and distances. If no such path exists, the program should indicate. Options
4 and 5 display the orders in which the graph is traversed. Option 6 allows you to calculate
the number of edges. When option 7 is selected, the program should perform a topological
sort of the graph showing the labeling generated by the sort. When option 8 is selected, it
should display the complete path between any pair of vertices in the graph if such a path
exists or display an appropriate message indication that no such path exists. If such a path
exists, the total cost of the path should be displayed.
pf2

Partial preview of the text

Download CSC 3102 Programming Assignment 4: Exploring Graph Functions - Prof. B. Karki and more Assignments Computer Science in PDF only on Docsity!

CSC 3102 Programming Assignment 4 Exploring Graph Functions Due: December 3, Thursday (by class time) Points: 5 Submit your work as instructed towards the end of this document. Contact TA Di Lin by e- mail to [email protected] or me by e-mail to [email protected] for help. Late submission is not allowed. Objective: To demonstrate the various functions and problems related to graphs. Background: You have learned about various interesting functions and problems related to graph. They include single-source shortest path, topological sorting, DFS and BFS graph traversals, minimum spanning tree and transitive closure. The given menu-driven application allows you to solve these graph problems. The menu interface is as follows: BASIC WEIGHTED GRAPH APPLICATION ================================== [1] Adjacency Matrix [2] Transitive Matrix [3] Single-source Shortest Path [4] Perform DFS Traversal [5] Perform BFS Traversal [6] Current number of edges [7] Topological Sort Labeling [8] Prim’s Minimum Spanning Tree [0] Quit When option 1 is selected, an adjacency matrix for the graph should be displayed, where the ( i , j ) entry is the weight on the i to j directed edge. When option 2 is selected the transitive closure matrix for the weighted graph should be displayed. When option 3 is selected, the user should be prompted for the search keys for the source and destination vertices. The program should display the shortest path from the source to the destination, showing intermediate cites and distances. If no such path exists, the program should indicate. Options 4 and 5 display the orders in which the graph is traversed. Option 6 allows you to calculate the number of edges. When option 7 is selected, the program should perform a topological sort of the graph showing the labeling generated by the sort. When option 8 is selected, it should display the complete path between any pair of vertices in the graph if such a path exists or display an appropriate message indication that no such path exists. If such a path exists, the total cost of the path should be displayed.

Project Task: Run the given menu-driven graph application for a given input data about cities and interlinks to answer the following questions.

  1. Find out the cities from where one cannot travel to any other city. Also find out the cities where you cannot travel (go) from any other city.
  2. Compute the shortest path from San Francisco to Dally City, and the shortest path from Oakland to Palo Alto.
  3. Perform the DFS and BFS traversals showing the results.
  4. Find the topological sort.
  5. Compute a minimum spanning tree for vertex 3 (i.e., San Francisco). If it does not exist, compute a minimum spanning forest and draw all the trees in the forest. Copy the following two required files from the server classes.csc.lsu.edu from /classes/cs3102/cs3102_kar/Karki-Fall09/prog After you login to your account, use the following command to copy the files: cp -r /classes/cs3102/cs3102_kar/Karki-Fall09/prog. graphrun – The executable file to run the application. cities.wdg - File containing weighted directed graph that you will use as input. The vertices of the graph represent 15 different cities, and the edges represent 25 links between these cities with weight for each link. Type graphrun cities.wdg at the system prompt to run the program using your account in the classes server. Submitting Your Work: Prepare a report, which should contain the answers to the above five questions along with the relevant outputs and interpretation. Submit a hard copy of your report during the class time.