@@ -13,7 +13,9 @@ Related Links:
1313- [ Issues] ( https://github.com/kayjan/bigtree/issues )
1414- [ Discussions] ( https://github.com/kayjan/bigtree/discussions )
1515- [ Contributing] ( https://bigtree.readthedocs.io/en/latest/others/contributing.html )
16- - [ PyPI] ( https://pypi.org/project/bigtree/ )
16+ - Package
17+ - [ PyPI] ( https://pypi.org/project/bigtree/ )
18+ - [ Conda] ( https://anaconda.org/conda-forge/bigtree )
1719- Articles
1820 - [ Python Tree Implementation with BigTree] ( https://towardsdatascience.com/python-tree-implementation-with-bigtree-13cdabd77adc#245a-94ae81f0b3f1 )
1921 - [ The Reingold Tilford Algorithm Explained, with Walkthrough] ( https://towardsdatascience.com/reingold-tilford-algorithm-explained-with-walkthrough-be5810e8ed93?sk=2db8e10398cee76c486c4b06b0b33322 )
@@ -99,6 +101,10 @@ For **Directed Acyclic Graph (DAG)** implementation, there are 4 main components
99101
100102## Installation
101103
104+ There are two ways to install ` bigtree ` , with pip (from PyPI) or conda (from conda-forge).
105+
106+ ### a) Installation with pip (preferred)
107+
102108To install ` bigtree ` , run the following line in command prompt:
103109
104110``` shell
@@ -127,6 +133,14 @@ Alternatively, install all optional dependencies with the following line in comm
127133$ pip install ' bigtree[all]'
128134```
129135
136+ ### b) Installation with conda
137+
138+ To install ` bigtree ` with conda, run the following line in command prompt:
139+
140+ ``` shell
141+ $ conda install -c conda-forge bigtree
142+ ```
143+
130144----
131145
132146## Tree Demonstration
@@ -500,10 +514,10 @@ root.show()
500514
501515### Modify Tree
502516
503- Nodes can be shifted or copied from one path to another.
517+ Nodes can be shifted (with or without replacement) or copied from one path to another.
504518
505519``` python
506- from bigtree import Node, shift_nodes
520+ from bigtree import Node, shift_nodes, shift_and_replace_nodes
507521
508522root = Node(" a" )
509523b = Node(" b" , parent = root)
@@ -526,6 +540,17 @@ root.show()
526540# │ └── c
527541# └── dummy
528542# └── d
543+
544+ shift_and_replace_nodes(
545+ tree = root,
546+ from_paths = [" a/dummy" ],
547+ to_paths = [" a/b/c" ],
548+ )
549+ root.show()
550+ # a
551+ # └── b
552+ # └── dummy
553+ # └── d
529554```
530555
531556``` python
@@ -556,10 +581,10 @@ root.show()
556581# └── d
557582```
558583
559- Nodes can also be copied between two different trees.
584+ Nodes can also be copied (with or without replacement) between two different trees.
560585
561586``` python
562- from bigtree import Node, copy_nodes_from_tree_to_tree
587+ from bigtree import Node, copy_nodes_from_tree_to_tree, copy_and_replace_nodes_from_tree_to_tree
563588root = Node(" a" )
564589b = Node(" b" , parent = root)
565590c = Node(" c" , parent = root)
@@ -583,6 +608,28 @@ root_other.show()
583608# │ └── c
584609# └── dummy
585610# └── d
611+
612+ root_other = Node(" aa" )
613+ b = Node(" b" , parent = root_other)
614+ c = Node(" c" , parent = b)
615+ d = Node(" d" , parent = root_other)
616+ root_other.show()
617+ # aa
618+ # ├── b
619+ # │ └── c
620+ # └── d
621+
622+ copy_and_replace_nodes_from_tree_to_tree(
623+ from_tree = root,
624+ to_tree = root_other,
625+ from_paths = [" a/b" , " a/c" ],
626+ to_paths = [" aa/b/c" , " aa/d" ],
627+ )
628+ root_other.show()
629+ # aa
630+ # ├── b
631+ # │ └── b
632+ # └── c
586633```
587634
588635### Tree Search
@@ -622,6 +669,7 @@ find_attr(root, "age", 40)
622669```
623670
624671To find multiple nodes,
672+
625673``` python
626674from bigtree import Node, findall, find_names, find_relative_path, find_paths, find_attrs
627675root = Node(" a" , age = 90 )
0 commit comments