



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Graph G = (V, E)
Figure 1: Example to illustrate graph terminology
“Explore a graph”, e.g.:
There are many.
Consider a 2 × 2 ×2 Rubik’s cube
Configuration Graph:
Diameter (“God’s Number”) 11 for 2 × 2 × 2, 20 for 3 × 3 × 3, Θ(n^2 / lg n) for n × n × n [Demaine, Demaine, Eisenstat Lubiw Winslow 2011]
... “breadth-
possible first moves reachable in two steps but not one
“hardest configs” solved
In other words, this is method for implicit graphs
Explore graph level by level from s
Figure 3: Illustrating Breadth-First Search
BFS (V,Adj,s): See CLRS for queue-based implementation level = { s: 0 } parent = {s : None } i = 1 frontier = [s] # previous level, i − 1 while frontier: next = [ ] # next level, i for u in frontier: for v in Adj [u]: if v not in level: # not yet seen level[v] = i ] = level[u] + 1 parent[v] = u next.append(v) frontier = next i + =
a (^) s d f
z x c v
(^1 0 2 )
2 1 2 3
level 1 level 0
level 2 level 3
frontier 0 = {s} frontier 1 = {a, x} frontier 2 = {z, d, c} frontier 3 = {f, v} (not x, c, d)
Figure 4: Breadth-First Search Frontier
MIT OpenCourseWare http://ocw.mit.edu
Fall 2011
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.