Class NodeIterator

java.lang.Object
it.unimi.dsi.webgraph.NodeIterator
All Implemented Interfaces:
IntIterator, java.util.Iterator<java.lang.Integer>, java.util.PrimitiveIterator<java.lang.Integer,​java.util.function.IntConsumer>, java.util.PrimitiveIterator.OfInt
Direct Known Subclasses:
ArcLabelledNodeIterator

public abstract class NodeIterator
extends java.lang.Object
implements IntIterator
This interface extends IntIterator and is used to scan a graph, that is, to read its nodes and their successor lists sequentially. The IntIterator.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.

The copy(int) methods is in fact optional, but should be implemented whenever the graph can be scanned more than once.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.PrimitiveIterator

    java.util.PrimitiveIterator.OfDouble, java.util.PrimitiveIterator.OfInt, java.util.PrimitiveIterator.OfLong
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static NodeIterator EMPTY
    An empty node iterator.
  • Constructor Summary

    Constructors 
    Constructor Description
    NodeIterator()  
  • Method Summary

    Modifier and Type Method Description
    NodeIterator copy​(int upperBound)
    Creates a copy of this iterator that will never return nodes ≥ the specified bound; the copy must be accessible by a different thread.
    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 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterator

    forEachRemaining, next, nextInt, skip

    Methods inherited from interface java.util.Iterator

    hasNext, remove

    Methods inherited from interface java.util.PrimitiveIterator.OfInt

    forEachRemaining
  • Field Details

  • Constructor Details

  • Method Details

    • 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.
    • copy

      public NodeIterator copy​(int upperBound)
      Creates a copy of this iterator that will never return nodes ≥ the specified bound; the copy must be accessible by a different thread. Optional operation (it should be implemented by all classes that allow to scan the graph more than once).

      This implementation just throws an UnsupportedOperationException. It should be kept in sync with the result of ImmutableGraph.hasCopiableIterators().

      Parameters:
      upperBound - the upper bound.
      Returns:
      a copy of this iterator, with the given upper bound.