Question: You are expected to implement the following task using C/C++ Java. Teamwork is not allowed. In this task you will be creating a graph from


You are expected to implement the following task using C/C++ Java. Teamwork is not allowed. In this task you will be creating a graph from an input data files called: 1. adjacent_cities.txt 2. CityDistances.txt You will see a file called adjacent cities.tst which contains list of neighboring eities in each line. Each line having a list of cities where the first city shares a border with the rest of the cities in the list. Concider the followine man First-line in " adjacent_cities.txt" contains Adana,Hatay,Osmaniye,Kahramanmaras,Kayseri,Nigde,Icel From that line, you are expected to extract neighboring relations of Adana. Next line contains the connection relation of Adiyaman, the last line has neighboring relations of Duzce. From adjacent_cities.tst text file extraction of the city(vertex) and its connections(edges) to neighboring cities will be done. In effect, you will be creating an undirected graph that represents See the following figure. Then there is second text file called CityDistances.txt. This text file has the distance information(weights of edges) between cities. The format of the text file is as follows: First line is the heading having plate number, city name, and list of cities from Adana to duzce. Primarily this file is in the form of a matrix where you can find distances between cities. In this task, you will extract distances between neighboring cities that you have extracted using adjacent cities,txt text file. By extracting distances you can create an undirected graph that represents cities and weighted edges. (see figure below) After creating the graph present the user with the following menu items a. Enter city(or select) b. Print selected(or entered) city c. List k closest cities (to selected city) d. Find shortest path to x. exit The explanation of the menu a) Enter city: will take a plate id or name of the city and remember it as the current city b) Show current city: will print the currently selected city. c) Find the k elosest cities from the current city, if the current has not been set. enabie the user to select eity, k is a number provided by the user, then your program must output k cities closest to the selected city. d) Find the shortest path: will take a plate id or name of the city, and calculate print all shortest hops from the current city to the destination city, finding the shortest path. b) Show current city: will print the currently selected city, c) Find the k closest cities from the current city, if the current has not been set. enable the user to select city, k is a number provided by the user, then your program must output k cities closest to the selected city, d) Find the shortest path: will take a plate id or name of the city, and calculate print all shortest hops from the current city to the destination city, finding the shortest path. You are expected to implement this problem independently (don't share your code). You can use library functions/classes such as queue, heap, stack, or list. Grading: 50% will be given to the implementation of running code. 50% will be given to face-to-face presentation (at my office) Graph (Structure of Class) public: Graph(int V) create a V-1ertex graph with no edges Graph(ln in) read a graph from input stream in if necessary adjacent(x,y) : tests whether there is an edge from the vertex x to the vertex y; neighbors (x) : lists/vector or array of all vertices y such that there is an edge from the vertex x to the vertex y; add_vertex (x); adds the vertex x, if it is not there; remove vertex (x) : removes the vertex x, if it is there; add edge (x,y) : adds the edge from the vertex x to the vertex y, if it is not there; remove_edge (x,y); removes the edge from the vertex x to the vertex y, if it is there; get_vertex_value (x) : returns the value associated with the vertex x; set_vertex_value (x,v) : sets the value associated with the vertex x to v. int VO number of vertices int EO number of edges String toString() string representation get_edge_value (x,y) : returns the value associated with the edge (x,y); set edge value (x,y,v) : sets the value associated with the edge (x,y) to v. private int V; // number of vertices int E;// number of edges String []labesONodes; adj; // choice of adjacency lists (linked list, matrix or hash table or whatever you consider more suitable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
