Lecture 12 CSE 331 Sep 30, 2009
Announcements Final exam: Dec 16, 11:45am-2:45pm, NSC 210 HW 2 solutions at the end of the lecture Mid term: Oct 16, in class
Breath First Search (BFS) Is s connected to t? Build layers of vertices connected to s L 0 = {s} Assume L 0,..,L j have been constructed L j+1 set of vertices not chosen yet but are connected to L j Stop when new layer is empty L j : all nodes at distance j from s
BFS Tree BFS naturally defines a tree rooted at s L j forms the jth “level” in the tree u in L j+1 is child of v in L j from which it was “discovered” L0L0 L1L L2L2 6 6 L3L3 Add non- tree edges
Connected Component Connected component (of s) is the set of all nodes connected to s
Today’s agenda Every edge is between consecutive layers Depth First Search
A DFS run