org.geotools.graph.traverse.basic
Class BasicGraphTraversal

java.lang.Object
  extended byorg.geotools.graph.traverse.basic.BasicGraphTraversal
All Implemented Interfaces:
GraphTraversal
Direct Known Subclasses:
StagedGraphTraversal

public class BasicGraphTraversal
extends java.lang.Object
implements GraphTraversal

A basic implementation of GraphTraversal.

Author:
Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net

Field Summary
 
Fields inherited from interface org.geotools.graph.traverse.GraphTraversal
CONTINUE, KILL_BRANCH, STOP, SUSPEND
 
Constructor Summary
BasicGraphTraversal(Graph graph, GraphWalker walker, GraphIterator iterator)
          Constrcuts a new graph traversal.
 
Method Summary
 Graph getGraph()
          Returns the graph being traversed.
 GraphIterator getIterator()
          Returns the iterator that specifies the order in which to visit graph components.
 GraphWalker getWalker()
          Returns the walker (visitor) traversing the graph of the graph.
 void init()
          Resets the visited flag and counts of all nodes of the graph.
 boolean isVisited(Graphable g)
           
 void setGraph(Graph graph)
          Sets the graph being traversed.
 void setIterator(GraphIterator iterator)
          Sets the iterator and intializes it.
 void setVisited(Graphable g, boolean visited)
           
 void setWalker(GraphWalker walker)
          Sets the walker (visitor) traversing the graph.
 void traverse()
          Upon each iteration of the traversal, a component is returned from the iterator and passed to the visitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicGraphTraversal

public BasicGraphTraversal(Graph graph,
                           GraphWalker walker,
                           GraphIterator iterator)
Constrcuts a new graph traversal.

Parameters:
graph - The graph being traversed.
walker - The walker being traversed over the components of the graph.
iterator - The iterator specifying the order in which to visit components of the graph.
Method Detail

setGraph

public void setGraph(Graph graph)
Description copied from interface: GraphTraversal
Sets the graph being traversed.

Specified by:
setGraph in interface GraphTraversal
Parameters:
graph - The graph whose components are being traversed.
See Also:
GraphTraversal.setGraph(Graph)

getGraph

public Graph getGraph()
Description copied from interface: GraphTraversal
Returns the graph being traversed.

Specified by:
getGraph in interface GraphTraversal
Returns:
The graph whose components are being traversed.
See Also:
GraphTraversal.getGraph()

setIterator

public void setIterator(GraphIterator iterator)
Sets the iterator and intializes it.

Specified by:
setIterator in interface GraphTraversal
Parameters:
iterator - The iterator over the graph components.
See Also:
GraphIterator#init(Graph), GraphTraversal.setIterator(GraphIterator)

getIterator

public GraphIterator getIterator()
Description copied from interface: GraphTraversal
Returns the iterator that specifies the order in which to visit graph components.

Specified by:
getIterator in interface GraphTraversal
Returns:
The iterator over the graph components.
See Also:
GraphTraversal.getIterator()

setWalker

public void setWalker(GraphWalker walker)
Description copied from interface: GraphTraversal
Sets the walker (visitor) traversing the graph.

Specified by:
setWalker in interface GraphTraversal
Parameters:
walker - The walker being iterated over the components of the graph.
See Also:
GraphTraversal.setWalker(GraphWalker)

getWalker

public GraphWalker getWalker()
Description copied from interface: GraphTraversal
Returns the walker (visitor) traversing the graph of the graph.

Specified by:
getWalker in interface GraphTraversal
Returns:
The walker being iterated over the components.
See Also:
GraphTraversal.getWalker()

init

public void init()
Resets the visited flag and counts of all nodes of the graph.

Specified by:
init in interface GraphTraversal
See Also:
GraphTraversal.init()

traverse

public void traverse()
Upon each iteration of the traversal, a component is returned from the iterator and passed to the visitor. The traversal interprets the return codes from the walker and performs the following actions.

Code Action Performed
CONTINUE The traversal instructs the iterator to continue and starts the next stage of iteration.
SUSPEND The traversal instructs the iterator to continue but does not start the next stage of iteration, returning from traverse().
KILL_BRANCH The traversal instructs the iterator to kill the current branch and starts the next stage of iteration.
STOP The traversal does not instruct the iterator to continue and does not start the next of iteration, returning from traverse()

Specified by:
traverse in interface GraphTraversal
See Also:
GraphTraversal.traverse()

setVisited

public void setVisited(Graphable g,
                       boolean visited)
Specified by:
setVisited in interface GraphTraversal

isVisited

public boolean isVisited(Graphable g)
Specified by:
isVisited in interface GraphTraversal


Copyright © GeoTools. All Rights Reserved.