Package com.jgalgo.graph
Interface EdgeIter<V,E>
-
- Type Parameters:
V
- the vertices typeE
- 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 bysource()
andtarget()
.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:
EdgeSet
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description E
peekNext()
Peek at the next edge of the iterator without advancing it.V
source()
Get the source vertex of the last returned edge.V
target()
Get the target vertex of the last returned edge.-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
-
-
-
Method Detail
-
peekNext
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
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
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
-
-