salvo.jesus.graph.algorithm
Class BreadthFirstTraversal

java.lang.Object
  extended by salvo.jesus.graph.algorithm.GraphTraversal
      extended by salvo.jesus.graph.algorithm.BreadthFirstTraversal
All Implemented Interfaces:
java.io.Serializable

public class BreadthFirstTraversal
extends GraphTraversal

A concrete subclass of GraphTraversal that uses breadth-first search in traversing a graph. Note that the traverse() method will only traverse the connected set to which the Vertex the traversal will start at belongs.

Author:
Jesus M. Salvo Jr.
See Also:
Serialized Form

Field Summary
(package private)  Queue queue
           
 
Fields inherited from class salvo.jesus.graph.algorithm.GraphTraversal
graph, OK, TERMINATEDBYVISITOR
 
Constructor Summary
BreadthFirstTraversal(Graph graph)
          Creates a BreadthFirstTraversal object
 
Method Summary
 java.util.Vector traverse(Vertex startat)
          Abstract traversal method to be implemented by subclasses.
 int traverse(Vertex startat, java.util.Vector visited, Visitor visitor)
          Abstract traversal method to be implemented by subclasses.
 java.util.Vector traverse(Vertex startat, Visitor visitor)
          Abstract traversal method to be implemented by subclasses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

Queue queue
Constructor Detail

BreadthFirstTraversal

public BreadthFirstTraversal(Graph graph)
Creates a BreadthFirstTraversal object

Method Detail

traverse

public int traverse(Vertex startat,
                    java.util.Vector visited,
                    Visitor visitor)
Description copied from class: GraphTraversal
Abstract traversal method to be implemented by subclasses.

Specified by:
traverse in class GraphTraversal
Parameters:
startat - The vertex from which traversal will start.
visited - A Vector of vertices that has been visited in sequence by the traversal
visitor - Visitor object controlling if and when traversal will stop, apart from having visited all the vertices.

traverse

public java.util.Vector traverse(Vertex startat,
                                 Visitor visitor)
Description copied from class: GraphTraversal
Abstract traversal method to be implemented by subclasses.

Specified by:
traverse in class GraphTraversal
Parameters:
startat - The vertex from which traversal will start.
visitor - Visitor object controlling if and when traversal will stop, apart from having visited all the vertices.
Returns:
A Vector of vertices that has been visited in sequence by the traversal

traverse

public java.util.Vector traverse(Vertex startat)
Description copied from class: GraphTraversal
Abstract traversal method to be implemented by subclasses.

Specified by:
traverse in class GraphTraversal
Parameters:
startat - The vertex from which traversal will start.
Returns:
A Vector of vertices that has been visited in sequence by the traversal