Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago