本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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]);
}