fix this code to give the exact result of
Output (on screen)
Weight Matrix:
 0 1 2 3 4
0 0 0 0 7 0
1 3 0 4 0 0
2 0 0 0 0 6
3 0 2 5 0 0
4 0 0 0 4 0
# of vertices is: 5, # of edges is: 7
 0: 0-3 7
 1: 1-0 3 1-2 4
 2: 2-4 6
 3: 3-1 2 3-2 5
 4: 4-3 4
Enter Source vertex: 4
Dijkstra using priority queue:
Shortest paths from vertex 4 are:
A path from 4 to 0: 4 3 1 0 (Length: 9.0)
A path from 4 to 1: 4 3 1 (Length: 6.0)
A path from 4 to 2: 4 3 2 (Length: 9.0)
A path from 4 to 3: 4 3 (Length: 4.0)
A path from 4 to 4: 4 (Length: 0.0)
Dijkstra using min heap:
Shortest paths from vertex 4 are:
A path from 4 to 0: 4 3 1 0 (Length: 9.0)
A path from 4 to 1: 4 3 1 (Length: 6.0)
A path from 4 to 2: 4 3 2 (Length: 9.0)
A path from 4 to 3: 4 3 (Length: 4.0)
A path from 4 to 4: 4 (Length: 0.0)
Comparison Of the running time :
 Running time of Dijkstra using priority queue is: 3599939 nano seconds
 Running time of Dijkstra using min Heap is: 1195418 nano seconds
 Running time of Dijkstra using min Heap is better
when the unput is
(First line denotes the number of vertices, second line denotes number of edges, and every other
line denotes source vertex, target vertex and weight of edge respectively)
5
7
0 3 7
1 0 3
1 2 4
2 4 6
3 1 2
3 2 5
4 3 4
code
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;

public class Dijkstra {

    private static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) throws FileNotFoundException {
        File inputFile = new File("input2.txt");
        Scanner scanner = new Scanner(inputFile);

        int vertices = scanner.nextInt();
        int edges = scanner.nextInt();

        int[][] weightMatrix = new int[vertices][vertices];
        for (int i = 0; i < vertices; i++) {
            Arrays.fill(weightMatrix[i], INF);
            weightMatrix[i][i] = 0;
        }

        for (int i = 0; i < edges; i++) {
            int src = scanner.nextInt();
            int dest = scanner.nextInt();
            int weight = scanner.nextInt();
            weightMatrix[src][dest] = weight;
        }

        scanner.close();

        System.out.println("Weight Matrix:");
        for (int i = 0; i < vertices; i++) {
            System.out.print(i + " ");
            for (int j = 0; j < vertices; j++) {
                System.out.print(weightMatrix[i][j] != INF ? weightMatrix[i][j] : 0);
                System.out.print(" ");
            }
            System.out.println();
        }

        System.out.println("Enter Source vertex: ");
        Scanner userInput = new Scanner(System.in);
        int source = userInput.nextInt();

        long start = System.nanoTime();
        List<List<Integer>> priorityQueueResult = dijkstraPriorityQueue(weightMatrix, source);
        long end = System.nanoTime();
        long priorityQueueTime = end - start;

        start = System.nanoTime();
        List<List<Integer>> minHeapResult = dijkstraMinHeap(weightMatrix, source);
        end = System.nanoTime();
        long minHeapTime = end - start;

        System.out.println("Dijkstra using priority queue:");
        printPaths(source, priorityQueueResult);
        System.out.println("Dijkstra using min heap:");
        printPaths(source, minHeapResult);

        System.out.println("Comparison of the running time:");
        System.out.println("Running time of Dijkstra using priority queue is: " + priorityQueueTime + " nano seconds");
        System.out.println("Running time of Dijkstra using min Heap is: " + minHeapTime + " nano seconds");
        System.out.println("Running time of Dijkstra using min Heap is better");
    }

    private static List<List<Integer>> dijkstraPriorityQueue(int[][] weightMatrix, int source) {
        int vertices = weightMatrix.length;
        int[] distances = new int[vertices];
        Arrays.fill(distances, INF);
        distances[source] = 0;

        List<List<Integer>> paths = new ArrayList<>();
        for (int i = 0; i < vertices; i++) {
            paths.add(new ArrayList<>());
        }

        PriorityQueue<int[]> pq = new PriorityQueue<>(Comparator.comparingInt(a -> a[1]));
        pq.add(new int[]{source, 0});

        while (!pq.isEmpty()) {
            int[] current = pq.poll();
            int vertex = current[0];
            int distance = current[1];

            if (distance > distances[vertex]) {
                continue;
            }

            for (int neighbor = 0; neighbor < vertices; neighbor++) {
                if (weightMatrix[vertex][neighbor] != INF) {
                    int newDistance = distance + weightMatrix[vertex][neighbor];
                    if (newDistance < distances[neighbor]) {
                        distances[neighbor] = newDistance;
                        pq.add(new int[]{neighbor, newDistance});

                        paths.get(neighbor).clear();
                        paths.get(neighbor).addAll(paths.get(vertex));
                        paths.get(neighbor).add(vertex);
                    }
                }
            }
        }

        return paths;
    }

    private static List<List<Integer>> dijkstraMinHeap(int[][] weightMatrix, int source) {
        int vertices = weightMatrix.length;
        int[] distances = new int[vertices];
        Arrays.fill(distances, INF);
        distances[source] = 0;

        List<List<Integer>> paths = new ArrayList<>();
        for (int i = 0; i < vertices; i++) {
            paths.add(new ArrayList<>());
        }

        PriorityQueue<int[]> pq = new PriorityQueue<>(Comparator.comparingInt(a -> a[1]));
        pq.add(new int[]{source, 0});

        boolean[] visited = new boolean[vertices];

        while (!pq.isEmpty()) {
            int[] current = pq.poll();
            int vertex = current[0];
            int distance = current[1];

            if (visited[vertex]) {
                continue;
            }
            visited[vertex] = true;

            for (int neighbor = 0; neighbor < vertices; neighbor++) {
                if (weightMatrix[vertex][neighbor] != INF) {
                    int newDistance = distance + weightMatrix[vertex][neighbor];
                    if (newDistance < distances[neighbor]) {
                        distances[neighbor] = newDistance;
                        pq.add(new int[]{neighbor, newDistance});

                        paths.get(neighbor).clear();
                        paths.get(neighbor).addAll(paths.get(vertex));
                        paths.get(neighbor).add(vertex);
                    }
                }
            }
        }

        return paths;
    }

    private static void printPaths(int source, List<List<Integer>> paths) {
        for (int destination = 0; destination < paths.size(); destination++) {
            List<Integer> path = paths.get(destination);
            path.add(destination);

            System.out.print("A path from " + source + " to " + destination + ": ");
            for (int i = 0; i < path.size(); i++) {
                System.out.print(path.get(i));
                if (i < path.size() - 1) {
                    System.out.print(" ");
                }
            }
            System.out.println(" (Length: " + path.size() + ".0)");
        }
    }
}