BreadthFirst Searches Introduction to AI BreadthFirst Search Using
Breadth-First Searches Introduction to AI
Breadth-First Search • Using a breadth-first strategy we expand the root level first and then we expand all those nodes (i. e. those at level 1) before we expand any nodes at level 2. • Or to put it another way, all nodes at level d are expanded before any nodes at level d+1. Function BREADTH-FIRST-SEARCH(problem) returns a solution or failure Return GENERAL-SEARCH(problem, ENQUEUE-AT-END) • To illustrate this search pattern we will be using an example node set containing 26 nodes (states). The initial state will be node A, and the goal state is node L. Press space to see the example node set.
The example node set Initial state B A C D E F Goal state G H I J K L M N O P Q S T U V W X Y Z R Press space to see a BFS of the example node set
Node B isbacktrack expanded then removed We The then search then moves to expand to thenode firstfrom C, nodethe queue. revealed nodes arecontinue. added and in the. The queue. process Press continues. space Press to spaceto the END of the queue. Press space. B G H Q R C I S A Node A is removed from This We begin node is with then our expanded initialthe state: toqueue. reveal the Each node revealed node is added to the END space of the further labeled(unexpanded) A. Press spacenodes. continue Press queue. Press space to continue the search. D J T K U E L F M N O P Node L is located and the search returns a solution. Press space to end. Press space to begin continue thethe search Size of Queue: 010 987651 Queue: Empty A J, B, C, D, E, F, G, H, I, J, K, L, K, G, C, F, M, D, E, H, K, I, L, J, G, L, H, D, F, M, E, I, N, L, K, J, M, G, H, E, F, I, O, N, M, K, L, J, G, H, F I, N, P, O, K, M, J, L, N, H I, O, Q, P, K, L, M, JO, N, P, R, Q, LP, M, O, N, Q, S, R, Q, N O, P, R, T, S, R Q PU ST Nodes expanded: 11 9876543210 10 Current. FINISHED Action: Backtracking Expanding SEARCH Current level: 210 n/a BREADTH-FIRST SEARCH PATTERN
- Slides: 4