Class BasicGraphTraversal
Object
BasicGraphTraversal
- All Implemented Interfaces:
GraphTraversal
- Direct Known Subclasses:
StagedGraphTraversal
A basic implementation of GraphTraversal.
- Author:
- Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
-
Field Summary
Fields inherited from interface GraphTraversal
CONTINUE, KILL_BRANCH, STOP, SUSPEND -
Constructor Summary
ConstructorsConstructorDescriptionBasicGraphTraversal(Graph graph, GraphWalker walker, GraphIterator iterator) Constructs a new graph traversal. -
Method Summary
Modifier and TypeMethodDescriptiongetGraph()Returns the graph being traversed.Returns the iterator that specifies the order in which to visit graph components.Returns the walker (visitor) traversing the graph of the graph.voidinit()Resets the visited flag and counts of all nodes of the graph.booleanvoidSets the graph being traversed.voidsetIterator(GraphIterator iterator) Sets the iterator and intializes it.voidsetVisited(Graphable g, boolean visited) voidsetWalker(GraphWalker walker) Sets the walker (visitor) traversing the graph.voidtraverse()Upon each iteration of the traversal, a component is returned from the iterator and passed to the visitor.
-
Constructor Details
-
BasicGraphTraversal
Constructs 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 Details
-
setGraph
Description copied from interface:GraphTraversalSets the graph being traversed.- Specified by:
setGraphin interfaceGraphTraversal- Parameters:
graph- The graph whose components are being traversed.- See Also:
-
getGraph
Description copied from interface:GraphTraversalReturns the graph being traversed.- Specified by:
getGraphin interfaceGraphTraversal- Returns:
- The graph whose components are being traversed.
- See Also:
-
setIterator
Sets the iterator and intializes it.- Specified by:
setIteratorin interfaceGraphTraversal- Parameters:
iterator- The iterator over the graph components.- See Also:
-
GraphIterator#init(Graph)GraphTraversal.setIterator(GraphIterator)
-
getIterator
Description copied from interface:GraphTraversalReturns the iterator that specifies the order in which to visit graph components.- Specified by:
getIteratorin interfaceGraphTraversal- Returns:
- The iterator over the graph components.
- See Also:
-
setWalker
Description copied from interface:GraphTraversalSets the walker (visitor) traversing the graph.- Specified by:
setWalkerin interfaceGraphTraversal- Parameters:
walker- The walker being iterated over the components of the graph.- See Also:
-
getWalker
Description copied from interface:GraphTraversalReturns the walker (visitor) traversing the graph of the graph.- Specified by:
getWalkerin interfaceGraphTraversal- Returns:
- The walker being iterated over the components.
- See Also:
-
init
public void init()Resets the visited flag and counts of all nodes of the graph.- Specified by:
initin interfaceGraphTraversal- See Also:
-
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:
traversein interfaceGraphTraversal- See Also:
-
setVisited
- Specified by:
setVisitedin interfaceGraphTraversal
-
isVisited
- Specified by:
isVisitedin interfaceGraphTraversal
-