lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · lecture 12 cse 331 feb21,...
TRANSCRIPT
Lecture 12
CSE 331Feb 21, 2020
Mini Project group due next Friday!
124 of you still need to do this!
Connectivity Problem
Input: Graph G = (V,E) and s in V
Output: All t connected to s in G
Breadth First Search (BFS)
Build layers of vertices connected to s
L0 = {s}
Assume L0,..,Lj have been constructed
Lj+1 is the set of vertices not chosen yet but are connected by an edge to Lj
Stop when new layer is empty
BFS TreeBFS naturally defines a tree rooted at s
Lj forms the jth �level� in the tree
u in Lj+1 is child of v in Lj from which it was �discovered�
1
2 3
4 5
6
7
8
1
2 3
L0
L1
4 5 7 8 L2
6 L3
Add non-tree edges
9
0
Two facts about BFS trees
All non-tree edges are in the same or consecutive layer
If u is in Li then dist(s,u) = i
Today’s agenda
Computing Connected component
Computing Connected Component
Start with R = {s}
Explore(s)
While there is an edge (u,v) whereu in R and v not in R
Add v to ROutput R* = R
kobe bryantsteve nash
shaq o’neal
anthony davis
lebron james
kyrie irving
kevin love
michael jordan scottie pippen
Questions?