V
- vertex typeE
- edge typepublic class RandomWalkIterator<V,E> extends AbstractGraphIterator<V,E>
Long#MAX_VALUE
. When the bound is
reached the iterator is considered exhausted. Calling next()
on exhausted iterator will
throw NoSuchElementException
.
In case a sink (i.e. no edges) vertex is reached, iterator will return null and consecutive calls
to next()
will throw NoSuchElementException
.
For this iterator to work correctly the graph must not be modified during iteration. Currently
there are no means to ensure that, nor to fail-fast. The results of such modifications are
undefined.nListeners, reusableEdgeEvent, reusableVertexEvent, specifics
Constructor and Description |
---|
RandomWalkIterator(Graph<V,E> graph)
Creates a new iterator for the specified graph.
|
RandomWalkIterator(Graph<V,E> graph,
V startVertex)
Creates a new iterator for the specified graph.
|
RandomWalkIterator(Graph<V,E> graph,
V startVertex,
boolean isWeighted)
Creates a new iterator for the specified graph.
|
RandomWalkIterator(Graph<V,E> graph,
V startVertex,
boolean isWeighted,
long maxSteps)
Creates a new iterator for the specified graph.
|
Modifier and Type | Method and Description |
---|---|
protected void |
encounterVertex(V vertex,
E edge)
Update data structures every time we see a vertex.
|
boolean |
hasNext() |
protected boolean |
isExhausted()
Check if this walk is exhausted.
|
V |
next() |
addTraversalListener, fireConnectedComponentFinished, fireConnectedComponentStarted, fireEdgeTraversed, fireVertexFinished, fireVertexTraversed, isCrossComponentTraversal, isReuseEvents, remove, removeTraversalListener, setCrossComponentTraversal, setReuseEvents
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public RandomWalkIterator(Graph<V,E> graph)
Long#MAX_VALUE
steps.graph
- the graph to be iterated.IllegalArgumentException
- if graph==null
or does not contain
startVertex
public RandomWalkIterator(Graph<V,E> graph, V startVertex)
null
, Iteration will start at an arbitrary graph vertex. Walk is un-weighted and
bounded by Long#MAX_VALUE
steps.graph
- the graph to be iterated.startVertex
- the vertex iteration to be started.IllegalArgumentException
- if graph==null
or does not contain
startVertex
public RandomWalkIterator(Graph<V,E> graph, V startVertex, boolean isWeighted)
null
, Iteration will start at an arbitrary graph vertex. Walk is bounded by
Long#MAX_VALUE
steps.graph
- the graph to be iterated.startVertex
- the vertex iteration to be started.isWeighted
- set to true
if a weighted walk is desired.IllegalArgumentException
- if graph==null
or does not contain
startVertex
public RandomWalkIterator(Graph<V,E> graph, V startVertex, boolean isWeighted, long maxSteps)
null
, Iteration will start at an arbitrary graph vertex. Walk is bounded by the
provided number steps.graph
- the graph to be iterated.startVertex
- the vertex iteration to be started.isWeighted
- set to true
if a weighted walk is desired.maxSteps
- number of steps before walk is exhausted.IllegalArgumentException
- if graph==null
or does not contain
startVertex
protected boolean isExhausted()
next()
on exhausted iterator will throw
NoSuchElementException
.true
if this iterator is exhausted, false
otherwise.protected void encounterVertex(V vertex, E edge)
vertex
- the vertex encounterededge
- the edge via which the vertex was encountered, or null if the vertex is a
starting pointpublic boolean hasNext()
Iterator.hasNext()
public V next()
Iterator.next()
Copyright © 2016. All rights reserved.