|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnick.graph.util.DepthFirstSearch<E>
E
- The type for this class would typically be numerical (Integer or
Double). In some applications it might be some other class, but it
is important that those classes override both the hashCode() and
equals() methods.public class DepthFirstSearch<E>
A utility class designed to do a depth first search (DFS) on a given graph.
Constructor Summary | |
---|---|
DepthFirstSearch(GraphInterface<E> the_graph)
Construct the DFS object. |
Method Summary | |
---|---|
void |
dfs()
Perform a depth first search. |
void |
dfs(java.lang.String start)
Perform a depth first search from a given vertex in an iterative fashion. |
void |
dfs(java.lang.String start,
java.lang.String dest)
Perform a depth first search from a given vertex to a given vertex in an iterative fashion. |
boolean |
hasGraphBeenSearched()
|
boolean |
isGraphConnected()
This method compares the number of vertices on a graph with the number of vertices visited by the DFS. |
boolean |
pathExists(java.lang.String start,
java.lang.String dest)
This method finds out if two vertices are part of the same connected component. |
java.lang.String |
toString()
|
java.util.HashMap<java.lang.String,java.lang.Integer> |
visitedVertices()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DepthFirstSearch(GraphInterface<E> the_graph)
the_graph
- A GraphInterface object to run the DFS on.Method Detail |
---|
public void dfs(java.lang.String start, java.lang.String dest)
start
- The starting point of the DFS.dest
- The ending point of the DFS.public void dfs(java.lang.String start)
start
- The dfs will proceed from here until all vertices are found.public void dfs()
public java.util.HashMap<java.lang.String,java.lang.Integer> visitedVertices()
public boolean isGraphConnected()
public boolean hasGraphBeenSearched()
public boolean pathExists(java.lang.String start, java.lang.String dest)
start
- The starting vertex.dest
- The destination vertex.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |