AB-JAVA2-Assignment3C.pdf

ASSIGNMENT 3C

Assignment 3C tests your knowledge of unweighted graphs (Chapters 28). You can and should start with the examples from the textbook/presentation and adapt them to the assignment at hand and use the appropriate names and add the additional code and requirements bellow.

Design a program/project/driver class YourNameAssignment3C and the following classes (with exact1 names for classes and methods, replace YourName with your actual first name or the name you go by):

Class Description YourNameGraph Program the complete version of the user-defined Graph from Chapter 28. Use the Edge class to

store the edge of the graph. YourNameUnweightedGraph Program the complete version of the user-defined UnweightedGraph from Chapter 28 with inner

class SearchTree and use the YourNameGraph instead of the Graph. Add the following 3 new methods: ▪ YourNamePrintGraph: a method that print the graph in this format: the number of vertices,

the list of vertices, and for each vertex all the connected vertices via an edge(values not numbers), e.g. “Vertex Dallas: El Paso”, “Vertex Houston: Austin, Buffalo”, etc.

▪ YourNamePrintDepthFirst: a method that traverses the graph in depth-first order starting from a node/vertex v given as a parameter and print the vertices.

▪ YourNamePrintBreathFirst: a method that traverses the graph in breadth-first order and print the search tree.

YourNameAssignment3C driver class main method

▪ Read the data from the Assignment3CData.txt attached file (containing on each line distances between 2 cities in format “City1 City2 Distance” separated by tab) and store the City1 and City2 data into an array of strings called YourNameVertices (do not duplicate vertices), and the City1-City2 and City2-City1 pairs into and 2D array of integers called YourNameEdges. For example, for “Dallas El Paso 633”, add “Dallas” and “El Paso” to YourNameVertices (let’s say Dallas is vertex 0 and El Paso is vertex 5), and {0,5} and {5,0} to YourNameEdges.

▪ Create an instance of YourNameUnweightedGraph using the YourNameVertices and YourNameEdges arrays and demonstrate ALL methods especially the 3 new ones.

Create a Microsoft Word screenshots document called YourNameAssignment3C-Screenshot.docx (replace YourName with your actual name) that contains screenshots of the entire JAVA source code in the editor window for all the classes and the entire output in the window (with the output from the attached Assignment3CData.txt file). If the entire class JAVA source code or the output does not fit in one screenshot, create multiple screenshots and add them to the document. Submit YourNameAssignment3C.java, YourNameGraph.java, Edge.java, and YourNameUnweightedGraph.java, Java source code files and YourNameAssignment3C-Screenshots.docx screenshots document on eCampus under Assignment 3C. Do not archive the files (no ZIP, no RAR, etc) or submit other file formats. You are not going to earn any credit if the files are not named as requested.

1 Use the exact names (spelling, caps), parameters, returned values, functionality. Yes, you may find examples in the textbook with different names and cases and with other methods, but you will need to adapt them to have this exact names and cases, to earn credit for the assignment.