Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 13 CSE 331 Oct 2, 2009. Announcements Mid term in < 2 weeks Graded HW2 at the END of the class.

Similar presentations


Presentation on theme: "Lecture 13 CSE 331 Oct 2, 2009. Announcements Mid term in < 2 weeks Graded HW2 at the END of the class."— Presentation transcript:

1 Lecture 13 CSE 331 Oct 2, 2009

2 Announcements Mid term in < 2 weeks Graded HW2 at the END of the class

3 Breadth 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

4 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” 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 1 1 2 2 3 3 L0L0 L1L1 4 4 5 5 7 7 8 8 L2L2 6 6 L3L3

5 Questions?

6 A theory workshop this weekend http://www.cse.buffalo.edu/events/theory-III/

7 Proofs in the lectures Mostly proof ideas from now on Read the book for the formal proofs Homeworks will still require formal proofs

8 Connected Component Connected component (of s) is the set of all nodes connected to s

9 Computing Connected Component Start with R = {s} While exists (u,v) edge v not in R and u in R Add v to R Output R

10 Today’s agenda If w is in R iff w is connected to s Depth First Search Computing all connected components

11 How is BFS related to this algo?

12 A DFS run 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 1 1 2 2 4 4 5 5 6 6 3 3 8 8 7 7 Every non- tree edge is between a node and its ancestor DFS tree

13 Questions?

14 Connected components are disjoint Either Connected components of s and t are the same or are disjoint Algorithm to compute ALL the connected components? Run BFS on some node s. Then run BFS on t that is not connected to s


Download ppt "Lecture 13 CSE 331 Oct 2, 2009. Announcements Mid term in < 2 weeks Graded HW2 at the END of the class."

Similar presentations


Ads by Google