lu.cs.co.graph
Class Vertices
java.lang.Object
|
+--lu.cs.co.graph.Vertices
- public class Vertices
- extends Object
An iterator over a set of vertices. Objects of this class generate
vertices one at a time. Successive calls to the next method return
successive vertices from the set.
The canonical way to process the vertices of a graph looks like this:
for (Vertices V= G.vertices(); V.hasNext();)
{ Vertex v= V.next();
handle(v);
}
|
Method Summary |
boolean |
hasNext()
Returns true if there are any vertices left. |
Vertex |
next()
Return the next vertex. |
hasNext
public boolean hasNext()
- Returns true if there are any vertices left. In other words,
calling next would return an edge instead of throwing an
exception.
- Returns:
- true if the iterator has more elements
next
public Vertex next()
- Return the next vertex.
- Returns:
- the next vertex
- Throws:
- NoSuchElementException - if there are no more vertices