public void SortThrowsTopologicalSortExceptionExceptionWhenGraphContainsLoops() { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); graph.AddSequence(new[] { 61, 11 }); graph.Sort().ToArray(); }
public void GetNodesWithBetweenReturnsNodesOnTheLevelsInTheRange(int levelFrom, int levelTo, int[] expectedNodes) { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); GraphTestHelper.AssertCollectionsConsistsOfNodes(expectedNodes, graph.GetNodesBetween(levelFrom, levelTo)); GraphTestHelper.AssertNodesAreOrderedByLevel(graph.GetNodesBetween(levelFrom, levelTo)); }
public void SortReturnsNodesInTopologicalOrder() { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); var nodes = graph.Sort(); Assert.AreEqual(20, nodes.Count()); AssertNodesAreInTopologicalOrder(nodes); }
public void DescendantsReturnsDescendantsOfTheNode(int node, int[] expectedDescendants) { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); GraphTestHelper.AssertCollectionsConsistsOfNodes(expectedDescendants, graph.Find(node).Descendants); GraphTestHelper.AssertNodesAreOrderedByLevel(graph.Find(node).Descendants); }
public void GetNodesReturnsNodesOnTheLevel(int level, int[] expectedNodes) { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); GraphTestHelper.AssertCollectionsConsistsOfNodes(expectedNodes, graph.GetNodes(level)); GraphTestHelper.AssertNodesAreOrderedByLevel(graph.GetNodes(level)); }
public void GetNeighboursReturnsNeighboursOfTheNodeInTheRangeOfLevels(int node, int[] expectedNeighbours) { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); GraphTestHelper.AssertCollectionsConsistsOfNodes(expectedNeighbours, graph.Find(node).GetNeighbours(-1, 2)); GraphTestHelper.AssertNodesAreOrderedByLevel(graph.Find(node).GetNeighbours(-1, 2)); }
public void TerminatingPrecedentsReturnsPrecedentsOfTheNodeOnTheZeroLevel(int node, int[] expectedTerminatingPrecedents) { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); GraphTestHelper.AssertCollectionsConsistsOfNodes(expectedTerminatingPrecedents, graph.Find(node).TerminatingPrecedents); GraphTestHelper.AssertNodesAreOrderedByLevel(graph.Find(node).TerminatingPrecedents); }
public void LevelCalculatesCorrectly(int node, int expectedLevel) { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); var countLevels = graph.CountLevels; // force graph to rebuild. fix this later var target = graph.Find(node); Assert.AreEqual(expectedLevel, target.Level, "Level of node {0} expected to be {1}, but is {2}", target.Value, expectedLevel, target.Level); }
public void FindReturnsCorrectValue(int node) { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); Assert.AreEqual(node, graph.Find(node).Value); }
public void CountLevelsReturnsNumberOfLevelsInGraph1() { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); Assert.AreEqual(6, graph.CountLevels); }
public void CountReturnsCountOfGraph() { var graph = GraphTestHelper.CreateExampleGraph(TargetGraph); Assert.AreEqual(20, graph.CountNodes); }