|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnick.graph.util.BreadthFirstSearch<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 BreadthFirstSearch<E>
A utility class designed to do a breadth first search (BFS) on a given graph.
Constructor Summary | |
---|---|
BreadthFirstSearch(GraphInterface<E> the_graph)
Construct the BFS object. |
Method Summary | |
---|---|
void |
bfs()
Perform a depth first search. |
void |
bfs(java.lang.String start)
Perform a depth first search from a given vertex in an iterative fashion. |
void |
bfs(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 BFS. |
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 BreadthFirstSearch(GraphInterface<E> the_graph)
the_graph
- A GraphInterface object to run the BFS on.Method Detail |
---|
public void bfs(java.lang.String start, java.lang.String dest)
start
- The starting point of the BFS.dest
- The ending point of the BFS.public void bfs(java.lang.String start)
start
- The BFS will proceed from here until all vertices are found.public void bfs()
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 |