Please fix the below code or write another code, the output of the code is incorrect. All the inforamtions are below inculde the input txt file and the expected output. PLEASE IF YOU COULD NOT GET THE CORRECT OUTPUT DO NOT AWNSER MY QUESTION.
In this homework, you must implement your own graph data structure by taking inspiration from your textbook and use it to help to solve problem. You are not allowed to use any external library or .jar file. Any solutions without using graph data structure are not evaluated! Q1(50 points): Imagine you established a new electricity distribution company. For each 10km, you should use one electricity pole and you should use the minimum number of poles that will provide electricity to cities you are responsible for. For this reason, you need to create a kind of map. The input.txt file given to you contains the name and coordinates ( x and y, respectively) of the city. Example input.txt is as follows: You should read input.txt file, and construct your graph based on this information. For example, the first line means that City A is on coordinate x=2 and y=2, or the second line means that City B is on coordinate x=3,y=5. You can assume that there is always a path between any two cities and you should use Euclidian distance to calculate length of this path. For example, there is a path from cities D to E and E to D. Their lengths are equal to: (10)2+(23)2=2 Example visualization of cities and paths are as follow for input.txt: Your goal is to find paths to provide electricity to all cities and require the use of the least number of poles. While printing, you should print the path in ascending order of their length. Also, your path starts with city which comes from alphabetically first. Here is example input and output: inport Java. 10. FileReader; inport java.io. IoException: ctass citty t string tares date xn,y; thir onate = nant; this x=x it \}. ? clags done t City start, end: def fie distance; patise fidel (cty start, caty end) 4 thicistart a starts thichend = end; \}. 1. ?. seanher, etose(t): reasinput(filePath); readinput(filepath); calcelateshortestpathof b. printpaths(1): dible y=n. ? 1. e.printstackirace(i): t Problems Console x Q Javadoc D. Dectaration Terminal E. Coverage inter the input file name: input_q1.txt path from A to B path from A to C path from A to D path from A to E path from B to C path from B to D path from B to E path from C to D path from C to E path from D to E aths are: priwate spatic yaif calcuinceseortestpatha() i List cities = Arraylistoloraph,ksyset (1): hity source = cittles.get(i): t. Dijkstrashertestpation(source, destination): ? ) distancelop.put(cource, 0.0 ) priorityqueue. adalsoarcel: While (IpriorityQueue.IsEnpty(i) 1 currentcity = priorityoueve, pollid: if tcurrentoistance m eniu 1 ? centinue: for (cee edoe : groph.get(currentcity)) \& ets neightor odge, end; dolste newistance = currentbistance + edpe.distance: distencelbp. put (ne ighor, ne-0istance): istencebs. put (ne ighbor, newolstance): \}. predectissormap:pat(neightor): \}. ) printPath(source, destinatien, distanechap.get(destination)); If (oistance = Anili) 1 ? returi: Gif currentcity = destination; While (currentclty te soures) path. insertte, currentcity, nane + i-2-1) \}. currentcity = predecessorhap.get(current(city); Syater.out.print in(patha tostring()): graph. forlach(tsource, edges) edges. fortechledge \} . nter the input file name: input_q1.txt path from A to B path from A to C path from A to D path from A to E path from B to C path from B to D path from B to E path from C to D path from C to E path from D to E aths are