def test_optimal_sort_for_trees__tree_2(tree_2):
    tree = operations.cast_to_tree(tree_2)
    sorted_labels = [
        node.label for node in topologicalsort.optimal_sort_for_trees(tree).nodes()
    ]

    assert sorted_labels == ["a", "b", "c1", "c2", "c3", "d", "f", "e1", "e2", "e3"]
def test_optimal_sort_for_trees__tree_1(tree_1):
    tree = operations.cast_to_tree(tree_1)
    sorted_labels = [
        node.label for node in topologicalsort.optimal_sort_for_trees(tree).nodes()
    ]

    assert sorted_labels == ["a", "b", "e", "c", "d"]
예제 #3
0
def test_get_root_of_tree__is_a_tree(tree):
    if len(tree) == 0:
        return

    expected_root = tree.get_node("a")

    actual_root = operations.cast_to_tree(tree).root

    assert expected_root == actual_root
예제 #4
0
def test_cast_to_tree__disconnected_graph(disconnected_graph):
    assert operations.cast_to_tree(disconnected_graph) is None
예제 #5
0
def test_cast_to_tree__empty_graph(empty_graph):
    assert operations.cast_to_tree(empty_graph) is None
예제 #6
0
def test_get_root_of_tree__not_a_tree(non_sortable_graph):
    assert operations.cast_to_tree(non_sortable_graph) is None