Skip to content

This Depth Fist Search Path Traversal algorithm traverses the whole paths from the leaf nodes to the root node.

Notifications You must be signed in to change notification settings

Strong-AI-Lab/Depth-First-Search-Path-Traversal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Depth First Search Path Traversal

Target

For the tree structure in the figure below, traverse and output the path from all leaf nodes to the root node.

The process of traversal

Given one example, starts from node e

:param start:
        eg: 'e'
:param child_father_dict:
        eg: {'e': {'b'}, 'b': {'a'}}
:return: all_path:
        eg: ['e', 'b', 'a']

Output

[[['h', 'd', 'a']], [['f', 'c', 'a'], ['f', 'b', 'a']], [['e', 'b', 'a']], [['g', 'c', 'a'], ['g', 'd', 'a']]]

Acknowledgement

深度搜索算法(python实现)获取所有叶子节点到根节点的路径

https://www.codeleading.com/article/21464801118/

Built With

  • Pandas - helper data manipulation library

About

This Depth Fist Search Path Traversal algorithm traverses the whole paths from the leaf nodes to the root node.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages