当前位置: 首页>>代码示例>>C#>>正文


C# Graph.AddNeighbours方法代码示例

本文整理汇总了C#中Graph.AddNeighbours方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.AddNeighbours方法的具体用法?C# Graph.AddNeighbours怎么用?C# Graph.AddNeighbours使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph.AddNeighbours方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SquareTest2

 public void SquareTest2()
 {
     var graph = new Graph(4);
     graph.AddNeighbours(0, new List<int>() { 1, 2 });
     graph.AddNeighbours(1, new List<int>() { 3 });
     graph.AddNeighbours(2, new List<int>() { 3 });
     var robots = new Robots(graph, new[] { 0, 1,  3 });
     Assert.IsFalse(robots.WillBeDestroyed());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:9,代码来源:RobotsTests.cs

示例2: SingleRobotTest

 public void SingleRobotTest()
 {
     var graph = new Graph(3);
     graph.AddNeighbours(0, new List<int>() { 1, 2 });
     graph.AddNeighbours(1, new List<int>() { 2 });
     graph.AddNeighbours(2, new List<int>());
     var robots = new Robots(graph, new[] { 0 });
     Assert.IsFalse(robots.WillBeDestroyed());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:9,代码来源:RobotsTests.cs

示例3: WillBeDestroyedTest2

 public void WillBeDestroyedTest2()
 {
     var graph = new Graph(3);
     graph.AddNeighbours(0, new List<int>() { 1 });
     graph.AddNeighbours(1, new List<int>() { 2 });
     var robots = new Robots(graph, new[] { 1, 2 });
     Assert.IsFalse(robots.WillBeDestroyed());
     var robots2 = new Robots(graph, new[] { 2, 0 });
     Assert.IsTrue(robots2.WillBeDestroyed());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:10,代码来源:RobotsTests.cs

示例4: WillBeDestroyedTest3

 public void WillBeDestroyedTest3()
 {
     var graph = new Graph(4);
     graph.AddNeighbours(0, new List<int>() { 1, 3 });
     graph.AddNeighbours(1, new List<int>() { 3 });
     graph.AddNeighbours(2, new List<int>() { 3 });
     var robots = new Robots(graph, new[] { 0, 2 });
     Assert.IsTrue(robots.WillBeDestroyed());
     var robots2 = new Robots(graph, new[] { 2, 0 });
     Assert.IsTrue(robots2.WillBeDestroyed());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:11,代码来源:RobotsTests.cs

示例5: HasCycleWithOddLenghtTest2

 public void HasCycleWithOddLenghtTest2()
 {
     var graph = new Graph(6);
     graph.AddNeighbours(0, new List<int>() { 1 });
     graph.AddNeighbours(1, new List<int>() { 2, 5, 0 });
     graph.AddNeighbours(2, new List<int>() { 1 });
     graph.AddNeighbours(3, new List<int>() { 4 });
     graph.AddNeighbours(4, new List<int>() { 3, 5 });
     graph.AddNeighbours(5, new List<int>() { 1, 4 });
     Assert.IsFalse(graph.HasCycleWithOddLenght());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:11,代码来源:GraphTests.cs

示例6: WillBeDestroyedTest

 public void WillBeDestroyedTest()
 {
     var graph = new Graph(6);
     graph.AddNeighbours(0, new List<int>() { 1 });
     graph.AddNeighbours(1, new List<int>() { 2, 5, 0 });
     graph.AddNeighbours(2, new List<int>() { 1 });
     graph.AddNeighbours(3, new List<int>() { 4 });
     graph.AddNeighbours(4, new List<int>() { 3, 5 });
     graph.AddNeighbours(5, new List<int>() { 1, 4 });
     var robots = new Robots(graph, new[] { 1, 4 });
     Assert.IsTrue(robots.WillBeDestroyed());
     var robots2 = new Robots(graph, new[] { 1, 5 });
     Assert.IsFalse(robots2.WillBeDestroyed());
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:14,代码来源:RobotsTests.cs

示例7: WayToVerticesTest

 public void WayToVerticesTest()
 {
     var graph = new Graph(6);
     graph.AddNeighbours(0, new List<int>() { 1 });
     graph.AddNeighbours(1, new List<int>() { 2, 5, 0 });
     graph.AddNeighbours(2, new List<int>() { 1 });
     graph.AddNeighbours(3, new List<int>() { 4 });
     graph.AddNeighbours(4, new List<int>() { 3, 5 });
     graph.AddNeighbours(5, new List<int>() { 1, 4 });
     var ways = graph.WayToVertices(5);
     Assert.AreEqual(1, ways[4]);
     Assert.AreEqual(1, ways[1]);
     Assert.AreEqual(2, ways[2]);
     Assert.AreEqual(2, ways[3]);
     Assert.AreEqual(2, ways[0]);
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:16,代码来源:GraphTests.cs


注:本文中的Graph.AddNeighbours方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。