Package dsa
Class Dijkstra
- java.lang.Object
-
- dsa.Dijkstra
-
-
Constructor Summary
Constructors Constructor Description Dijkstra(EdgeWeightedDiGraph G, int s)
Determines the shortest paths from the source vertexs
to every other vertex in the edge-weighted digraphG
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distTo(int v)
Returns the shortest distance between a designated source vertex and vertexv
, or infinity.boolean
hasPathTo(int v)
Returnstrue
if there is a path between a designated source vertex and vertexv
, andfalse
otherwise.static void
main(String[] args)
Unit tests the data type.Iterable<Integer>
pathTo(int v)
Returns a path between a designated source vertex and vertexv
, ornull
.
-
-
-
Constructor Detail
-
Dijkstra
public Dijkstra(EdgeWeightedDiGraph G, int s)
Determines the shortest paths from the source vertexs
to every other vertex in the edge-weighted digraphG
.- Parameters:
G
- the edge-weighted digraph.s
- the source vertex.
-
-
Method Detail
-
hasPathTo
public boolean hasPathTo(int v)
Description copied from interface:Paths
Returnstrue
if there is a path between a designated source vertex and vertexv
, andfalse
otherwise.
-
pathTo
public Iterable<Integer> pathTo(int v)
Description copied from interface:Paths
Returns a path between a designated source vertex and vertexv
, ornull
.
-
distTo
public double distTo(int v)
Description copied from interface:Paths
Returns the shortest distance between a designated source vertex and vertexv
, or infinity.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-