Interface EdgeIter<V,E>

Type Parameters:
V - the vertices type
E - the edges type
All Superinterfaces:
Iterator<E>
All Known Subinterfaces:
IEdgeIter

public interface EdgeIter<V,E> extends Iterator<E>
Iterator used to iterate over graph edges.

Each value returned by Iterator.next() is an edge iterated by the iterator. The source and target of the last iterated edge are available by source() and target().

 
 Graph<String, Integer> g = ...;
 String vertex = ...;
 for (EdgeIter<String, Integer> eit = g.outEdges(vertex).iterator(); eit.hasNext();) {
 	Integer e = eit.next();
 	String u = eit.source();
 	String v = eit.target();
 	assert vertex.equals(u);
 	System.out.println("Out edge of " + vertex + ": " + e + "(" + u + ", " + v + ")");
 }
 
Author:
Barak Ugav
See Also:
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    Peek at the next edge of the iterator without advancing it.
    Get the source vertex of the last returned edge.
    Get the target vertex of the last returned edge.

    Methods inherited from interface java.util.Iterator Link icon

    forEachRemaining, hasNext, next, remove
  • Method Details Link icon

    • peekNext Link icon

      E peekNext()
      Peek at the next edge of the iterator without advancing it.

      Similar to Iterator.next() but without advancing the iterator.

      Returns:
      the next edge of the iterator
      Throws:
      NoSuchElementException - if there is no 'next' element
    • source Link icon

      V source()
      Get the source vertex of the last returned edge.

      The behavior is undefined if Iterator.next() was not called yet.

      Returns:
      the source vertex of the last returned edge
    • target Link icon

      V target()
      Get the target vertex of the last returned edge.

      The behavior is undefined if Iterator.next() was not called yet.

      Returns:
      the target vertex of the last returned edge