Skip to content

Commit

Permalink
Add tree search algo aliases for walking.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Jul 4, 2023
1 parent aaf020f commit 7870233
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions order/unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,10 @@ def _walk(self, next_fn, algo="bfs", depth_first=False, include_self=False):
algo = "dfs"

# check the algo
if algo == "dfs":
if algo == "dfs" or algo == "dfs_pre":
algo = "dfs_preorder"
elif algo == "dfs_post":
algo = "dfs_postorder"
known_algos = ["bfs", "dfs_preorder", "dfs_postorder"]
if algo not in known_algos:
_known_algos = ", ".join(map("'{}'".format, known_algos))
Expand Down Expand Up @@ -899,9 +901,11 @@ def walk(self, algo="bfs", depth_first=False, include_self=False):
`info <https://en.wikipedia.org/wiki/Tree_traversal>`__):
- ``"bfs"``: Breadth-first search.
- ``"dfs"``: Alias for ``"dfs_preorder"``.
- ``"dfs_preorder"``: Pre-order depth-first search.
- ``"dfs_postorder"``: Post-order depth-first search.
- ``"dfs"``: Alias for ``"dfs_preorder"``.
- ``"dfs_pre"``: Alias for ``"dfs_preorder"``.
- ``"dfs_post"``: Alias for ``"dfs_postorder"``.
When *include_self* is *True*, this {singular} instance is yielded as well with a
depth of 0.
Expand Down Expand Up @@ -1178,9 +1182,11 @@ def walk(self, algo="bfs", depth_first=False, include_self=False): # noqa: F811
`info <https://en.wikipedia.org/wiki/Tree_traversal>`__):
- ``"bfs"``: Breadth-first search.
- ``"dfs"``: Alias for ``"dfs_preorder"``.
- ``"dfs_preorder"``: Pre-order depth-first search.
- ``"dfs_postorder"``: Post-order depth-first search.
- ``"dfs"``: Alias for ``"dfs_preorder"``.
- ``"dfs_pre"``: Alias for ``"dfs_preorder"``.
- ``"dfs_post"``: Alias for ``"dfs_postorder"``.
When *include_self* is *True*, this {singular} instance is yielded as well with
a depth of 0.
Expand Down

0 comments on commit 7870233

Please sign in to comment.