Exemplo n.º 1
0
def test_tgt_decomposition__general_case_1(in_tree_piece, out_tree_piece):
    in_tree_piece.create_node("b1")
    in_tree_piece.create_edge_using_labels("a1", "b1")

    tree_1, graph, tree_2 = operations.calculate_tgt_decomposition(
        datastructures.Graph.union([in_tree_piece, out_tree_piece])
    )

    assert tree_1 == datastructures.Tree(in_tree_piece, in_tree_piece.get_node("b1"))
    assert graph is None
    assert tree_2 == datastructures.Tree(out_tree_piece, out_tree_piece.get_node("b1"))
Exemplo n.º 2
0
def test_tgt_decomposition__general_case_3(in_tree_piece, out_tree_piece):
    middle_graph = datastructures.Graph.build_from_edge_label_tuples(
        [("a1", "c1"), ("c1", "b1"), ("a1", "c2"), ("c2", "b1")]
    )

    tree_1, graph, tree_2 = operations.calculate_tgt_decomposition(
        datastructures.Graph.union([in_tree_piece, middle_graph, out_tree_piece])
    )

    assert tree_1 == datastructures.Tree(in_tree_piece, in_tree_piece.get_node("a1"))
    assert graph == middle_graph
    assert tree_2 == datastructures.Tree(out_tree_piece, out_tree_piece.get_node("b1"))
Exemplo n.º 3
0
def test_tgt_decomposition__general_case_2(in_tree_piece):
    out_tree_piece = datastructures.Graph.build_from_edge_label_tuples(
        [("a1", "b2"), ("a1", "b3")]
    )

    tree_1, graph, tree_2 = operations.calculate_tgt_decomposition(
        datastructures.Graph.union([in_tree_piece, out_tree_piece])
    )

    assert tree_1 == datastructures.Tree(in_tree_piece, in_tree_piece.get_node("a1"))
    assert graph is None
    assert tree_2 == datastructures.Tree(out_tree_piece, out_tree_piece.get_node("a1"))
Exemplo n.º 4
0
def tree_2():
    graph = datastructures.Graph.build_from_edge_label_tuples([
        ("a", "b"),
        ("b", "c1"),
        ("c1", "c2"),
        ("c2", "c3"),
        ("b", "d"),
        ("d", "e1"),
        ("e1", "e2"),
        ("e2", "e3"),
        ("d", "f"),
    ])
    return datastructures.Tree(graph, graph.get_node("a"))
Exemplo n.º 5
0
def tree_1():
    graph = datastructures.Graph.build_from_edge_label_tuples([("a", "b"),
                                                               ("b", "c"),
                                                               ("c", "d"),
                                                               ("b", "e")])
    return datastructures.Tree(graph, graph.get_node("a"))