Skip to content

Commit d96f672

Browse files
authored
Update docs (#374)
* docs: update docs and README * feat: allow method chaining, add .add/.extend method to DAGNode * test: add more test for coverage * test: add more test for coverage * docs: update README * docs: update README and docs
1 parent 76e8139 commit d96f672

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ For **Tree** implementation, there are 9 main components.
4949
4. Level-Order-Group Traversal
5050
5. ZigZag Traversal
5151
6. ZigZag-Group Traversal
52-
4. [** Parsing Tree**](https://bigtree.readthedocs.io/en/stable/bigtree/tree/parsing/)
52+
4. [**🧩 Parsing Tree**](https://bigtree.readthedocs.io/en/stable/bigtree/tree/parsing/)
5353
1. Get common ancestors between nodes
5454
2. Get path from one node to another node
5555
5. [**📝 Modifying Tree**](https://bigtree.readthedocs.io/en/stable/bigtree/tree/modify/)
@@ -104,7 +104,7 @@ For **Directed Acyclic Graph (DAG)** implementation, there are 4 main components
104104
3. From *pandas DataFrame*
105105
3. [**➰ Traversing DAG**](https://bigtree.readthedocs.io/en/stable/bigtree/utils/iterators/)
106106
1. Generic traversal method
107-
4. [** Parsing DAG**](https://bigtree.readthedocs.io/en/stable/bigtree/dag/parsing/)
107+
4. [**🧩 Parsing DAG**](https://bigtree.readthedocs.io/en/stable/bigtree/dag/parsing/)
108108
1. Get possible paths from one node to another node
109109
5. [**🔨 Exporting DAG**](https://bigtree.readthedocs.io/en/stable/bigtree/dag/export/)
110110
1. Export to *list*, *dictionary*, or *pandas DataFrame*

Diff for: docs/gettingstarted/demo/dag.md

+22-19
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ DAGNodes can be linked to each other in the following ways:
1515
- Using `parents` and `children` setter methods
1616
- Directly passing `parents` or `children` argument
1717
- Using bitshift operator with the convention `parent_node >> child_node` or `child_node << parent_node`
18+
- Using `.append(child)` or `.extend([child1, child2])` methods
1819

1920
```python hl_lines="5-8 10"
2021
from bigtree import DAGNode, dag_to_dot
@@ -113,26 +114,28 @@ node_a = dag.parents[0]
113114

114115
Below are the tables of attributes available to `DAGNode` class.
115116

116-
| Attributes wrt self | Code | Returns |
117-
|--------------------------------------|------------------|---------|
118-
| Check if root | `node_a.is_root` | True |
119-
| Check if leaf node | `dag.is_leaf` | False |
120-
| Get node name (only for `Node`) | `dag.node_name` | 'd' |
117+
| Attributes wrt self | Code | Returns |
118+
|---------------------------------|------------------|---------|
119+
| Check if root | `node_a.is_root` | True |
120+
| Check if leaf node | `dag.is_leaf` | False |
121+
| Get node name (only for `Node`) | `dag.node_name` | 'd' |
121122

122-
| Attributes wrt structure | Code | Returns |
123-
|------------------------------|-----------------------|----------------------------------------------------------------------|
124-
| Get child/children | `node_a.children` | (DAGNode(c, ), DAGNode(d, )) |
125-
| Get parents | `dag.parents` | (DAGNode(a, ), DAGNode(c, )) |
126-
| Get siblings | `dag.siblings` | (DAGNode(c, ),) |
127-
| Get ancestors | `dag.ancestors` | [DAGNode(a, ), DAGNode(b, ), DAGNode(c, )] |
128-
| Get descendants | `dag.descendants` | [DAGNode(e, )] |
123+
| Attributes wrt structure | Code | Returns |
124+
|--------------------------|--------------------|--------------------------------------------|
125+
| Get child/children | `node_a.children` | (DAGNode(c, ), DAGNode(d, )) |
126+
| Get parents | `dag.parents` | (DAGNode(a, ), DAGNode(c, )) |
127+
| Get siblings | `dag.siblings` | (DAGNode(c, ),) |
128+
| Get ancestors | `dag.ancestors` | [DAGNode(a, ), DAGNode(b, ), DAGNode(c, )] |
129+
| Get descendants | `dag.descendants` | [DAGNode(e, )] |
129130

130131
Below is the table of operations available to `DAGNode` class.
131132

132-
| Operations | Code | Returns |
133-
|---------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
134-
| Get node information | `dag.describe(exclude_prefix="_")` | [('name', 'd')] |
135-
| Find path(s) from one node to another | `node_a.go_to(dag)` | [[DAGNode(a, ), DAGNode(c, ), DAGNode(d, description=dag-tag)], [DAGNode(a, ), DAGNode(d, description=dag-tag)]] |
136-
| Set attribute(s) | `dag.set_attrs({"description": "dag-tag"})` | None |
137-
| Get attribute | `dag.get_attr("description")` | 'dag-tag' |
138-
| Copy DAG | `dag.copy()` | None |
133+
| Operations | Code | Returns |
134+
|---------------------------------------|-----------------------------------------------|------------------------------------------------------------------------------------------------------------------|
135+
| Get node information | `dag.describe(exclude_prefix="_")` | [('name', 'd')] |
136+
| Find path(s) from one node to another | `node_a.go_to(dag)` | [[DAGNode(a, ), DAGNode(c, ), DAGNode(d, description=dag-tag)], [DAGNode(a, ), DAGNode(d, description=dag-tag)]] |
137+
| Add child to node | `node_a.append(DAGNode("j"))` | DAGNode(a, ) |
138+
| Add multiple children to node | `node_a.extend([DAGNode("k"), DAGNode("l")])` | DAGNode(a, ) |
139+
| Set attribute(s) | `dag.set_attrs({"description": "dag-tag"})` | None |
140+
| Get attribute | `dag.get_attr("description")` | 'dag-tag' |
141+
| Copy DAG | `dag.copy()` | None |

Diff for: docs/gettingstarted/demo/tree.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ Below is the table of operations available to `BaseNode` and `Node` classes.
589589
| Visualize tree (vertically) (only for `Node`) | `root.vshow()` | None |
590590
| Get node information | `root.describe(exclude_prefix="_")` | [('name', 'a')] |
591591
| Find path from one node to another | `root.go_to(node_e)` | [Node(/a, ), Node(/a/b, ), Node(/a/b/e, )] |
592-
| Add child to node | `root.append(Node("j"))` | None |
593-
| Add multiple children to node | `root.extend([Node("k"), Node("l")])` | None |
592+
| Add child to node | `root.append(Node("j"))` | Node(/a, ) |
593+
| Add multiple children to node | `root.extend([Node("k"), Node("l")])` | Node(/a, ) |
594594
| Set attribute(s) | `root.set_attrs({"description": "root-tag"})` | None |
595595
| Get attribute | `root.get_attr("description")` | 'root-tag' |
596596
| Copy tree | `root.copy()` | None |

0 commit comments

Comments
 (0)