Download presentation
Presentation is loading. Please wait.
1
Lecture 15 CSE 331 Oct 4, 2010
2
Announcements Final exam: Dec 14, 3:30pm-6:30pm, Knox 104
Mid term: Oct 18, in class Graded HW 2 on Wed: sorry!
3
not student post category
4
Determining connectivity in graphs
s t Are s and t connected?
5
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
6
Algorithm motivation all
7
Distance between u and v
Length of the shortest length path between u and v Distance between RM and BO? 1
8
Questions?
9
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
10
Exercise for you Prove that Lj has all nodes at distance j from s
11
Given BFS, how to decide if s is connected to t?
12
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
13
Connected Component Connected component (of s) is the set of all nodes connected to s
14
Algo to compute the connected component of s?
15
Today’s agenda Every edge in is between consecutive layers
Computing Connected component
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.