Python

treelib


參考資訊:
1. treelib
2. Graphviz

程式碼

from treelib import Node, Tree

tree = Tree()
tree.create_node("Harry", "harry")  # root node
tree.create_node("Jane", "jane", parent="harry")
tree.create_node("Bill", "bill", parent="harry")
tree.create_node("Diane", "diane", parent="jane")
tree.create_node("Mary", "mary", parent="diane")
tree.create_node("Mark", "mark", parent="jane")
tree.show()
tree.to_graphviz()

輸出

Harry
├── Bill
└── Jane
    ├── Diane
    │   └── Mary
    └── Mark

把graphviz資料貼到online顯示


返回上一頁