it.unimi.dsi.webgraph
Class NodeIterator

java.lang.Object
  extended by it.unimi.dsi.fastutil.ints.AbstractIntIterator
      extended by it.unimi.dsi.webgraph.NodeIterator
All Implemented Interfaces:
IntIterator, Iterator<Integer>
Direct Known Subclasses:
ArcLabelledNodeIterator

public abstract class NodeIterator
extends AbstractIntIterator

This interface extends IntIterator and is used to scan a graph, that is, to read its nodes and their successor lists sequentially. The AbstractIntIterator.nextInt() method returns the node that will be scanned. After a call to this method, calling successors() or successorArray() will return the list of successors.

Implementing subclasses can override either successors() or successorArray(), but at least one of them must be implemented.


Constructor Summary
NodeIterator()
           
 
Method Summary
abstract  int outdegree()
          Returns the outdegree of the current node.
 int[] successorArray()
          Returns a reference to an array containing the successors of the current node.
 LazyIntIterator successors()
          Returns a lazy iterator over the successors of the current node.
 
Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntIterator
next, nextInt, remove, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Iterator
hasNext
 

Constructor Detail

NodeIterator

public NodeIterator()
Method Detail

outdegree

public abstract int outdegree()
Returns the outdegree of the current node.

Returns:
the outdegree of the current node.

successors

public LazyIntIterator successors()
Returns a lazy iterator over the successors of the current node. The iteration terminates when -1 is returned.

This implementation just wraps the array returned by successorArray().

Returns:
a lazy iterator over the successors of the current node.

successorArray

public int[] successorArray()
Returns a reference to an array containing the successors of the current node.

The returned array may contain more entries than the outdegree of the current node. However, only those with indices from 0 (inclusive) to the outdegree of the current node (exclusive) contain valid data.

This implementation just unwrap the iterator returned by successors().

Returns:
an array whose first elements are the successors of the current node; the array must not be modified by the caller.