please fix my code or write another code to solve the question. The output is wroge as i sahred it in the first image. All informations are shared below as well as the input.txt content. The correct expected output is in the last image. PLEASE IF YO COULD NOT GET THE EXACT CORRECT OUTPUT DO NOT AWNSER MY QUESTION' I DO NOT HAVE ANOTHER QUESTION POSTING ABILITY.
Enter the filename: input.txt Paths are: A-B: 3.1622776601683795 A-C: 4.242640687119285 A-D: 3.0 A-E: 2.23606797749979 A,2,2B,3,5C,5,5D,1,2E,3,0 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: import java.io.File; import java.io.FileNotFoundException; import jawa.util.; public class ShortestPaths \{ public static void main(String[] args) throws FileNotFoundException \{ Scanner inputScanner = new Scanner ( System.in); System.out.print("Enter the filename: "); String filename = inputScanner.nextLine(): Map> graph = readinput(filename); String startCity = getAlphabeticallyFirstCity (graph.keySet()); Map shortestDistances = dijkstra(graph, startCity): printShortestPaths(shortestDistances, startCity): ? private static String getAlphabeticallyFirstCity(Set cities) ( return cities.stream().min(Comparator.naturalOrder(0).orElse(null); \} private static void printShortestPaths(Map shortestDistances, String startCity) \& System.out.printin("Paths are:"); shortestDistances.entrySet().stream() sorted(Comparator.comparing(Map.Entry::getKey)) filter(entry lentry.getKey().equals(startCity)) forEach(entry 1 String endCity = entry.getKey(): double distance = entry.getvalue(); System.out.printin(startCity +"4+ endCity +"+4 + distance): Wi 1 private static Map> readinput(String filename) throws FileNotFoundException \{ Map graph = new HashMap0; Map coordinatesMap = new HashMap0; Scanner scanner = new Scanner(new File(filename)); while (scanner.hasNextLine()) ( String line = scanner.nextLine(): if (line.startsWith("//") || line.isBlank(0) \} continue; \} String[ parts = line.split(","); if (parts.length = parts [0]; double x= Double . parseDouble { parts [1]}; double y= Double , parseDouble ( parts [2]); coordinatesMap.put(city, new double [](x,y}); graph.put(city, new HashMap 0 ): // Calculate distances after storing coordinates coordinatesMap.forEach((city, coordinates) 1 double 1= coordinates [0]; double y1= coordinates[1]; coordinatesMap.forEach((otherCity, otherCoordinates) ( if (lotherCity.equals(city)) \& double 2= otherCoordinates [0]; double y2 = otherCoordinates [1]; double distance = calculateDistance (x1,y1,x2,y2); graph.get(city). put(otherCity, distance); graph,computelfAbsent(otherCity, k new HashMap > ()).put(city, distance); // Assuming an undirected graph l Hi Hi return graph; static double calculateDistance(double 1, double y1, double 2, double y2 ) ( return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); \} private static Mapdjkstra(Map> graph, String startCity) f Map> distances = new HashMap (0) for (String city : graph.keySet()) ( distances.put(city, Double.POSITIVE_INFINITY); ) distances.put(startCity, 0.0): SeteString> visited = new HashSet >0; PriorityQueue pq= new PriorityQueue(Comparator.comparing(Map.Entry:getValue)); pq.offer(new AbstractMap.SimpleEntry ( startCity, 0.0)); while (tpq-isEmpty()) ( Map.Entry> currentEntry = pq.poll(): String currentCity = currentEntry.getKey (): double currentDistance = currentEntry.getValue(); if (visited.contains(currentCity)) 1 continue; ) visited.add(currentCity); for (Map.Entry neighborEntry : graph.get(currentCity).entrySet(0) ( String neighborCity = neighborEntry.getKey0: double neighborDistance = neighborEntry.getValue(0; double newDistance = currentDistance + neighborDistance; if (distances.get(neighborCity) > newDistance) \{ distances.put(neighborCity, newDistance): pq.offer(new AbstractMap.SimpleEntry(neighborCity, newDistance)); ) \} t return distances; \} \}