提交 d7df1a98 authored 作者: Matthew Rocklin's avatar Matthew Rocklin

inputs/outputs/example for _toposort docstring

上级 8f2d3dc5
...@@ -53,6 +53,14 @@ def reverse_dict(d): ...@@ -53,6 +53,14 @@ def reverse_dict(d):
def _toposort(edges): def _toposort(edges):
""" Topological sort algorithm by Kahn [1] - O(nodes + vertices) """ Topological sort algorithm by Kahn [1] - O(nodes + vertices)
inputs:
edges - a dict of the form {a: {b, c}} where b and c depend on a
outputs:
L - an ordered list of nodes that satisfy the dependencies of edges
>>> _toposort({1: {2, 3}, 2: (3, )})
[1, 2, 3]
Closely follows the wikipedia page [2] Closely follows the wikipedia page [2]
[1] Kahn, Arthur B. (1962), "Topological sorting of large networks", [1] Kahn, Arthur B. (1962), "Topological sorting of large networks",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论