com.tensegrity.graph.algorithm
Class BFS

java.lang.Object
  extended bycom.tensegrity.graph.algorithm.BFS

public class BFS
extends java.lang.Object

This class implements the Breadth-First-Search algorithm with a cost of

O(|V| + |E|).
The algorithm can be customized by implementing a specialized BFSVisitor.

Version:
$Id: BFS.java,v 1.10 2005/11/18 16:06:23 KevinCVS Exp $
Author:
Stepan Rutz

Constructor Summary
BFS()
          Constructs an empty BFS search context.
 
Method Summary
 void apply(Graph graph, BFSVisitor visitor)
          This starts a visit with the node at index 0 as the rootnode.
 void apply(Graph graph, BFSVisitor visitor, boolean allcomponents)
          This starts a visit with the node at index 0 as the rootnode.
 void apply(Graph graph, BFSVisitor visitor, Node startnode)
          This starts a visit with the node startnode as the rootnode.
 void apply(Graph graph, BFSVisitor visitor, Node startnode, boolean allcomponents)
          This starts a visit with the node startnode as the rootnode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BFS

public BFS()
Constructs an empty BFS search context.

Method Detail

apply

public void apply(Graph graph,
                  BFSVisitor visitor)
           throws GraphException
This starts a visit with the node at index 0 as the rootnode. All components of the graph are visited by default.

Parameters:
graph - the graph to visit.
visitor - a bfs visitor instance to handle the callbacks that occur during the visiting.
Throws:
GraphException - thrown if the operation failed.

apply

public void apply(Graph graph,
                  BFSVisitor visitor,
                  Node startnode)
           throws GraphException
This starts a visit with the node startnode as the rootnode. If allcomponents is false, unvisited unconnected components are excluded from the search All components of the graph are visited by default.

Parameters:
graph - the graph to visit.
visitor - a bfs visitor instance to handle the callbacks that occur during the visiting.
startnode - a node that specifies the staring point for the BFS.
Throws:
GraphException - thrown if the operation failed.

apply

public void apply(Graph graph,
                  BFSVisitor visitor,
                  boolean allcomponents)
           throws GraphException
This starts a visit with the node at index 0 as the rootnode. If allcomponents is false, unvisited unconnected components are excluded from the search

Parameters:
graph - the graph to visit.
visitor - a bfs visitor instance to handle the callbacks that occur during the visiting.
allcomponents - a flag that determines whether to visit all components of the graph consecutively.
Throws:
GraphException - thrown if the operation failed.

apply

public void apply(Graph graph,
                  BFSVisitor visitor,
                  Node startnode,
                  boolean allcomponents)
           throws GraphException
This starts a visit with the node startnode as the rootnode. If allcomponents is false, unvisited unconnected components are excluded from the search

Parameters:
graph - the graph to visit.
visitor - a bfs visitor instance to handle the callbacks that occur during the visiting.
startnode - a node that specifies the staring point for the BFS.
allcomponents - a flag that determines whether to visit all components of the graph consecutively.
Throws:
GraphException - thrown if the operation failed.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.