prefuse.data.util
Class BreadthFirstIterator

java.lang.Object
  extended by prefuse.data.util.BreadthFirstIterator
All Implemented Interfaces:
java.util.Iterator

public class BreadthFirstIterator
extends java.lang.Object
implements java.util.Iterator

Provides a distance-limited breadth first traversal over nodes, edges, or both, using any number of traversal "roots".

Author:
jeffrey heer

Field Summary
protected  int m_depth
           
protected  boolean m_includeEdges
           
protected  boolean m_includeNodes
           
protected  Queue m_queue
           
protected  int m_traversal
           
 
Constructor Summary
BreadthFirstIterator()
          Create an uninitialized BreadthFirstIterator.
BreadthFirstIterator(java.util.Iterator it, int depth, int traversal)
          Create a new BreadthFirstIterator starting from the given source nodes.
BreadthFirstIterator(Node n, int depth, int traversal)
          Create a new BreadthFirstIterator starting from the given source node.
 
Method Summary
 int getDepth(Tuple t)
          Get the traversal depth at which a particular tuple was encountered.
protected  java.util.Iterator getEdges(Node n)
          Determines which edges are traversed for a given node.
 boolean hasNext()
           
 void init(java.lang.Object o, int depth, int traversal)
          Initialize (or re-initialize) this iterator.
 java.lang.Object next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_queue

protected Queue m_queue

m_depth

protected int m_depth

m_traversal

protected int m_traversal

m_includeNodes

protected boolean m_includeNodes

m_includeEdges

protected boolean m_includeEdges
Constructor Detail

BreadthFirstIterator

public BreadthFirstIterator()
Create an uninitialized BreadthFirstIterator. Use the init(Object, int, int) method to initialize the iterator.


BreadthFirstIterator

public BreadthFirstIterator(Node n,
                            int depth,
                            int traversal)
Create a new BreadthFirstIterator starting from the given source node.

Parameters:
n - the source node from which to begin the traversal
depth - the maximum graph distance to traverse
traversal - the traversal type, one of Constants.NODE_TRAVERSAL, Constants.EDGE_TRAVERSAL, or Constants.NODE_AND_EDGE_TRAVERSAL

BreadthFirstIterator

public BreadthFirstIterator(java.util.Iterator it,
                            int depth,
                            int traversal)
Create a new BreadthFirstIterator starting from the given source nodes.

Parameters:
it - an Iterator over the source nodes from which to begin the traversal
depth - the maximum graph distance to traverse
traversal - the traversal type, one of Constants.NODE_TRAVERSAL, Constants.EDGE_TRAVERSAL, or Constants.NODE_AND_EDGE_TRAVERSAL
Method Detail

init

public void init(java.lang.Object o,
                 int depth,
                 int traversal)
Initialize (or re-initialize) this iterator.

Parameters:
o - Either a source node or iterator over source nodes
depth - the maximum graph distance to traverse
traversal - the traversal type, one of Constants.NODE_TRAVERSAL, Constants.EDGE_TRAVERSAL, or Constants.NODE_AND_EDGE_TRAVERSAL

remove

public void remove()
Specified by:
remove in interface java.util.Iterator
See Also:
Iterator.remove()

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator
See Also:
Iterator.hasNext()

getEdges

protected java.util.Iterator getEdges(Node n)
Determines which edges are traversed for a given node.

Parameters:
n - a node
Returns:
an iterator over edges incident on the node

getDepth

public int getDepth(Tuple t)
Get the traversal depth at which a particular tuple was encountered.

Parameters:
t - the tuple to lookup
Returns:
the traversal depth of the tuple, or -1 if the tuple has not been visited by the traversal.

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator
See Also:
Iterator.next()


Copyright © 2007 Regents of the University of California