Top Banner
Lecture 11 CSE 331 Sep 25, 2009
15

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.

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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.

Lecture 11

CSE 331Sep 25, 2009

Page 2: 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.

Homeworks

Please hand in your HW 2 now

HW 3 and graded HW 1 at the end of class

Page 3: 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.

GraphsRepresentation of relationships between pairs of entities/elements

VertexVertex

EdgeEdge

# vertices = n

#edges = m

# vertices = n

#edges = m

Page 4: 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.

Paths

Sequence of (distinct) vertices connected by edges

, , ,

Path length 3Path length 3

,

ConnectedConnected

Page 5: 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.

Connected Graphs

Every pair of vertices has a path between them

Page 6: 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.

Cycles

Sequence of k vertices connected by edges, first k-1 are distinct

, , ,

Page 7: 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.
Page 8: 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.

TreeConnected undirected graph with no cycles

Page 9: 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.

Rooted Tree

Page 10: 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.

A rooted tree

Pick any vertex as root

Let the rest of the tree hang under “gravity”

How many rooted trees

can an n vertex tree

have?

How many rooted trees

can an n vertex tree

have?

SG’s parent=AC

SG’s parent=AC

AC’s child=SG

AC’s child=SG

Page 11: 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.

Rest of Today’s agenda

Prove n vertex tree has n-1 edges

Algorithms for checking connectivity

Page 12: 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.

Checking by inspection

Page 13: 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.

What about large graphs?

s

t

Are s and t connected?

Page 14: 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.

Brute-force algorithm?

List all possible vertex sequences between s and t

Check if any is a path between s and t

2n such sequences

2n such sequences

Page 15: 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.

Algorithm motivation

allall