Class CountingWalker

  • All Implemented Interfaces:
    GraphWalker

    public class CountingWalker
    extends Object
    implements GraphWalker
    An implementation of GraphWalker that counts the number of components visited. As each component is visited, the walker sets the count of the component to the value of its counter.
    Author:
    Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
    See Also:
    Graphable.setCount(int)
    • Constructor Detail

      • CountingWalker

        public CountingWalker()
    • Method Detail

      • visit

        public int visit​(Graphable element,
                         GraphTraversal traversal)
        Sets the count of the component and increments the counter.
        Specified by:
        visit in interface GraphWalker
        Parameters:
        element - The component being visited.
        traversal - The traversal controlling the sequence of graph component visits.
        Returns:
        GraphTraversal#CONTINUE to signal that the traversal should continue.
        GraphTraversal#CONTINUE to signal that the traversal should suspend.
        GraphTraversal#KILL_BRANCH to signal that the traversal should kill its current branch.
        GraphTraversal#STOP to signal that the traversal should stop.
        See Also:
        Graphable.setCount(int), GraphWalker.visit(Graphable, GraphTraversal)
      • getCount

        public int getCount()
        Returns the value of the visitation counter.
        Returns:
        int Value of the counter.