本文整理汇总了C#中Vertex.HasEmanatingEdgeTo方法的典型用法代码示例。如果您正苦于以下问题:C# Vertex.HasEmanatingEdgeTo方法的具体用法?C# Vertex.HasEmanatingEdgeTo怎么用?C# Vertex.HasEmanatingEdgeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex
的用法示例。
在下文中一共展示了Vertex.HasEmanatingEdgeTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OtherVertex
public void OtherVertex()
{
var graph = new Graph<int>(true);
var vertex1 = new Vertex<int>(1);
var vertex2 = new Vertex<int>(2);
var vertex3 = new Vertex<int>(3);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddVertex(vertex3);
graph.AddEdge(vertex1, vertex2);
graph.AddEdge(vertex3, vertex2);
graph.AddEdge(vertex1, vertex3);
Assert.AreEqual(graph.Edges.Count, 3);
Assert.AreEqual(graph.Vertices.Count, 3);
Assert.IsTrue(graph.RemoveEdge(vertex1, vertex2));
Assert.AreEqual(graph.Edges.Count, 2);
Assert.IsFalse(vertex1.HasEmanatingEdgeTo(vertex2));
Assert.IsTrue(vertex3.HasEmanatingEdgeTo(vertex2));
Assert.IsTrue(graph.RemoveEdge(vertex3, vertex2));
Assert.AreEqual(graph.Edges.Count, 1);
Assert.IsFalse(vertex1.HasEmanatingEdgeTo(vertex2));
Assert.IsFalse(vertex3.HasEmanatingEdgeTo(vertex2));
}
示例2: HasEmanatingEdgeToExample
public void HasEmanatingEdgeToExample()
{
// 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);
// vertex1 has an emanating edge to vertex2
Assert.IsTrue(vertex1.HasEmanatingEdgeTo(vertex2));
// But vertex2 does not have an emanating edge to vertex1
Assert.IsFalse(vertex2.HasEmanatingEdgeTo(vertex1));
}
示例3: VerticesAndWeightUndirected
public void VerticesAndWeightUndirected()
{
var graph = new Graph<int>(false);
var vertex1 = new Vertex<int>(4);
var vertex2 = new Vertex<int>(5);
var vertex3 = new Vertex<int>(6);
graph.AddVertex(vertex1);
graph.AddVertex(vertex2);
graph.AddVertex(vertex3);
graph.AddEdge(vertex1, vertex2, 10);
graph.AddEdge(vertex1, vertex3, 12);
graph.AddEdge(vertex2, vertex3, 14);
Assert.AreEqual(graph.Edges.Count, 3);
Assert.IsTrue(vertex1.HasEmanatingEdgeTo(vertex2));
Assert.IsTrue(vertex1.HasEmanatingEdgeTo(vertex3));
Assert.IsTrue(vertex2.HasEmanatingEdgeTo(vertex3));
Assert.IsTrue(vertex2.HasEmanatingEdgeTo(vertex1));
Assert.IsTrue(vertex3.HasEmanatingEdgeTo(vertex1));
Assert.IsTrue(vertex3.HasEmanatingEdgeTo(vertex2));
Assert.IsTrue(graph.ContainsEdge(vertex1, vertex2));
Assert.IsTrue(graph.ContainsEdge(vertex1, vertex3));
Assert.IsTrue(graph.ContainsEdge(vertex2, vertex3));
Assert.IsTrue(graph.ContainsEdge(vertex2, vertex1));
Assert.IsTrue(graph.ContainsEdge(vertex3, vertex1));
Assert.IsTrue(graph.ContainsEdge(vertex3, vertex2));
}