возможно, вы можете начать с модуля networkx
установить networkx : pip install networkx
установите matplotlib : pip install matplotlib
программу
import networkx as nx
import matplotlib.pyplot as plt
if __name__ == "__main__":
# define DiGraph
tree = nx.DiGraph()
# add node
tree.add_node("root")
tree.add_node("AB")
tree.add_node("CD")
tree.add_node("ABC")
tree.add_node("CBA")
tree.add_node("CDE")
tree.add_node("FGH")
# add connection edge
tree.add_edge("root","AB")
tree.add_edge("root","CD")
tree.add_edge("AB","ABC")
tree.add_edge("AB","CBA")
tree.add_edge("CD","CDE")
tree.add_edge("CD","FGH")
# output the tree
nx.draw(tree,with_labels = True)
plt.show()