本文整理汇总了C#中Vertex.GetEmanatingEdgeTo方法的典型用法代码示例。如果您正苦于以下问题:C# Vertex.GetEmanatingEdgeTo方法的具体用法?C# Vertex.GetEmanatingEdgeTo怎么用?C# Vertex.GetEmanatingEdgeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex
的用法示例。
在下文中一共展示了Vertex.GetEmanatingEdgeTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Directed
public void Directed()
{
var vertex1 = new Vertex<int>(3);
var vertex2 = new Vertex<int>(5);
var vertex3 = new Vertex<int>(8);
var graph = new Graph<int>(true);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddVertex(vertex3);
graph.AddEdge(vertex1, vertex2);
graph.AddEdge(vertex3, vertex1);
var edgeList = vertex3.IncidentEdges;
Assert.AreEqual(edgeList.Count, 1);
AssertContainsEdges(edgeList, true,
vertex3.GetEmanatingEdgeTo(vertex1)
);
edgeList = vertex1.IncidentEdges;
Assert.AreEqual(edgeList.Count, 2);
AssertContainsEdges(edgeList, true,
vertex1.GetEmanatingEdgeTo(vertex2),
vertex3.GetEmanatingEdgeTo(vertex1)
);
}
示例2: Directed
public void Directed()
{
var vertex1 = new Vertex<int>(3);
var vertex2 = new Vertex<int>(5);
var vertex3 = new Vertex<int>(8);
var graph = new Graph<int>(true);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddEdge(vertex1, vertex2);
var edge = vertex1.GetEmanatingEdgeTo(vertex2);
Assert.AreEqual(edge.FromVertex, vertex1);
Assert.AreEqual(edge.ToVertex, vertex2);
edge = vertex2.GetEmanatingEdgeTo(vertex1);
Assert.IsNull(edge);
Assert.IsNull(vertex1.GetEmanatingEdgeTo(vertex3));
}
示例3: UndirectedEnumerator
public void UndirectedEnumerator()
{
var vertex1 = new Vertex<int>(3);
var vertex2 = new Vertex<int>(5);
var vertex3 = new Vertex<int>(8);
var graph = new Graph<int>(false);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddVertex(vertex3);
graph.AddEdge(vertex1, vertex2);
graph.AddEdge(vertex3, vertex1);
var edgeList = vertex1.EmanatingEdges;
Assert.AreEqual(edgeList.Count, 2);
AssertContainsEdges(edgeList, true,
vertex1.GetEmanatingEdgeTo(vertex2),
vertex1.GetEmanatingEdgeTo(vertex3),
vertex3.GetEmanatingEdgeTo(vertex1));
}
示例4: GetEmanatingEdgeToExample
public void GetEmanatingEdgeToExample()
{
// Create two new vertices
var vertex1 = new Vertex<int>(2);
var vertex2 = new Vertex<int>(4);
// Create a graph, and add the vertices to
// the graph
var graph = new Graph<int>(true);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
// Add an edge from vertex1 to vertex vertex2
graph.AddEdge(vertex1, vertex2);
// Retrieve the emanating edge from vertex1 to vertex2
var edge = vertex1.GetEmanatingEdgeTo(vertex2);
// Which will be a valid edge
Assert.IsNotNull(edge);
// Requesting the emanating edge from vertex2 to vertex1
// will result in a null being returned - the
// edge is directed from vertex1 to vertex2.
edge = vertex2.GetEmanatingEdgeTo(vertex1);
Assert.IsNull(edge);
}