本文整理汇总了C#中Graph.AddEdges方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.AddEdges方法的具体用法?C# Graph.AddEdges怎么用?C# Graph.AddEdges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.AddEdges方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddVertices_AddParentTwice_OnlyOneNode
public void AddVertices_AddParentTwice_OnlyOneNode()
{
IGraph<string> graph = new Graph<string>();
// Act
graph.AddEdges("Parent", new List<string>());
graph.AddEdges("Parent", new List<string>());
// Assert
Assert.AreEqual(1, graph.Vertices.Count());
Assert.AreEqual("Parent", graph.Vertices.First());
Assert.AreEqual(0, graph.Edges.Count());
}
示例2: AddVertices_AddChildTwice_OnlyOneNode
public void AddVertices_AddChildTwice_OnlyOneNode()
{
IGraph<string> graph = new Graph<string>();
// Act
graph.AddEdges("ParentX", new List<string>() { "Child" });
graph.AddEdges("ParentY", new List<string>() { "Child" });
// Assert
Assert.AreEqual(3, graph.Vertices.Count());
Assert.AreEqual(2, graph.Edges.Count());
Assert.IsTrue(graph.Vertices.Contains("ParentX"));
Assert.IsTrue(graph.Vertices.Contains("ParentY"));
Assert.IsTrue(graph.Vertices.Contains("Child"));
}
示例3: AddVertices_NoChildren_ParentIsAddedAsNode
public void AddVertices_NoChildren_ParentIsAddedAsNode()
{
IGraph<string> graph = new Graph<string>();
// Act
graph.AddEdges("Parent", new List<string>());
// Assert
Assert.AreEqual(1, graph.Vertices.Count());
Assert.AreEqual("Parent", graph.Vertices.First());
Assert.AreEqual(0, graph.Edges.Count());
}
示例4: AddVertices_OneChild_NodesAndVerticesAreCorrect
public void AddVertices_OneChild_NodesAndVerticesAreCorrect()
{
IGraph<string> graph = new Graph<string>();
// Act
graph.AddEdges("Parent", new List<string>() { "Child" } );
// Assert
Assert.AreEqual(2, graph.Vertices.Count());
Assert.IsTrue(graph.Vertices.Contains("Parent"));
Assert.IsTrue(graph.Vertices.Contains("Child"));
var vertex = graph.Edges.First();
Assert.AreEqual(1, graph.Edges.Count());
Assert.AreEqual("Parent", vertex.Parent);
Assert.AreEqual("Child", vertex.Child);
}