Docsity

Graphs in COMP385: Data Structures II HW11 at Wentworth Tech, Assignments of Data Structures and Algorithms

Toggle sidebar
bg1
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP385 Section 71 - Data Structures II - Fall, 2007
Homework 11 โ€“ Using Graphs
Instructor: Bob Goldstein (617) 912-2512
http://home.comcast.net/~goldsteinr/Courses/index.html
http://goldstein.eri.harvard.edu/courses/index.html
http://myweb.wit.edu/goldsteinr/Courses/index.html
Due Date: December 4, 2007
Hand In: Printout of program code and dialogue of how it runs.
Purpose:
Get experience using Graph Operations.
This homework is based on problem 10, page 759 of Ford and Topp.
Description:
Start with the datafile graphB.dat that is in the ch24ex directory of the software supplement to Ford and Topp.
Read in the datafile using the DiGraph.readGraph() method. Once the graph is loaded, programmatically
perform the following operations, and print the graph after each operation using toString():
1. Insert an edge from F to D with weight 1.
2. Delete vertex F
3. Erase the edge (A,D).
4. Prompt the user to input a vertex, and list all of the neighbors of the vertex
5. Insert a new vertex, G.
6. Add the following edges with weight 8: (G,C), (G,E), (D,G)
7. Prompt the user to input a vertex, and print the neighbors of the vertex. Make sure you test this with vertex E.
Extra Credit:
Find a program on the internet that can graphically draw a graph datastructure. Implement this into your
program and in the above problem, instead of printing the graph with toString(), draw the graph after each
operation.
If you cannot find such a program on the internet, modify the drawTree program of Ford and Topp so that it
draws graphs instead of trees. To simplify the placement, assume there is no more than 10 vertices in the
graph.
/app/work/qkda6j-469457-2765065-homework11-doc.doc 1 12/6/2020 12/6/2020

Partial preview of the text

Download Graphs in COMP385: Data Structures II HW11 at Wentworth Tech and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP385 Section 71 - Data Structures II - Fall, 2007

Homework 11 โ€“ Using Graphs

Instructor: Bob Goldstein (617) 912- [email protected] [email protected] http://home.comcast.net/~goldsteinr/Courses/index.html http://goldstein.eri.harvard.edu/courses/index.html http://myweb.wit.edu/goldsteinr/Courses/index.html Due Date: December 4, 2007 Hand In: Printout of program code and dialogue of how it runs. Purpose: Get experience using Graph Operations. This homework is based on problem 10, page 759 of Ford and Topp. Description: Start with the datafile graphB.dat that is in the ch24ex directory of the software supplement to Ford and Topp. Read in the datafile using the DiGraph.readGraph() method. Once the graph is loaded, programmatically perform the following operations, and print the graph after each operation using toString():

  1. Insert an edge from F to D with weight 1.
  2. Delete vertex F
  3. Erase the edge (A,D).
  4. Prompt the user to input a vertex, and list all of the neighbors of the vertex
  5. Insert a new vertex, G.
  6. Add the following edges with weight 8: (G,C), (G,E), (D,G)
  7. Prompt the user to input a vertex, and print the neighbors of the vertex. Make sure you test this with vertex E. Extra Credit: Find a program on the internet that can graphically draw a graph datastructure. Implement this into your program and in the above problem, instead of printing the graph with toString(), draw the graph after each operation. If you cannot find such a program on the internet, modify the drawTree program of Ford and Topp so that it draws graphs instead of trees. To simplify the placement, assume there is no more than 10 vertices in the graph. /app/work/qkda6j-469457-2765065-homework11-doc.doc 1 12/6/2020 12/6/