Download presentation
Presentation is loading. Please wait.
1
Lecture 11 CSE 331 Sep 19, 2014
2
HW 2 due today I will not accept HWs after 1:15pm
Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm
3
Other HW related stuff HW 3 has been posted online: see piazza
Solutions to HW 2 at the END of the lecture Graded HW 1 available from Monday onwards
4
Out of town next week Andrew Hughes will cover the lecture for me
5
Graphs Graph G = (V,E) Directed vs Undirected (default) u w
No “self loops”
6
Paths , , Sequence of vertices connected by edges Connected
Path length 3 ,
7
Connectivity u and w are connected iff there is a path between them A graph is connected iff all pairs of vertices are connected
8
Connected Graphs Every pair of vertices has a path between them
9
Cycles Sequence of k vertices connected by edges, first k-1 are distinct ,
11
Formally define everything
12
Rest of Today’s agenda Prove n vertex tree has n-1 edges
Formal definitions of paths, cycles, connectivity and trees Prove n vertex tree has n-1 edges Algorithms for checking connectivity
13
HW 2 due today I will not accept HWs after 1:15pm
Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm
14
Tree Connected undirected graph with no cycles
15
Rooted Tree
16
A rooted tree AC’s child=SG Pick any vertex as root SG’s parent=AC
Let the rest of the tree hang under “gravity”
17
Rest of Today’s agenda Prove n vertex tree has n-1 edges
Algorithms for checking connectivity
18
Checking by inspection
19
What about large graphs?
Are s and t connected?
20
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
21
Algorithm motivation all
22
Distance between u and v
Length of the shortest length path between u and v Distance between RM and BO? 1
23
Questions?
24
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
25
Exercise for you Prove that Lj has all nodes at distance j from s
26
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.