本文整理汇总了Python中vunit.dependency_graph.DependencyGraph.toposort方法的典型用法代码示例。如果您正苦于以下问题:Python DependencyGraph.toposort方法的具体用法?Python DependencyGraph.toposort怎么用?Python DependencyGraph.toposort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vunit.dependency_graph.DependencyGraph
的用法示例。
在下文中一共展示了DependencyGraph.toposort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_resort_after_additions
# 需要导入模块: from vunit.dependency_graph import DependencyGraph [as 别名]
# 或者: from vunit.dependency_graph.DependencyGraph import toposort [as 别名]
def test_should_resort_after_additions(self):
nodes = ['a', 'b', 'c', 'd', 'e', 'f']
dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f')]
graph = DependencyGraph()
self._add_nodes_and_dependencies(graph, nodes, dependencies)
graph.toposort()
dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f'), ('b', 'g')]
graph.add_node('g')
graph.add_dependency('b', 'g')
result = graph.toposort()
self._check_result(result, dependencies)
示例2: test_should_raise_runtime_error_exception_on_long_circular_dependency
# 需要导入模块: from vunit.dependency_graph import DependencyGraph [as 别名]
# 或者: from vunit.dependency_graph.DependencyGraph import toposort [as 别名]
def test_should_raise_runtime_error_exception_on_long_circular_dependency(self):
nodes = ["a", "b", "c", "d"]
dependencies = [("a", "b"), ("a", "c"), ("b", "d"), ("d", "a")]
graph = DependencyGraph()
self._add_nodes_and_dependencies(graph, nodes, dependencies)
try:
graph.toposort()
except CircularDependencyException as exc:
self.assertEqual(exc.path, ["a", "b", "d", "a"])
else:
self.fail("Exception not raised")
示例3: test_should_resort_after_additions
# 需要导入模块: from vunit.dependency_graph import DependencyGraph [as 别名]
# 或者: from vunit.dependency_graph.DependencyGraph import toposort [as 别名]
def test_should_resort_after_additions(self):
nodes = ['a', 'b', 'c', 'd', 'e', 'f']
dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f')]
g = DependencyGraph()
self._add_nodes_and_dependencies(g, nodes, dependencies)
g.toposort()
dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f'), ('b', 'g')]
g.add_node('g')
g.add_dependency('b', 'g')
result = g.toposort()
for d in dependencies:
self.assertTrue(result.index(d[0]) < result.index(d[1]), "%s is not before %s" % d)
示例4: test_should_sort_in_topological_order_when_there_are_dependencies
# 需要导入模块: from vunit.dependency_graph import DependencyGraph [as 别名]
# 或者: from vunit.dependency_graph.DependencyGraph import toposort [as 别名]
def test_should_sort_in_topological_order_when_there_are_dependencies(self):
nodes = ['a', 'b', 'c', 'd', 'e', 'f']
dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f')]
graph = DependencyGraph()
self._add_nodes_and_dependencies(graph, nodes, dependencies)
result = graph.toposort()
self._check_result(result, dependencies)
示例5: test_should_sort_in_topological_order_when_there_are_dependencies
# 需要导入模块: from vunit.dependency_graph import DependencyGraph [as 别名]
# 或者: from vunit.dependency_graph.DependencyGraph import toposort [as 别名]
def test_should_sort_in_topological_order_when_there_are_dependencies(self):
nodes = ['a', 'b', 'c', 'd', 'e', 'f']
dependencies = [('a', 'b'), ('a', 'c'), ('b', 'd'), ('e', 'f')]
g = DependencyGraph()
self._add_nodes_and_dependencies(g, nodes, dependencies)
result = g.toposort()
for d in dependencies:
self.assertTrue(result.index(d[0]) < result.index(d[1]), "%s is not before %s" % d)
示例6: test_should_return_list_of_nodes_when_there_are_no_dependencies
# 需要导入模块: from vunit.dependency_graph import DependencyGraph [as 别名]
# 或者: from vunit.dependency_graph.DependencyGraph import toposort [as 别名]
def test_should_return_list_of_nodes_when_there_are_no_dependencies(self):
nodes = ['a', 'b', 'c', 'd']
graph = DependencyGraph()
self._add_nodes_and_dependencies(graph, nodes, [])
result = graph.toposort()
self.assertEqual(result.sort(), nodes.sort(), 'Should return the node list in any order')
示例7: test_should_return_empty_compile_order_for_no_nodes
# 需要导入模块: from vunit.dependency_graph import DependencyGraph [as 别名]
# 或者: from vunit.dependency_graph.DependencyGraph import toposort [as 别名]
def test_should_return_empty_compile_order_for_no_nodes(self):
graph = DependencyGraph()
self.assertEqual(graph.toposort(), [], 'Should return empty list')