Package repast.simphony.engine.graph
Class NaryTreeTraverser<T>
java.lang.Object
repast.simphony.engine.graph.NaryTreeTraverser<T>
- All Implemented Interfaces:
Traverser<T>
A simple traverser for
NaryTrees.- Author:
- Jerry Vos
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNaryTreeTraverser(NaryTree<T> tree) Constructs thisTraverser, traversing the given tree.NaryTreeTraverser(NaryTree<T> tree, boolean simpleDistance) Constructs thisTraverser, traversing the given tree. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetDistance(T fromNode, T toNode) Returns 1 if the toNode is a child of the fromNode, otherwise Double.POSITIVE_INFINITY.getSuccessors(T previousNode, T currentNode) Returns the currentNode's children.
-
Field Details
-
tree
-
simpleDistance
protected boolean simpleDistance
-
-
Constructor Details
-
NaryTreeTraverser
public NaryTreeTraverser() -
NaryTreeTraverser
Constructs thisTraverser, traversing the given tree.- Parameters:
tree- the tree to traversesimpleDistance- when enabled this cancels the distance calculation and always makes it return 1
-
NaryTreeTraverser
Constructs thisTraverser, traversing the given tree. This sets simpleDistance to tree, so it is the same asNaryTreeTravserer(tree, true).- Parameters:
tree- the tree to traverse
-
-
Method Details
-
getSuccessors
Returns the currentNode's children.- Specified by:
getSuccessorsin interfaceTraverser<T>- Parameters:
previousNode- ignoredcurrentNode- the node whose children to return- Returns:
- the children
- See Also:
-
getDistance
Returns 1 if the toNode is a child of the fromNode, otherwise Double.POSITIVE_INFINITY. If simpleDistance is turned on, this will always return 1.- Specified by:
getDistancein interfaceTraverser<T>- Parameters:
fromNode- assumed to be the parenttoNode- assumed to be the child- Returns:
- 1 or Double.POSITIVE_INFINITY
-