Question
(In Java) Write a program that allows the user to read graph information from a text file that s/he specifies. Once the file is loaded,
(In Java) Write a program that allows the user to read graph information from a text file that s/he specifies. Once the file is loaded, the user should be able to view all the vertices and edges (including weights) of the graph. Use the following classes for the project design:
Vertex class: This should include an instance variable for the vertexs name, as well as instance variables for the various quantities needed in Dijkstras algorithm (distance, visited status, and previous vertex).
Edge class: This should include instance variables for the start and end vertices, as well as the edges weight. Graph class: This should include a list of Vertex objects and a list of Edge objects as instance variables. You can use java.util.ArrayList or java.util.LinkedList for these lists. This class should also include the following methods: o A method that loads information from a data file o A method that runs Dijkstras algorithm using a specified start and end vertex o A toString method that includes information about the graphs vertices and edges MappingApp class: This is the client program where all user input will be made. It should contain an instance of Graph and allow the user to load a data file, view the currently loaded graph, or find the shortest path between two vertices in the currently loaded graph. As mentioned before, display both the optimal cost as well as the path itself.
Implement error checking on all user inputs! This includes exception handling: possible crashes due to exceptions like InputMismatchException or FileNotFoundException should be gracefully handled. Your program should never crash due to user input.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started