Lecture 15 CSE 331 Oct 4, 2010
Announcements Final exam: Dec 14, 3:30pm-6:30pm, Knox 104 Mid term: Oct 18, in class Graded HW 2 on Wed: sorry!
not student post category
Determining connectivity in graphs http://www.cise.ufl.edu/research/sparse/matrices/Nasa/barth5.html s t Are s and t connected?
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
Algorithm motivation all
Distance between u and v Length of the shortest length path between u and v Distance between RM and BO? 1
Questions?
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
Exercise for you Prove that Lj has all nodes at distance j from s
Given BFS, how to decide if s is connected to t?
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
Connected Component Connected component (of s) is the set of all nodes connected to s
Algo to compute the connected component of s?
Today’s agenda Every edge in is between consecutive layers Computing Connected component