lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · lecture 12 cse 331 feb21,...
TRANSCRIPT
![Page 1: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/1.jpg)
Lecture 12
CSE 331Feb 21, 2020
![Page 2: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/2.jpg)
Mini Project group due next Friday!
124 of you still need to do this!
![Page 3: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/3.jpg)
Connectivity Problem
Input: Graph G = (V,E) and s in V
Output: All t connected to s in G
![Page 4: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/4.jpg)
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
![Page 5: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/5.jpg)
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
![Page 6: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/6.jpg)
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
![Page 7: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/7.jpg)
Today’s agenda
Computing Connected component
![Page 8: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/8.jpg)
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
![Page 9: Lecture 12 - cse.buffalo.eduerdem/cse331/spring20/lectures/lect12.pdf · Lecture 12 CSE 331 Feb21, 2020. Mini Project group due next Friday! 124 of you still need to do this! Connectivity](https://reader034.vdocument.in/reader034/viewer/2022042310/5ed82f370fa3e705ec0dfe44/html5/thumbnails/9.jpg)
Questions?