Please fix the code below, the output is wrong. All the informations, input and expected output are sahred below. 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: Inoort fova. 10.Files Theort jawa.util:*; String tilenase = input5canner, nextlineti; Jining startcity = getilghaboticallyfiratcitylgraph, keysethi: Mapsstring, bow shortestoistances = dikkstra(graph, sturtcity): \}. printshortesthothsi(shertestbistances, starticity): f Shortestoistarkes, entryset(i).streait) - sorted(Coeparator. ceaparimin(map. Entry: :getvalue)) ifiter(entry tentry.getkeyl). equalsistarticity) foreachlentry i String endeity = entry dowin distance = entry-getvatue(1); y): \} 1. Mapestria, Mapesty Mapestring, deSleti> coordinateekap = nex HashMapoli): Stanner scanner = ites Scanner(ow fite(filensme)): Ville (scanner,hasvextline(i) 4 strigl line - scamer. nextitine(): r. if (parts. tength i double y1= coordinates (1); coordinateskp. fortach (lothercity, otherCoordinates) f If (lothercity.oquats(city)) \& toule x2= othercoordinates y2= otherCoordinates 1 if: thouble distance = atculatesistance (x1,y1,x2,y2) : graph, get(city), put (othercity, distance) ) H: H): r return sortedGresh; rabalems Console Javadoe Pnefaration Terminal coverate er the filename: input. txt 2.23606797749979 :3.0 in t (o) (Stin' city i groph, keyset (i) 1 b. distances,put(startcity, a.e): Setestring? visited = nite Hashiseto(): Te (Ipq.isEnpty (1) 1 in (visitedicontoistance = currententry.getvatue(): 1. (visited.contains(currentcity)) \& visited.add(currenteity); dowhin neighbordistance - neighbortintry.getVolue(): ofic newistance = currentelstance + neighboroistance; If (distances.get (neighbercity) > newolstance) : distances. put (neighborcity, newoistance): t. + ? 1 1 Probiems Consale dayador Declaratian Torminal Coverage Enter the filename: input. txt A=E:2.23606797749979 A-D: 3.0 AB:3.1622776601683795 AC:4.242640687119285