コード例 #1
0
def test_topological_sort_is_deterministic(graph: DirectedGraph,
                                           reverse: bool) -> None:
    assert iequal(
        graph.topological_sort(reverse=reverse),
        graph.topological_sort(reverse=reverse),
        strict=True,
    )
コード例 #2
0
def test_topological_sort(graph: DirectedGraph, reverse: bool) -> None:
    sorted_nodes = list(graph.topological_sort(reverse=reverse))
    nodes = list(graph.nodes())

    assert len(sorted_nodes) == len(nodes)
    assert set(sorted_nodes) == set(nodes)