🏗️ ΘρϵηΠατπ🚧 (under construction)

BFS Example

Assuming that we push characters onto the frontier in alphabetical order (A before B ...), specify the order of the nodes that would be explored by BFS.

  • If we use the above source code
  • If we don't use the node_has_been_visited check

Assume that S is the initial node, while G is the goal node.

Breadth First Search is Correct
Given any graph, breadth first search traverses all nodes in the graph
Enqueued
Suppose that v is a vertex in a graph being explored by BFS, then we say that v is enqueued, if it has been added to the queue.
Expanded
Suppose that v is a vertex in a graph being explored by BFS, then we say that v is expanded if all of it's successors have been added to the queue.
Depth
Suppose that v,w are two connected vertices in a graph, then we say that the depth of w with respect to v is the length of the shortest path from v to w in the graph, and we notate it by depth(v,w)
Found
We say that a specific vertex v is said to be found if it has been expanded.
BFS Searches Less Deep Vertices First
Let s be the initial vertex that BFS is called on, and let us define the set Xk:={vV:depth(s,v)=k}, then for any i<jN0 BFS will expand everything in Xi before it will expand anything in Xj
BFS Expands by Depth Layer
Specifically given the following sequence of sets: X0,X1,X2, BFS will expand every node in the previous set before expanding any vertex in the next set.
BFS Expands All Enqueued Vertices
Suppose that the queue consists of some finite collection of vertices V, then BFS will expand every vertex in this set
BFS is Complete
Suppose that we have a potentially infinite graph G=(V,E) with an maximum branching factor of b. Given two specific vertices s,gV denoted as the start state and the goal state respectively if there exists a path from s to g then if BFS is initialized on s, it will expand g in a finite number of iterations.

Consider a graph that has one root node, and then infinitely many child nodes, and then in the third layer all the child nodes lead to a singlar goal node. BFS will get stuck on this graph because it will be spending an infinite amount of time adding every child of the root node to the queue, and thus will never terminate even though there is a trivial path from the root to the goal node.

BFS Time Complexity
Suppose that BFS is run on a potentially infinite graph that has maximum branching factor b, then given two connected nodes s,g, such that d=depth(s,g) , then the number of steps taken by BFS by starting it on s until it expands g is O(bb+1)
BFS Space Complexity
The space complexity of BFS is given by O(bd+1)

Note that if you run BFS on a graph with edge weights hoping that it will produce a minimum cost solution to the goal node, it will not.

BFS Cost Optimal?
Suppose that there is a solution path within a finite search space, is it true that BFS is cost-optimal if given any level of the search tree, all step costs are greater than the step costs in the previous level.