public class WeightedRandomWalkIterator<V> extends java.lang.Object implements GraphWalkIterator<V>
RandomWalkIterator
, the WeightedRandomWalkIterator
uses the values associated with each edge
to determine probabilities. Weights on each edge need not be normalized.WeightedRandomWalkIterator
can only be used on graphs with an edge type that extends the Number
class (i.e., Integer, Double, etc)Constructor and Description |
---|
WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph,
int walkLength) |
WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph,
int walkLength,
long rngSeed)
Construct a RandomWalkIterator for a given graph, with a specified walk length and random number generator seed.
Uses NoEdgeHandling.EXCEPTION_ON_DISCONNECTED - hence exception will be thrown when generating random
walks on graphs with vertices containing having no edges, or no outgoing edges (for directed graphs) |
WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph,
int walkLength,
long rngSeed,
NoEdgeHandling mode) |
WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph,
int walkLength,
long rngSeed,
NoEdgeHandling mode,
int firstVertex,
int lastVertex)
Constructor used to generate random walks starting at a subset of the vertices in the graph.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Whether the iterator has any more vertex sequences.
|
IVertexSequence<V> |
next()
Get the next vertex sequence.
|
void |
reset()
Reset the graph walk iterator.
|
int |
walkLength()
Length of the walks returned by next()
Note that a walk of length
i contains i+1 vertices |
public WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph, int walkLength)
public WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph, int walkLength, long rngSeed)
NoEdgeHandling.EXCEPTION_ON_DISCONNECTED
- hence exception will be thrown when generating random
walks on graphs with vertices containing having no edges, or no outgoing edges (for directed graphs)public WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph, int walkLength, long rngSeed, NoEdgeHandling mode)
graph
- IGraph to conduct walks onwalkLength
- length of each walk. Walk of length 0 includes 1 vertex, walk of 1 includes 2 vertices etcrngSeed
- seed for randomizationmode
- mode for handling random walks from vertices with either no edges, or no outgoing edges (for directed graphs)public WeightedRandomWalkIterator(IGraph<V,? extends java.lang.Number> graph, int walkLength, long rngSeed, NoEdgeHandling mode, int firstVertex, int lastVertex)
graph
- IGraph to conduct walks onwalkLength
- length of each walk. Walk of length 0 includes 1 vertex, walk of 1 includes 2 vertices etcrngSeed
- seed for randomizationmode
- mode for handling random walks from vertices with either no edges, or no outgoing edges (for directed graphs)firstVertex
- first vertex index (inclusive) to start random walks fromlastVertex
- last vertex index (exclusive) to start random walks frompublic IVertexSequence<V> next()
GraphWalkIterator
next
in interface GraphWalkIterator<V>
public boolean hasNext()
GraphWalkIterator
hasNext
in interface GraphWalkIterator<V>
public void reset()
GraphWalkIterator
reset
in interface GraphWalkIterator<V>
public int walkLength()
GraphWalkIterator
i
contains i+1
verticeswalkLength
in interface GraphWalkIterator<V>