@@ -339,12 +339,12 @@ Construct nodes with attributes. *DataFrame* can contain either <mark>path colum
339
339
340
340
### 1. Print Tree
341
341
342
- After tree is constructed, it can be viewed by printing to console using ` show ` or ` hshow ` method directly,
343
- for vertical and horizontal orientation respectively.
344
- Alternatively, the ` print_tree ` or ` hprint_tree ` method can be used.
342
+ After tree is constructed, it can be viewed by printing to console using ` show ` , ` hshow ` , or ` vshow ` method directly,
343
+ for compact, horizontal, and vertical orientation respectively.
344
+ Alternatively, the ` print_tree ` , ` hprint_tree ` , or ` vprint_tree ` method can be used.
345
345
346
346
``` python hl_lines="8 15"
347
- from bigtree import Node, print_tree, hprint_tree
347
+ from bigtree import Node, print_tree, hprint_tree, vprint_tree
348
348
349
349
root = Node(" a" , alias = " alias-a" , age = 90 , gender = " F" )
350
350
b = Node(" b" , age = 65 , gender = " M" , parent = root)
@@ -363,17 +363,31 @@ hprint_tree(root) # (2)!
363
363
# ┌─ b ─┤
364
364
# ─ a ─┤ └─ e
365
365
# └─ c
366
+
367
+ vprint_tree(root) # (3)!
368
+ # ┌───┐
369
+ # │ a │
370
+ # └─┬─┘
371
+ # ┌────┴─────┐
372
+ # ┌─┴─┐ ┌─┴─┐
373
+ # │ b │ │ c │
374
+ # └─┬─┘ └───┘
375
+ # ┌──┴───┐
376
+ # ┌─┴─┐ ┌─┴─┐
377
+ # │ d │ │ e │
378
+ # └───┘ └───┘
366
379
```
367
380
368
381
1 . Alternatively, ` root.show() ` can be used
369
382
2 . Alternatively, ` root.hshow() ` can be used
383
+ 3 . Alternatively, ` root.vshow() ` can be used
370
384
371
385
Other customizations for printing are also available, such as:
372
386
373
387
- Printing alias instead of node name, if present
374
388
- Printing subtree
375
389
- Printing tree with attributes
376
- - Different built-in or custom style
390
+ - Different built-in or custom style and border style
377
391
378
392
=== "Alias"
379
393
```python hl_lines="1"
@@ -572,6 +586,7 @@ Below is the table of operations available to `BaseNode` and `Node` classes.
572
586
| -------------------------------------------------| ------------------------------------------------------------| --------------------------------------------|
573
587
| Visualize tree (only for ` Node ` ) | ` root.show() ` | None |
574
588
| Visualize tree (horizontally) (only for ` Node ` ) | ` root.hshow() ` | None |
589
+ | Visualize tree (vertically) (only for ` Node ` ) | ` root.vshow() ` | None |
575
590
| Get node information | ` root.describe(exclude_prefix="_") ` | [ ('name', 'a')] |
576
591
| Find path from one node to another | ` root.go_to(node_e) ` | [ Node(/a, ), Node(/a/b, ), Node(/a/b/e, )] |
577
592
| Add child to node | ` root.append(Node("j")) ` | None |
0 commit comments