本文整理汇总了C#中Graph.AcceptVisitor方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.AcceptVisitor方法的具体用法?C# Graph.AcceptVisitor怎么用?C# Graph.AcceptVisitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.AcceptVisitor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Simple
public void Simple()
{
var graph = new Graph<int>(false);
var vertices = new Vertex<int>[20];
for (var i = 0; i < 20; i++)
{
vertices[i] = new Vertex<int>(i);
graph.AddVertex(vertices[i]);
}
for (var i = 0; i < 17; i += 2)
{
var edge = new Edge<int>(vertices[i], vertices[i + 2], false);
graph.AddEdge(edge);
}
var trackingVisitor = new TrackingVisitor<int>();
graph.AcceptVisitor(trackingVisitor);
Assert.AreEqual(trackingVisitor.TrackingList.Count, 20);
for (var i = 0; i < 20; i++)
{
Assert.IsTrue(trackingVisitor.TrackingList.Contains(i));
}
}
示例2: AcceptExample
public void AcceptExample()
{
// Initialize a new graph instance
var graph = new Graph<int>(true);
// Add three vertices to the graph
graph.AddVertex(1);
graph.AddVertex(2);
graph.AddVertex(3);
// Create a counting visitor. The counting
// visitor will keep track of the number of
// items on which Accept was called.
var visitor = new CountingVisitor<int>();
// Let the visitor in the door
graph.AcceptVisitor(visitor);
// The visitor will have visited three vertices.
Assert.AreEqual(visitor.Count, 3);
}
示例3: CompletedVisitor
public void CompletedVisitor()
{
var graph = new Graph<int>(false);
var vertices = new Vertex<int>[20];
for (var i = 0; i < 20; i++)
{
vertices[i] = new Vertex<int>(i);
graph.AddVertex(vertices[i]);
}
for (var i = 0; i < 17; i += 2)
{
var edge = new Edge<int>(vertices[i], vertices[i + 2], false);
graph.AddEdge(edge);
}
var completedTrackingVisitor = new CompletedTrackingVisitor<int>();
graph.AcceptVisitor(completedTrackingVisitor);
}
示例4: ExceptionNullVisitor
public void ExceptionNullVisitor()
{
var graph = new Graph<int>(false);
graph.AcceptVisitor(null);
}