本文整理汇总了C#中Graph.SortTopologically方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.SortTopologically方法的具体用法?C# Graph.SortTopologically怎么用?C# Graph.SortTopologically使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.SortTopologically方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SortTopologicallyAsString_does_not_scan_dependencies_for_Visited_packages
public void SortTopologicallyAsString_does_not_scan_dependencies_for_Visited_packages()
{
Graph graph = new Graph();
PackageDefinition definitionA = new PackageDefinition("A:B");
definitionA.MarkAsAdded();
graph.AddPackageDefinition(definitionA);
Queue<string> result = graph.SortTopologically();
Assert.IsEmpty(result);
}
示例2: SortTopologicallyAsString_throws_exception_if_package_definitions_contain_cycle
public void SortTopologicallyAsString_throws_exception_if_package_definitions_contain_cycle()
{
Graph graph = new Graph();
PackageDefinition definitionA = new PackageDefinition("A:B");
PackageDefinition definitionB = new PackageDefinition("B:A");
graph.AddPackageDefinition(definitionA);
graph.AddPackageDefinition(definitionB);
Assert.Throws<InvalidOperationException>(() => graph.SortTopologically());
}
示例3: Graph
public void SortTopologically_throws_exception_if_package_definitions_contain_cycle_even_for_more_complex_scenarios()
{
Graph graph = new Graph();
PackageDefinition definitionA = new PackageDefinition("A:B, C");
PackageDefinition definitionD = new PackageDefinition("D:A");
PackageDefinition definitionB = new PackageDefinition("B:C");
PackageDefinition definitionC = new PackageDefinition("C:E");
PackageDefinition definitionE = new PackageDefinition("E:D");
graph.AddPackageDefinition(definitionA);
graph.AddPackageDefinition(definitionB);
graph.AddPackageDefinition(definitionC);
graph.AddPackageDefinition(definitionD);
graph.AddPackageDefinition(definitionE);
Assert.Throws<InvalidOperationException>(() => graph.SortTopologically());
}
示例4: SortTopologically_returns_the_node_if_it_has_no_dependency_list
public void SortTopologically_returns_the_node_if_it_has_no_dependency_list()
{
Graph graph = new Graph();
PackageDefinition definition = new PackageDefinition("A");
graph.AddPackageDefinition(definition);
Queue<string> sortedQueue = graph.SortTopologically();
Assert.IsTrue(sortedQueue.Count == 1);
Assert.AreEqual(definition.Package, sortedQueue.Peek());
}