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
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
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
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
-