-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff01c1e
Showing
129 changed files
with
34,322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 58919a43cbfd5a67cde2b6c320766ddc | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|:sparkles:| Construct | ||
========================= | ||
|
||
Construct Binary Tree from list. | ||
|
||
.. list-table:: Binary Tree Construct Methods | ||
:widths: 30 40 30 | ||
:header-rows: 1 | ||
|
||
* - Construct Binary Tree from | ||
- Using heapq structure | ||
- Add node attributes | ||
* - List | ||
- `list_to_binarytree` | ||
- No | ||
|
||
.. automodule:: bigtree.binarytree.construct | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|:sparkles:| Construct | ||
========================= | ||
|
||
Construct Directed Acyclic Graph (DAG) from list, dictionary, and pandas DataFrame. | ||
|
||
.. list-table:: DAG Construct Methods | ||
:widths: 30 40 30 | ||
:header-rows: 1 | ||
|
||
* - Construct DAG from | ||
- Using parent-child relation | ||
- Add node attributes | ||
* - List | ||
- `list_to_dag` | ||
- No | ||
* - Dictionary | ||
- `dict_to_dag` | ||
- Yes | ||
* - DataFrame | ||
- `dataframe_to_dag` | ||
- Yes | ||
|
||
These functions are not standalone functions. | ||
Under the hood, they have the following dependency, | ||
|
||
.. image:: https://github.com/kayjan/bigtree/raw/master/assets/dag_construct.png | ||
:target: https://github.com/kayjan/bigtree/raw/master/assets/dag_construct.png | ||
:alt: DAG Constructor Dependency Diagram | ||
|
||
.. automodule:: bigtree.dag.construct | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|:hammer:| Export | ||
=================== | ||
|
||
Export Directed Acyclic Graph (DAG) to list, dictionary, and pandas DataFrame. | ||
|
||
.. list-table:: DAG Export Methods | ||
:widths: 40 25 30 | ||
:header-rows: 1 | ||
|
||
* - Export DAG to | ||
- Method | ||
- Extract node attributes | ||
* - List | ||
- `dag_to_list` | ||
- No | ||
* - Dictionary | ||
- `dag_to_dict` | ||
- Yes with `attr_dict` or `all_attrs` | ||
* - DataFrame | ||
- `dag_to_dataframe` | ||
- Yes with `attr_dict` or `all_attrs` | ||
* - Dot (for .dot, .png, .svg, .jpeg, etc.) | ||
- `dag_to_dot` | ||
- No | ||
|
||
.. automodule:: bigtree.dag.export | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|:seedling:| BaseNode | ||
===================== | ||
|
||
.. automodule:: bigtree.node.basenode | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|:herb:| BinaryNode | ||
===================== | ||
|
||
.. automodule:: bigtree.node.binarynode | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|:blossom:| DAGNode | ||
===================== | ||
|
||
.. automodule:: bigtree.node.dagnode | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|:hibiscus:| Node | ||
===================== | ||
|
||
.. automodule:: bigtree.node.node | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
|:sparkles:| Construct | ||
========================= | ||
|
||
Construct Tree from list, dictionary, and pandas DataFrame. | ||
|
||
To decide which method to use, consider your data type and data values. | ||
|
||
.. list-table:: Tree Construct Methods | ||
:widths: 35 30 50 40 | ||
:header-rows: 1 | ||
|
||
* - Construct Tree from | ||
- Using full path | ||
- Using parent-child relation | ||
- Add node attributes | ||
* - String | ||
- `str_to_tree` | ||
- NA | ||
- No | ||
* - List | ||
- `list_to_tree` | ||
- `list_to_tree_by_relation` | ||
- No | ||
* - Dictionary | ||
- `dict_to_tree` | ||
- `nested_dict_to_tree` | ||
- Yes | ||
* - DataFrame | ||
- `dataframe_to_tree` | ||
- `dataframe_to_tree_by_relation` | ||
- Yes | ||
|
||
|
||
To add attributes to existing tree, | ||
|
||
.. list-table:: Tree Add Attributes Methods | ||
:widths: 30 40 30 | ||
:header-rows: 1 | ||
|
||
* - Add attributes from | ||
- Using full path | ||
- Using node name | ||
* - String | ||
- `add_path_to_tree` | ||
- NA | ||
* - Dictionary | ||
- `add_dict_to_tree_by_path` | ||
- `add_dict_to_tree_by_name` | ||
* - DataFrame | ||
- `add_dataframe_to_tree_by_path` | ||
- `add_dataframe_to_tree_by_name` | ||
|
||
.. note:: | ||
| If attributes are added to existing tree using **full path**, paths that previously did not exist will be added. | ||
| If attributes are added to existing tree using **node name**, names that previously did not exist will not be created. | ||
These functions are not standalone functions. | ||
Under the hood, they have the following dependency, | ||
|
||
.. image:: https://github.com/kayjan/bigtree/raw/master/assets/tree_construct.png | ||
:target: https://github.com/kayjan/bigtree/raw/master/assets/tree_construct.png | ||
:alt: Tree Constructor Dependency Diagram | ||
|
||
.. automodule:: bigtree.tree.construct | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|:hammer:| Export | ||
=================== | ||
|
||
Export Tree to list, dictionary, and pandas DataFrame. | ||
|
||
.. list-table:: Tree Export Methods | ||
:widths: 40 30 | ||
:header-rows: 1 | ||
|
||
* - Export Tree to | ||
- Method | ||
* - Command Line / Others | ||
- `print_tree`, `yield_tree` | ||
* - Dictionary | ||
- `tree_to_dict`, `tree_to_nested_dict` | ||
* - DataFrame | ||
- `tree_to_dataframe` | ||
* - Dot (for .dot, .png, .svg, .jpeg, etc.) | ||
- `tree_to_dot` | ||
* - Pillow (for .png, .jpg, .jpeg, etc.) | ||
- `tree_to_pillow` | ||
* - Mermaid Markdown (for .md) | ||
- `tree_to_mermaid` | ||
|
||
While exporting to another data type, methods can take in arguments to determine what information to extract. | ||
|
||
.. list-table:: Tree Export Customizations | ||
:widths: 40 30 30 30 30 30 | ||
:header-rows: 1 | ||
|
||
* - Method | ||
- Extract node attributes | ||
- Specify maximum depth | ||
- Skip depth | ||
- Extract leaves only | ||
- Others | ||
* - `print_tree` | ||
- Yes with `attr_list` or `all_attrs` | ||
- Yes with `max_depth` | ||
- No, but can specify subtree | ||
- No | ||
- Tree style | ||
* - `yield_tree` | ||
- No, returns node | ||
- Yes with `max_depth` | ||
- No, but can specify subtree | ||
- No | ||
- Tree style | ||
* - `tree_to_dict` | ||
- Yes with `attr_dict` or `all_attrs` | ||
- Yes with `max_depth` | ||
- Yes with `skip_depth` | ||
- Yes with `leaf_only` | ||
- Dict key for parent | ||
* - `tree_to_nested_dict` | ||
- Yes with `attr_dict` or `all_attrs` | ||
- Yes with `max_depth` | ||
- No | ||
- No | ||
- Dict key for node name and node children | ||
* - `tree_to_dataframe` | ||
- Yes with `attr_dict` or `all_attrs` | ||
- Yes with `max_depth` | ||
- Yes with `skip_depth` | ||
- Yes with `leaf_only` | ||
- Column name for path, node name, node parent | ||
* - `tree_to_dot` | ||
- No | ||
- No | ||
- No | ||
- No | ||
- Graph attributes, background, node, edge colour, etc. | ||
* - `tree_to_pillow` | ||
- No | ||
- Yes, using keyword arguments similar to `yield_tree` | ||
- No | ||
- No | ||
- Font (family, size, colour), background colour, etc. | ||
* - `tree_to_mermaid` | ||
- No | ||
- Yes, using keyword arguments similar to `yield_tree` | ||
- No | ||
- No | ||
- Node shape, node fill, edge arrow, edge label etc. | ||
|
||
.. automodule:: bigtree.tree.export | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|:wrench:| Helper | ||
=================== | ||
|
||
Helper functions that can come in handy. | ||
|
||
.. automodule:: bigtree.tree.helper | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|:memo:| Modify | ||
=================== | ||
|
||
Shift or copy nodes within same tree or between two trees using | ||
`from_paths` (list of paths) and `to_paths` (list of paths). | ||
|
||
There are several configurations available for more customization | ||
|
||
- `skippable`: Skip shifting/copying of nodes if from_path cannot be found, defaults to False (from node must be found) | ||
- `overriding`: Override existing node if it exists, defaults to False (to node must not exist) | ||
- `merge_children`: Merge children and remove intermediate parent node, defaults to False (children are not merged) | ||
- `merge_leaves`: Merge leaves and remove all intermediate nodes, defaults to False (leaves are not merged) | ||
- `delete_children`: Shift/copy node only and delete its children, defaults to False (nodes are shifted/copied together with children) | ||
|
||
.. note:: `merge_children` and `merge_leaves` cannot be simultaneously set to `True` | ||
|
||
.. note:: Error will always be thrown if multiple from-nodes are found, paths in `from_paths` must be unique. | ||
|
||
Tree Modification Illustration | ||
---------------------------------- | ||
|
||
.. image:: https://github.com/kayjan/bigtree/raw/master/assets/modify_shift_and_copy.png | ||
:target: https://github.com/kayjan/bigtree/raw/master/assets/modify_shift_and_copy.png | ||
:width: 80% | ||
:align: center | ||
:alt: Shift and Copy Example | ||
|
||
.. list-table:: Sample Tree Modification (Shift, Copy, Delete) | ||
:widths: 20 20 20 50 | ||
:header-rows: 1 | ||
|
||
* - Setting | ||
- Sample path in `from_paths` | ||
- Sample path in `to_paths` | ||
- Description | ||
* - Default | ||
- "/a/c" | ||
- "/a/b/c" | ||
- Shift/copy node `c` | ||
* - Default | ||
- "/c" | ||
- "/a/b/c" | ||
- Shift/copy node `c` | ||
* - Default | ||
- "c" | ||
- "/a/b/c" | ||
- Shift/copy node `c` | ||
* - Default | ||
- "/a/e" | ||
- None | ||
- Delete node `e` | ||
* - skippable | ||
- "/a/c" | ||
- "/a/b/c" | ||
- Shift/copy node `c`, skip if "/a/c" cannot be found | ||
|
||
.. image:: https://github.com/kayjan/bigtree/raw/master/assets/modify_advanced.png | ||
:target: https://github.com/kayjan/bigtree/raw/master/assets/modify_advanced.png | ||
:alt: Advanced Shift Example | ||
|
||
.. list-table:: Sample Tree Modification (Advanced) | ||
:widths: 20 20 20 50 | ||
:header-rows: 1 | ||
|
||
* - Setting | ||
- Sample path in `from_paths` | ||
- Sample path in `to_paths` | ||
- Description | ||
* - overriding | ||
- "a/b/c" | ||
- "a/d/c" | ||
- Shift/copy node `c`, override if "a/d/c" exists | ||
* - merge_children | ||
- "a/b/c" | ||
- "a/d/c" | ||
- | **If path not present**: Shift/copy children of node `c` to be children of node `d`, removing node `c` | ||
| **If path present**: Shift/copy children of node `c` to be merged with existing "a/d/c" children | ||
* - merge_children + overriding | ||
- "a/b/c" | ||
- "a/d/c" | ||
- | **If path not present**: Behaves like merge_children | ||
| **If path present**: Behaves like overriding | ||
* - merge_leaves | ||
- "a/b/c" | ||
- "a/d/c" | ||
- | **If path not present**: Shift/copy leaves of node `c` to be children of node `d` | ||
| **If path present**: Shift/copy leaves of node `c` to be merged with existing "a/d/c" children | ||
* - merge_leaves + overriding | ||
- "a/b/c" | ||
- "a/d/c" | ||
- | **If path not present**: Behaves like merge_leaves | ||
| **If path present**: Behaves like overriding, but original node `c` remains | ||
* - delete_children | ||
- "a/b" | ||
- "a/d/b" | ||
- Shift/copy node `b` only without any node `b` children | ||
|
||
.. automodule:: bigtree.tree.modify | ||
:members: | ||
:show-inheritance: |
Oops, something went wrong.