1 / 17

Implementing Breadth-First Search: A MATLAB Wavefront Planner on a Grid

This guide explores a MATLAB implementation of the Breadth-First Search (BFS) algorithm tailored for a grid environment. The BFS Wavefront planner operates by labeling grid cells with values where '0' represents unchecked areas, '1' indicates obstacles, and '2' marks the starting cell. The approach uses 4-Point and 8-Point connectivity to expand the wavefront from the starting cell, searching for the shortest path back to the goal. Key concepts include queue management and iterative expansion until the goal is reached.

isaura
Download Presentation

Implementing Breadth-First Search: A MATLAB Wavefront Planner on a Grid

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Breadth-First Search David Johnson

  2. Today • Look at one version of Breadth-first search on a grid • Develop Matlab version of BFS

  3. Wavefront planner • Use BFS on a grid • Label cells with values • Zero means unchecked • 1 is obstacle • Set start cell to 2 • Expand from start • Add +1 to neighbors of current wavefront • Use gradient descent to search from goal to start

  4. Representations: A Grid • Distance is reduced to discrete steps • For simplicity, we’ll assume distance is uniform • Direction is now limited from one adjacent cell to another

  5. Representations: Connectivity • 8-Point Connectivity • (chessboard metric) • 4-Point Connectivity • (Manhattan metric)

  6. The Wavefront Planner: Setup

  7. The Wavefront in Action (Part 1) • Starting with the goal, set all adjacent cells with “0” to the current cell + 1 • 4-Point Connectivity or 8-Point Connectivity? • Your Choice. We’ll use 8-Point Connectivity in our example

  8. The Wavefront in Action (Part 2) • Now repeat with the modified cells • This will be repeated until goal is reached • 0’s will only remain when regions are unreachable

  9. The Wavefront in Action (Part 3) • Repeat again...

  10. The Wavefront in Action (Part 4) • And again...

  11. The Wavefront in Action (Part 5) • And again until...

  12. The Wavefront in Action (Done) • You’re done

  13. The Wavefront • To find the shortest path simply always move toward a cell with a lower number • The numbers generated by the Wavefront planner are roughly proportional to their distance from the goal Two possible shortest paths shown

  14. Developing the Breadth-First Search Algorithm • Store the list of graph vertices under consideration (the wavefront). • Store indices rather than the whole vertex • Look for successors of the wavefront • Put the successors back on the wavefront • Where should they go? 1st gen 2nd gen 3rd gen

  15. Queue • A queue is a datastructure where you can • Add elements to the back • Take an element off the front • First in the queue is first out • FIFO

  16. Queue • Matlab can easily make a queue • Pop element from front element = wavefront(1) wavefront = wavefront(2:end) • Add to end wavefront = [wavefrontnewelement]

  17. Matlab • Develop BFS in Matlab

More Related