(nid, prefix='', is_last=True)
| 491 | default_icon = '◆' |
| 492 | |
| 493 | def print_tree(nid, prefix='', is_last=True): |
| 494 | icon = icons.get(nid, default_icon) |
| 495 | if not prefix: |
| 496 | print(f' {icon} {nid}') |
| 497 | else: |
| 498 | connector = '└── ' if is_last else '├── ' |
| 499 | print(f' {prefix}{connector}{icon} {nid}') |
| 500 | child_list = children.get(nid, []) |
| 501 | for i, cid in enumerate(child_list): |
| 502 | ext = ' ' if is_last else '│ ' |
| 503 | print_tree(cid, prefix + ext, i == len(child_list) - 1) |
| 504 | |
| 505 | print_tree('root') |
| 506 |