Package repast.simphony.engine.graph
Class NaryTreeTraverser<T>
- java.lang.Object
-
- repast.simphony.engine.graph.NaryTreeTraverser<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
simpleDistance
protected NaryTree<T>
tree
-
Constructor Summary
Constructors Constructor Description NaryTreeTraverser()
NaryTreeTraverser(NaryTree<T> tree)
Constructs thisTraverser
, traversing the given tree.NaryTreeTraverser(NaryTree<T> tree, boolean simpleDistance)
Constructs thisTraverser
, traversing the given tree.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getDistance(T fromNode, T toNode)
Returns 1 if the toNode is a child of the fromNode, otherwise Double.POSITIVE_INFINITY.Iterator<T>
getSuccessors(T previousNode, T currentNode)
Returns the currentNode's children.
-
-
-
Constructor Detail
-
NaryTreeTraverser
public NaryTreeTraverser()
-
NaryTreeTraverser
public NaryTreeTraverser(NaryTree<T> tree, boolean simpleDistance)
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
-
-
Method Detail
-
getSuccessors
public Iterator<T> getSuccessors(T previousNode, T currentNode)
Returns the currentNode's children.- Specified by:
getSuccessors
in interfaceTraverser<T>
- Parameters:
previousNode
- ignoredcurrentNode
- the node whose children to return- Returns:
- the children
- See Also:
GraphParams
-
getDistance
public double getDistance(T fromNode, T toNode)
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:
getDistance
in interfaceTraverser<T>
- Parameters:
fromNode
- assumed to be the parenttoNode
- assumed to be the child- Returns:
- 1 or Double.POSITIVE_INFINITY
-
-