本文整理汇总了C#中Graph.ContainsVertex方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.ContainsVertex方法的具体用法?C# Graph.ContainsVertex怎么用?C# Graph.ContainsVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.ContainsVertex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Directed
public void Directed()
{
var graph = new Graph<int>(true);
for (var i = 0; i < 20; i++)
{
var vertex = new Vertex<int>(i);
graph.AddVertex(vertex);
Assert.AreEqual(graph.Vertices.Count, i + 1);
Assert.IsTrue(graph.ContainsVertex(i));
Assert.IsTrue(graph.ContainsVertex(vertex));
Assert.AreEqual(graph.Edges.Count, 0);
}
}
示例2: Simple
public void Simple()
{
var graph = new Graph<int>(false);
for (var i = 0; i < 20; i++)
{
var vertex = new Vertex<int>(i);
graph.AddVertex(vertex);
Assert.IsTrue(graph.ContainsVertex(i));
Assert.IsTrue(graph.ContainsVertex(vertex));
}
Assert.IsFalse(graph.ContainsVertex(new Vertex<int>(3)));
Assert.IsFalse(graph.ContainsVertex(21));
}
示例3: ContainsVertexValueExample
public void ContainsVertexValueExample()
{
// Initialize a new graph instance
var graph = new Graph<int>(true);
// Add two vertices to the graph
graph.AddVertex(1);
graph.AddVertex(2);
// The graph will contain vertex values 1 and 2
Assert.IsTrue(graph.ContainsVertex(1));
Assert.IsTrue(graph.ContainsVertex(2));
// But not vertex value 3
Assert.IsFalse(graph.ContainsVertex(3));
}
示例4: ContainsVertexExample
public void ContainsVertexExample()
{
// Initialize a new graph instance
var graph = new Graph<int>(true);
// Add two vertices to the graph
var vertex1 = graph.AddVertex(1);
var vertex2 = graph.AddVertex(2);
// Create a vertex that doesn't form part of the graph
var vertex3 = new Vertex<int>(3);
// The graph will contain vertices vertex1 and vertex2
Assert.IsTrue(graph.ContainsVertex(vertex1));
Assert.IsTrue(graph.ContainsVertex(vertex2));
// But not vertex vertex3
Assert.IsFalse(graph.ContainsVertex(vertex3));
}
示例5: UndirectedVertexValue
public void UndirectedVertexValue()
{
var graph = new Graph<int>(false);
for (var i = 0; i < 20; i++)
{
graph.AddVertex(i);
Assert.AreEqual(graph.Vertices.Count, i + 1);
Assert.IsTrue(graph.ContainsVertex(i));
Assert.AreEqual(graph.Edges.Count, 0);
}
}