javaslam.tjt.graph
Class DepthFirstTraversal

java.lang.Object
  |
  +--javaslam.tjt.graph.Traversal
        |
        +--javaslam.tjt.graph.DepthFirstTraversal

public class DepthFirstTraversal
extends Traversal

An iterator that traverses the nodes of a graph in depth-first (children before siblings) order.


Field Summary
protected  LinkedList queue
          A queue of nodes to be visited in this search.
 
Fields inherited from class javaslam.tjt.graph.Traversal
current, cycle, edges
 
Constructor Summary
DepthFirstTraversal(Node n)
          Constructor.
 
Method Summary
protected  Node dequeue()
          Dequeues a node to visit.
protected  void enqueue(Node n)
          Enqueues a node for later visit.
 boolean hasNext()
          Returns true if the iteration has more elements.
 
Methods inherited from class javaslam.tjt.graph.Traversal
current, edge, isCyclic, next, path, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected LinkedList queue
A queue of nodes to be visited in this search.

Constructor Detail

DepthFirstTraversal

public DepthFirstTraversal(Node n)
Constructor.

Parameters:
n - the node from which to start the traversal; this will be the first node returned by the iterator
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in class Traversal

enqueue

protected void enqueue(Node n)
Enqueues a node for later visit.

Specified by:
enqueue in class Traversal

dequeue

protected Node dequeue()
Dequeues a node to visit.

Specified by:
dequeue in class Traversal