|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.mhhe.clrs2e.DFS
Class that performs a depth-first search on a graph. Based on DFS code on page 541 of Introduction to Algorithms, Second edition.
| Field Summary | |
protected com.mhhe.clrs2e.DFSInfo[] |
dfsInfo
Array of DFSInfo objects, one per vertex, to hold
the result of the depth-first search. |
protected int |
time
The global timestamp. |
| Constructor Summary | |
DFS()
|
|
| Method Summary | |
protected void |
dfsVisit(com.mhhe.clrs2e.AdjacencyListGraph g,
com.mhhe.clrs2e.Vertex u)
Performs a depth-first search on a graph starting from a given vertex, filling in discovery times, finish times, and parents in the predecessor graph in the dfsInfo array. |
protected void |
discover(com.mhhe.clrs2e.AdjacencyListGraph g,
com.mhhe.clrs2e.Vertex u)
Performs an action upon discovering a vertex in a graph. |
protected void |
finish(com.mhhe.clrs2e.AdjacencyListGraph g,
com.mhhe.clrs2e.Vertex u)
Performs an action upon finishing a vertex in a graph. |
com.mhhe.clrs2e.DFSInfo |
getDFSInfo(int v)
Returns a reference to the DFSInfo object for a
given vertex. |
com.mhhe.clrs2e.DFSInfo |
getDFSInfo(com.mhhe.clrs2e.Vertex v)
Returns a reference to the DFSInfo object for a
given vertex. |
void |
search(com.mhhe.clrs2e.AdjacencyListGraph g)
Performs a depth-first search on a graph from a given source vertex, filling in discovery times, finish times, and parents in the predecessor graph in the dfsInfo array. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int time
protected com.mhhe.clrs2e.DFSInfo[] dfsInfo
DFSInfo objects, one per vertex, to hold
the result of the depth-first search.
| Constructor Detail |
public DFS()
| Method Detail |
public void search(com.mhhe.clrs2e.AdjacencyListGraph g)
dfsInfo array.
g - The graph.
protected void dfsVisit(com.mhhe.clrs2e.AdjacencyListGraph g,
com.mhhe.clrs2e.Vertex u)
dfsInfo array.
g - The graph.u - The vertex being searched from.public com.mhhe.clrs2e.DFSInfo getDFSInfo(com.mhhe.clrs2e.Vertex v)
DFSInfo object for a
given vertex.
v - The vertex for which the corresponding
DFSInfo is returned.public com.mhhe.clrs2e.DFSInfo getDFSInfo(int v)
DFSInfo object for a
given vertex.
v - The index of the vertex for which the corresponding
DFSInfo is returned.
protected void discover(com.mhhe.clrs2e.AdjacencyListGraph g,
com.mhhe.clrs2e.Vertex u)
g - The graph.u - The vertex just discovered.
protected void finish(com.mhhe.clrs2e.AdjacencyListGraph g,
com.mhhe.clrs2e.Vertex u)
g - The graph.u - The vertex just finished.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||