Class NaryTreeTraverser<T>

java.lang.Object
repast.simphony.engine.graph.NaryTreeTraverser<T>
All Implemented Interfaces:
Traverser<T>

public class NaryTreeTraverser<T> extends Object implements Traverser<T>
A simple traverser for NaryTrees.
Author:
Jerry Vos
  • Field Details

    • tree

      protected NaryTree<T> tree
    • simpleDistance

      protected boolean simpleDistance
  • Constructor Details

    • NaryTreeTraverser

      public NaryTreeTraverser()
    • NaryTreeTraverser

      public NaryTreeTraverser(NaryTree<T> tree, boolean simpleDistance)
      Constructs this Traverser, traversing the given tree.
      Parameters:
      tree - the tree to traverse
      simpleDistance - when enabled this cancels the distance calculation and always makes it return 1
    • NaryTreeTraverser

      public NaryTreeTraverser(NaryTree<T> tree)
      Constructs this Traverser, traversing the given tree. This sets simpleDistance to tree, so it is the same as NaryTreeTravserer(tree, true).
      Parameters:
      tree - the tree to traverse
  • Method Details

    • getSuccessors

      public Iterator<T> getSuccessors(T previousNode, T currentNode)
      Returns the currentNode's children.
      Specified by:
      getSuccessors in interface Traverser<T>
      Parameters:
      previousNode - ignored
      currentNode - the node whose children to return
      Returns:
      the children
      See Also:
    • 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 interface Traverser<T>
      Parameters:
      fromNode - assumed to be the parent
      toNode - assumed to be the child
      Returns:
      1 or Double.POSITIVE_INFINITY