Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 12 CSE 331 Sep 22, 2014.

Similar presentations


Presentation on theme: "Lecture 12 CSE 331 Sep 22, 2014."— Presentation transcript:

1 Lecture 12 CSE 331 Sep 22, 2014

2 Today’s agenda Finish Proving n vertex tree has n-1 edges
Algorithms for checking connectivity

3 n vertex tree has n-1 edges
Proof idea (recap): Root tree T at vertex r r Direct edges from child to parent

4 n vertex tree has n-1 edges
Proof idea (recap): tail Claim 1: r is not the head of any directed edge. r Claim 2: Every directed edge has a unique head head

5 Questions?

6 Rest of Today’s agenda Algorithms for checking connectivity
Finish Proving n vertex tree has n-1 edges Algorithms for checking connectivity

7 Checking by inspection

8 What about large graphs?
Are s and t connected?

9 Brute-force algorithm?
List all possible vertex sequences between s and t nn such sequences Check if any is a path between s and t

10 Algorithm motivation all

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

12 Questions?

13 Breadth First Search (BFS)
Is s connected to t? 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

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

15 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


Download ppt "Lecture 12 CSE 331 Sep 22, 2014."

Similar presentations


Ads by Google