Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 13 CSE 331 Oct 1, 2012.

Similar presentations


Presentation on theme: "Lecture 13 CSE 331 Oct 1, 2012."— Presentation transcript:

1 Lecture 13 CSE 331 Oct 1, 2012

2 Reminders HW 2 ready for pickup MID TERM IN 2.5 WEEKS (in class)

3 Determining connectivity in graphs
s t Are s and t connected?

4 Brute-force algorithm
List all possible distinct vertex sequences between s and t n! such sequences Check if any is a path between s and t

5 Algorithm motivation all

6 Distance between u and v
Length of the shortest length path between u and v Distance between RM and BO? 1

7 Questions?

8 Breadth First Search (BFS)
Which vertices is s connected to? Build layers of vertices connected to s Lj : all nodes at distance j from s L0 = {s} Assume L0,..,Lj have been constructed Lj+1 set of vertices not chosen yet but are connected to Lj Stop when new layer is empty

9 Exercise for you Prove that Lj has all nodes at distance j from s

10 BFS Tree BFS naturally defines a tree rooted at s Add non-tree edges
Lj forms the jth “level” in the tree u in Lj+1 is child of v in Lj from which it was “discovered” 1 7 1 L0 2 3 L1 2 3 8 4 5 4 5 7 8 L2 6 6 L3

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

12 Algo to compute the connected component of s?

13 Today’s agenda Every edge in is between consecutive layers
Computing Connected component


Download ppt "Lecture 13 CSE 331 Oct 1, 2012."

Similar presentations


Ads by Google