本文整理汇总了C#中Vertex.GetIncidentEdgeWith方法的典型用法代码示例。如果您正苦于以下问题:C# Vertex.GetIncidentEdgeWith方法的具体用法?C# Vertex.GetIncidentEdgeWith怎么用?C# Vertex.GetIncidentEdgeWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex
的用法示例。
在下文中一共展示了Vertex.GetIncidentEdgeWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Undirected
public void Undirected()
{
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.AddEdge(vertex1, vertex2);
var edge = vertex1.GetIncidentEdgeWith(vertex2);
Assert.AreEqual(edge.FromVertex, vertex1);
Assert.AreEqual(edge.ToVertex, vertex2);
edge = vertex2.GetIncidentEdgeWith(vertex1);
Assert.AreEqual(edge.FromVertex, vertex1);
Assert.AreEqual(edge.ToVertex, vertex2);
Assert.IsNull(vertex1.GetIncidentEdgeWith(vertex3));
}
示例2: GetIncidentEdgeWithExample
public void GetIncidentEdgeWithExample()
{
// 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 incident edge from vertex1 to vertex2
var edge = vertex1.GetIncidentEdgeWith(vertex2);
// Which will be a valid edge
Assert.IsNotNull(edge);
// Incident edges are edges "touching" the
// vertex, irrespective of direction
edge = vertex2.GetIncidentEdgeWith(vertex1);
// Will also be a valid edge
Assert.IsNotNull(edge);
}