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NWG 2/5 CPF[GNNQY 2/5 'OQT[7PKXGTUKV[YQTFOCTMU ECPDGTGRTQFWEGFKP'OQT[DNWG 2/5 DNCEMQTYJKVGQPCP'OQT[DNWGQTFCTMDCEMITQWPF YYYKFGPVKV[GOQT[GFW JVVRYGDIWKFGGOQT[GFW Dijkstra's Algorithm 6 public Integer[] getShortestPath(Graph graph, int source, int target) { PriorityQueue<VertexDistancePair> queue = new PriorityQueue<>(); Integer[] previous = new Integer[graph.size()]; double[] distances = new double[graph.size()]; Set<Integer> visited = new HashSet<>(); init(distances, previous, target); queue.add(new VertexDistancePair(target, distances[target])); while (!queue.isEmpty()) { // To be filled. } return previous; }