Assembly: QuickGraph.Algorithms (in QuickGraph.Algorithms.dll) Version: 2.4.2.1514 (2.4.2.1514)
Syntax
| C# |
|---|
public class RandomWalkAlgorithm : IAlgorithm |
| Visual Basic (Declaration) |
|---|
Public Class RandomWalkAlgorithm _ Implements IAlgorithm |
Remarks
This algorithms walks randomly across a directed graph. The probability to choose the next out-edges is provided by a IMarkovEdgeChain instance.
Events
The StartVertex is raised on the root vertex of the walk. This event is raised once.
On each new edge in the walk, the TreeEdge is raised with the edge added to the walk tree.
The EndVertex is raised on the last vertex of the walk. This event is raised once.
Custom end of walk condition can be provided by attacing a IEdgePredicate instance to the EndPredicate property.
Examples
// define delegates public void TreeEdge(Object sender, EdgeEventArgs e) { Console.WriteLine( "{0}->{1}", e.Edge.Source.ToString(), e.Edge.Target.ToString()); } ... IVertexListGraph g = ...; // create algo RandomWalkAlgorithm walker = new RandomWalkAlgorithm(g); // attach event handler walker.TreeEdge += new EdgeEventHandler(this.TreeEdge); // walk until we read a dead end. waler.Generate(int.MaxValue);
