HO#27
SlidesTrees, Intro to Automata
4/20/11
1
CS103
4/20/11
Mathematical Foundations of Computing
Midterm Thursday Night (aka Tomorrow!)
7 – 9 pm
Cubberley Auditorium
Open book, open notes
No computers or mobile devices
An
undirected graph
is an ordered pair (V, E) where
(i)
V is a nonempty set of
vertices
, and
(ii)
E is an
edge set
consisting of unordered pairs of
distinct vertices.
By convention, we write edges as (u, v), where u, v
V and u
v.
(u, v) and (v, u) are considered to be the same edge.
Graphs
1
2
3
4
5
6
7
Unless we say otherwise, we will be talking about undirected graphs.
Reference:
Introduction to Algorithms, 2
nd
Ed.
, Thomas Cormen, et al.
Graph Terminology
1
2
3
4
5
6
7
If (u, v) is an edge, we say (u, v) is
incident
on vertices u and v,
that u is
adjacent
to v, and that v is adjacent to u.
The
degree
of a vertex is the number of edges incident on it.
A
path of length k
from a vertex u to a vertex u' in a tree G = (V, E)
is a sequence of vertices (v
0
, v
1
, v
2
, .
.., v
k
) from V such that u = v
0
,
u' = v
k
and (v
i1
, v
i
)
E for i = 1, 2, .
.., k.
A path is
simple
if all its vertices are distinct.
A path (v
0
, v
1
, v
2
, .
.., v
k
) forms a (simple)
cycle
if k
3, v
0
= v
k
, and
v
1
, v
2
, .
.., v
k
are distinct.
A graph with no cycles is
acyclic
.
A graph is
connected
if there is a path between every pair of vertices.
Trees
A
tree
is an acyclic, connected, graph in which one vertex has been
designated as the
root
.
1
2
3
4
5
6
7
We normally draw the root of a tree at the top, and we refer to the
vertices as
nodes
.
Trees
A
tree
is an acyclic, connected, graph in which one vertex has been
designated as the
root
.
1
2
3
4
5
6
7
Consider a node x in a tree with root r.
Any node on the unique path from
r to x is an
ancestor
of x.
If y is an ancestor of x, x is a
descendant
of y.
If the last
edge
on the path from r to x is
(y, x)
, then y is the
parent
of x
and x is the
child
of y.
Nodes with the same parent are
siblings
.
A node with no children is a
leaf
, and a node that is not a leaf is an
interior node
.
The
subtree rooted at x
is the tree consisting of x, its descendants, and
the edges connecting them.
Properties of Trees
Let G = (V, E) be an undirected graph.
The following statements are equivalent:
1. G is a tree.
2. Any two vertices of G are connected by a unique simple path.
3. G is connected, but if any edge in E is removed, the result is not connected.
4. G is connected, and E = V  1.
5. G is acyclic, and
E = V  1.
6. G is acyclic, but if an edge is added to E, the resulting graph has a cycle.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 PLUMMER
 Graph Theory, Formal language, Planar graph

Click to edit the document details