本文整理汇总了C#中Graph.SetVertex方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.SetVertex方法的具体用法?C# Graph.SetVertex怎么用?C# Graph.SetVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.SetVertex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestArguments
public void TestArguments()
{
using (var graph = new Graph<Edge>(new MemoryMappedStream(new MemoryStream()), 1000,
Edge.MapFromDelegate, Edge.MapToDelegate, Edge.SizeUints))
{
uint vertex1 = graph.AddVertex(0, 0);
uint vertex2 = graph.AddVertex(0, 0);
uint vertex3 = 3;
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.AddEdge(vertex3, vertex1, new Edge(), null);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.AddEdge(vertex1, vertex3, new Edge(), null);
});
Assert.Catch<ArgumentException>(() =>
{
graph.AddEdge(vertex1, vertex1, new Edge(), null);
});
Assert.Catch<ArgumentException>(() =>
{
graph.AddEdge(vertex1, vertex1, new Edge(), null);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.ContainsEdges(vertex3, vertex1);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.ContainsEdges(vertex1, vertex3);
});
Edge edge;
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.GetEdge(vertex3, vertex1, out edge);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.GetEdge(vertex1, vertex3, out edge);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.GetEdges(vertex3);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.SetVertex(vertex3, 10, 10);
});
}
}
示例2: TestGraphAddVertex
public void TestGraphAddVertex()
{
var graph = new Graph<Edge>();
var vertex = graph.AddVertex(51, 4);
float latitude, longitude;
graph.GetVertex(vertex, out latitude, out longitude);
Assert.AreEqual(51, latitude);
Assert.AreEqual(4, longitude);
graph.SetVertex(vertex, 52, 5);
graph.GetVertex(vertex, out latitude, out longitude);
Assert.AreEqual(52, latitude);
Assert.AreEqual(5, longitude);
var edges = graph.GetEdges(vertex).ToKeyValuePairs();
Assert.AreEqual(0, edges.Length);
Assert.IsFalse(graph.GetVertex(100, out latitude, out longitude));
}
示例3: TestGraphArguments
public void TestGraphArguments()
{
// create graph with one vertex and start adding vertex2.
var graph = new Graph<Edge>();
uint vertex1 = graph.AddVertex(0, 0);
uint vertex2 = graph.AddVertex(0, 0);
uint vertex3 = 3;
Assert.Catch<ArgumentOutOfRangeException>(() => {
graph.AddEdge(vertex3, vertex1, new Edge(), null);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.AddEdge(vertex1, vertex3, new Edge(), null);
});
Assert.Catch<ArgumentException>(() =>
{
graph.AddEdge(vertex1, vertex1, new Edge(), null);
});
Assert.Catch<ArgumentException>(() =>
{
graph.AddEdge(vertex1, vertex1, new Edge(), null);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.ContainsEdges(vertex3, vertex1);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.ContainsEdges(vertex1, vertex3);
});
Edge edge;
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.GetEdge(vertex3, vertex1, out edge);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.GetEdge(vertex1, vertex3, out edge);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.GetEdges(vertex3);
});
Assert.Catch<ArgumentOutOfRangeException>(() =>
{
graph.SetVertex(vertex3, 10, 10);
});
}
示例4: TestVertex
public void TestVertex()
{
using (var graph = new Graph<Edge>(new MemoryMappedStream(new MemoryStream()), 1000, Edge.MapFromDelegate, Edge.MapToDelegate, Edge.SizeUints))
{
var vertex = graph.AddVertex(51, 4);
float latitude, longitude;
graph.GetVertex(vertex, out latitude, out longitude);
Assert.AreEqual(51, latitude);
Assert.AreEqual(4, longitude);
graph.SetVertex(vertex, 52, 5);
graph.GetVertex(vertex, out latitude, out longitude);
Assert.AreEqual(52, latitude);
Assert.AreEqual(5, longitude);
var edges = graph.GetEdges(vertex).ToKeyValuePairs();
Assert.AreEqual(0, edges.Length);
Assert.IsFalse(graph.GetVertex(100, out latitude, out longitude));
}
}