From 7870233b3d21afa303124b9d9e7a85ccf497de7a Mon Sep 17 00:00:00 2001 From: Marcel R Date: Tue, 4 Jul 2023 14:35:40 +0200 Subject: [PATCH] Add tree search algo aliases for walking. --- order/unique.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/order/unique.py b/order/unique.py index 7dbd32c..da24a6b 100644 --- a/order/unique.py +++ b/order/unique.py @@ -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)) @@ -899,9 +901,11 @@ def walk(self, algo="bfs", depth_first=False, include_self=False): `info `__): - ``"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. @@ -1178,9 +1182,11 @@ def walk(self, algo="bfs", depth_first=False, include_self=False): # noqa: F811 `info `__): - ``"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.