public class DFS<V,E,I,R>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Graph<V,E> |
graph |
protected I |
info |
protected Vertex<V> |
start |
protected static java.lang.Object |
STATUS |
protected static java.lang.Object |
UNVISITED |
protected static java.lang.Object |
VISITED |
protected R |
visitResult |
Constructor and Description |
---|
DFS() |
Modifier and Type | Method and Description |
---|---|
protected R |
dfsTraversal(Vertex<V> v)
Recursive template method for a generic DFS traversal.
|
R |
execute(Graph<V,E> g,
Vertex<V> s,
I in)
Execute a depth first search traversal on graph g, starting
from a start vertex s, passing in an information object (in)
|
protected R |
finalResult(R r)
Returns the final result of the DFS execute method.
|
protected void |
finishVisit(Vertex<V> v)
Called after we finish the visit for a vertex (v).
|
protected void |
initResult()
Initializes result (called first, once per vertex visited).
|
protected boolean |
isDone()
Determines whether the traversal is done early.
|
protected boolean |
isVisited(DecorablePosition<?> p)
Test if a position (vertex or edge) has been visited.
|
protected R |
result()
Returns a result of a visit (if needed).
|
protected void |
setup()
Setup method that is called prior to the DFS execution.
|
protected void |
startVisit(Vertex<V> v)
Called when we encounter a vertex (v).
|
protected void |
traverseBack(Edge<E> e,
Vertex<V> from)
Called when we traverse a back edge (e) from a vertex (from).
|
protected void |
traverseDiscovery(Edge<E> e,
Vertex<V> from)
Called when we traverse a discovery edge (e) from a vertex (from).
|
protected void |
unVisit(DecorablePosition<?> p)
Mark a position (vertex or edge) as unvisited.
|
protected void |
visit(DecorablePosition<?> p)
Mark a position (vertex or edge) as visited.
|
protected I info
protected R visitResult
protected static java.lang.Object STATUS
protected static java.lang.Object VISITED
protected static java.lang.Object UNVISITED
public R execute(Graph<V,E> g, Vertex<V> s, I in)
protected R dfsTraversal(Vertex<V> v)
protected void visit(DecorablePosition<?> p)
protected void unVisit(DecorablePosition<?> p)
protected boolean isVisited(DecorablePosition<?> p)
protected void setup()
protected void initResult()
protected void finishVisit(Vertex<V> v)
protected void traverseDiscovery(Edge<E> e, Vertex<V> from)
protected void traverseBack(Edge<E> e, Vertex<V> from)
protected boolean isDone()
protected R result()