Lecture 11 CSE 331 Sep 25, 2009

advertisement
Lecture 11
CSE 331
Sep 25, 2009
Homeworks
Please hand in your HW 2 now
HW 3 and graded HW 1 at the end of class
Graphs
Representation of relationships between pairs of entities/elements
# vertices = n
#edges = m
Edge
Vertex
Paths
,
Sequence of (distinct) vertices connected by edges
Connected
Path length 3
,
,
,
Connected Graphs
Every pair of vertices has a path between them
Cycles
Sequence of k vertices connected by edges, first k-1 are distinct
,
,
,
Tree
Connected undirected graph with no cycles
Rooted Tree
A rooted tree
How many
rooted trees
can an n
vertex tree
have?
Pick any vertex as root
Let the rest of the tree hang under “gravity”
SG’s
parent=AC
AC’s
chil
d=S
G
Rest of Today’s agenda
Prove n vertex tree has n-1 edges
Algorithms for checking connectivity
Checking by inspection
What about large graphs?
s
t
Are s and t connected?
Brute-force algorithm?
List all possible vertex sequences between s and t
2n such
sequences
Check if any is a path between s and t
Algorithm motivation
all
Download