Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.33 KB

README.md

File metadata and controls

61 lines (51 loc) · 1.33 KB

python-graphs

github action status

Install

pip install hexlet-graphs

Usage example

from hexlet.graphs import build_tree_from_leaf, make_joints, sort_tree

tree = [
    "B",
    [
        ["D"],
        [
            "A",
            [
                [
                    "C",
                    [
                        ["F"],
                        ["E"],
                    ],
                ],
            ],
        ],
    ],
]

joints = make_joints(tree)
transformed = build_tree_from_leaf(joints, "C")
# ['C', [
#     ['F'],
#     ['E'],
#     ['A', [
#         ['B', [
#             ['D'],
#         ]],
#     ]],
# ]]

sort_tree(transformed)
# ['C', [
#     ['A', [
#         ['B', [
#             ['D'],
#         ]],
#     ]],
#     ['E'],
#     ['F'],
# ]]

Hexlet Ltd. logo

This repository is created and maintained by the team and the community of Hexlet, an educational project. Read more about Hexlet.