Package dsa
Class DFSPaths
- java.lang.Object
-
- dsa.DFSPaths
-
-
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
-
DFSPaths
public DFSPaths(Graph G, int s)
Computes paths between source vertexs
and every other vertex in the graphG
.- Parameters:
G
- the graph.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.
-
-