Question: Create a Java program with the following menu: Menu: 1 ) Author info 2 ) Load Graph 3 ) Traverse graph 4 ) Depth First
Create a Java program with the following menu:
Menu:
Author info
Load Graph
Traverse graph
Depth First Search
Breadth First Search
Exit
Menu Option
Print program author name and student id
Menu Option
Allow the user to enter a file name, then build and adjacency matrix from the data in the selected file. Details for the file are given below
Menu Option
Implement a traversal method that lets the user select a starting vertex.
Then inform the user of all neighbors and the cost of traveling to the neighbor, then let the user pick a neighbor to travel to For full credit but only a minor penalty if you don't have it also indicate if the link is bidirectional or unidirectional. "Travel" to the vertex and repeat the process. If the user selects vertex as a destination end the traversal. As you traverse the nodes, keep a total of the costs incurred by the chosen path and inform the user at each step.
Menu option
let the user select a starting vertex, then print the order in which nodes are marked as visited for a depth first search
Menu option
let the user select a starting vertex, then print the order in which nodes are marked as visited for a breadth first search
Menu option
Exit the program
File description:
The first row contains the number of vertices, every row after contains information about a vertex, row contains vertex s information, row contains vertex s information and so on for a vertex the first integers is the number of neighbors for that vertex, followed by the weight of an edge, then the connected vertex
NUMBEROFVERTICES
NUMBER OF NEIGHBORS NeighborWeight Neighbor NeighborWeight Neighbor
for example for the following graph
The file would be:
vertices in graph
vertex has neighbors
vertex has neighbor
vertex has neighbors
vertex has neighbor
vertex has neighbors
file;
file
file
file
file
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
