Question: JAVA package algs44; import algs13.Stack; import algs24.IndexMinPQ; import stdlib.StdOut; // Develop an API and implementation that use a version of Dijkstras algorithm // to solve

JAVA

package algs44;

import algs13.Stack; import algs24.IndexMinPQ; import stdlib.StdOut;

// Develop an API and implementation that use a version of Dijkstras algorithm // to solve the source-sink shortest path problem on edge-weighted digraphs.

public class hw5 {

public class DijkstraSPSourceSink { private DirectedEdge[] edgeTo; // last edge on path to vertex private double[] distTo; // length of path to vertex private IndexMinPQ minPQ; private int target; private int source;

// This function should compute the shortest path from the // input source s to target t on the edge-weighted directed graph public DijkstraSPSourceSink(EdgeWeightedDigraph G, int s, int t) { edgeTo = new DirectedEdge[G.V()]; distTo = new double[G.V()]; minPQ = new IndexMinPQ<>(G.V()); this.source = s; this.target = t;

// initialize distances to vertices for(int v = 0; v < G.V(); v++) { distTo[v] = Double.POSITIVE_INFINITY; }

// TODO }

private void relax(EdgeWeightedDigraph G, int v) { // TODO }

public double distToTarget() { // TODO return 0.0; }

public boolean hasPathToTarget() { // TODO return false; }

public Iterable pathToTarget() { Stack path = new Stack<>(); if ( hasPathToTarget() ) { // TODO }

return path; }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!