Package dsa.lab11.exercises
Class DepthFirstSearcher
java.lang.Object
dsa.lab11.exercises.DepthFirstSearcher
Depth-first search (DFS).
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <Vertex,Weight> 
 DepthFirstSearchResult<Vertex> fullSearch(DirectedGraph<Vertex, Weight> graph) Perform full depth-first search, starting from every vertex in the graph.static <Vertex,Weight> 
 DepthFirstSearchResult<Vertex> search(DirectedGraph<Vertex, Weight> graph, Vertex source) Perform depth-first search from the given source vertex.
- 
Constructor Details- 
DepthFirstSearcherpublic DepthFirstSearcher()
 
- 
- 
Method Details- 
searchpublic static <Vertex,Weight> DepthFirstSearchResult<Vertex> search(DirectedGraph<Vertex, Weight> graph, Vertex source) Perform depth-first search from the given source vertex.Returns both the paths found to all reachable vertices and the order in which they were fully visited. - Type Parameters:
- Vertex- the vertex type
- Weight- the weight type
- Parameters:
- graph- the graph
- source- the source vertex
- Returns:
- the result of the search
 
- 
fullSearchpublic static <Vertex,Weight> DepthFirstSearchResult<Vertex> fullSearch(DirectedGraph<Vertex, Weight> graph) Perform full depth-first search, starting from every vertex in the graph.Essentially runs single-source DFS from each source in turn, re-using the same paths map and visited list (to not re-visit already-visited vertices). - Type Parameters:
- Vertex- the vertex type
- Weight- the weight type
- Parameters:
- graph- the graph
- Returns:
- the result of the search
 
 
-