Mobile robot motion planning --- basic knowledge based on graph search --- breadth-first traversal and depth-first traversal

Mobile robot motion planning --- basic knowledge based on graph search --- breadth-first traversal and depth-first traversal

The direction of graph search optimization is :
according to what rules to visit nodes, according to what rules to pop up nodes, so that we can find the termination node as quickly as possible.

Graph traversal algorithm:

  • breadth first search
  • depth-first search

Breadth-first search follows the first-in-first-out principle and maintains a queue.
insert image description here
Pop elements are always popped from the head of the queue.
Depth-first search follows the last-in-first-out principle. It maintains a stack
insert image description here
pop from the top, and finally Those that enter the container are the first to be ejected

Breadth First Search (BFS)

Features: Each time the shallowest node is popped up, a queue structure is maintained,
so the search process is carried out layer by layer.
insert image description here
The most intuitive understanding is to proceed layer by layer.

Splitting of BFS steps :
insert image description here
such a graph structure, the steps of BFS are as follows

The initialization container is empty, first put the start node S
insert image description here
and pop up (visit) the S node, and the container becomes empty again.
insert image description here
Expand S,
as can be seen from the figure, S can be expanded by d\e\
insert image description here
p According to the defined rules, the expanded nodes are put into the container in a regular order. The
insert image description here
difference from DFS is that the nodes are popped up from below, the p node is popped up first,
insert image description here
and then the loop is performed
insert image description here
. Finally, the terminal node is found, the loop is ended, and the graph search is completed.

Depth First Search (DFS)

Features: The node that is popped up each time is the deepest node, and a stack is maintained. The
insert image description here
intuitive understanding is that a branch is never taken to the end

Splitting of DFS steps:
Note—the structure of a stack is maintained,
insert image description here
such a graph structure, and the steps of DFS are as follows

The initialization container is empty, first put the start node S
insert image description here
and pop up (visit) the S node, and the container becomes empty again.
insert image description here
Expand S,
as can be seen from the figure, S can be expanded by d\e\
insert image description here
p According to the defined rules, the expanded nodes are put into the container in a regular order,
insert image description here
and then the depth-first search pops up the container, and the last-entered node (the deepest level), that is, the d node,
then expands the d node, and puts the expanded node into The container, and then pop up the popped node, then expand, and then put in the loop operation

insert image description here
Finally find the terminal node, end the loop, and complete the graph search.

BFS vs DFS

From the final traversal result graph, you can see the difference between the two
insert image description here

  • BFS expands from the start node layer by layer until it reaches the target node, and then backtracks to find the shortest path.
  • DFS goes all the way from the start node to the end to find the target node.

From the results, the path found by BFS is the shortest

Therefore, for mobile robots, when doing path planning to find the shortest path, the best way to do it is BFS

Guess you like

Origin blog.csdn.net/qq_32761549/article/details/130648120