Trees: September 4, 2014 11:56 WSPC/Book Trim Size For 9in X 6in Bgtbook Saidur
Trees: September 4, 2014 11:56 WSPC/Book Trim Size For 9in X 6in Bgtbook Saidur
Chapter 4
Trees
4.1 Introduction
There are many equivalent properties of a tree. In fact, any of these equiv-
alent properties can be taken as the definition of a tree. In this section, we
discuss these properties of a tree. We first observe the following two trivial
57
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur
(d) (e)
(f)
properties of a tree whic play crucial roles while dealing with trees.
Lemma 4.2.1 Every tree with two or more vertices has at least two
leaves.
Lemma 4.2.3 Let G be a graph with n vertices. Then, any two of the
following three statements implies the third (and charactrize a tree of n
vertices).
(a) G is connected.
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur
Trees 59
Proof. (a)&(b)⇒ (c). We first prove that a connected and acyclic graph
G with n vertices has n − 1 edges. The claim is obvious for n = 1 since a
graph with a single vertex and no cycle has no edges. We thus assume that
n > 1 and the claim is true for any connected and acyclic graph with less
than n vertices. We now show that the graph G with n vertices has n − 1
edges. Since G contains no cycle, every edge e of G is a cut edge. Let H1
and H2 be the two components of G−e with n1 and n2 vertices respectively
where n1 + n2 = n. Since both H1 and H2 are acyclic and connected, they
contains n1 − 1 and n2 − 1 edges respectively. Then the total number of
edges in G is n1 − 1 + n2 − 1 + 1 = n − 1.
(a)&(c)⇒ (b). We now prove that a connected graph G with n vertices
and n−1 edges is acyclic. We delete edges from cycles of G one by one until
the resulting graph G′ is acyclic. Since no edge on a cycle is a cut-edge
by Lemma 3.1.4, G′ is connected. Then G′ is connected and acyclic, and
hence G′ has n − 1 edges. Since G has n − 1, we have not deleted any edge
from G to construct G′ . Therefore G has no cycle.
(b)&(c)⇒ (a). We now prove that an acyclic graph G with n vertices
and m = n − 1 edges is connected. Assume for a contradiction that G is
not connected. Then G consists of two or more onnected ccomponents and
each connected component is also acyclic. Let G1 , · · · , Gk be the connected
components of G. Let ni and mi be the number of vertices and edges in
�
Gi respectively. Clearly i ni = n. Since each Gi is acyclic and connected
�
mi = ni − 1. Then m = i [ni − 1] = n − k. Since we have m = n − 1,
k = 1. Hence G is connected. �
The following corollaries are very trivial from the lemma above, and
their proofs are left as exercises.
Corollary 4.2.4
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur
Lemma 4.2.5 A simple graph G is a tree if and only if for each pair of
vertices u and v of G, there is a unique u, v-path in G
Proof. We first prove that for each pair of vertex u and v of a tree G,
G contains a unique u, v-path. Since G is connected, there is at least one
u, v-path between each pair of vertices. Assume for a contradiction that
there are two distinct paths P1 and P2 between a pair vertices u and v in
G. Let x be a vertex on P1 which is not on P2 . Then P1 contains a subpath
P ′ = u′ , · · · , x, v ′ such that only u′ of v ′ of P ′ are on P2 . (Assume that
u′ is closer to u and v ′ is closer to v along P1 , and u′ = u or v ′ or v ′ = v
may hold.) Then the parts of P1 and P2 from u′ to v ′ forms a cycle in G
as illustrated in Fig. 4.2, which is a contradiction.
P1 x
� �
u u ′ v′
� � � � v
� �
P2
Trees 61
A rooted tree is a tree in which one of the nodes is distinguished from the
others. The distinguished node is called the root of the tree. The root of
a tree is usually drawn at the top. In Fig. 4.3, the root is v1 . If a rooted
tree is regarded as a directed graph in which each edge is directed from top
to bottom, then every node u other than the root is connected by an edge
from some other node p, called the parent of u. We also call u a child of
node p. We draw the parent of a node above that node. For example, in
Fig. 4.3, v1 is the parent of v2 , v3 and v4 , while v2 is the parent of v5 and
v6 ; v2 , v3 and v4 are the children of v1 , while v5 and v6 are the children of
v2 . A leaf is a node of a tree that has no children. An internal node is a
node that has one or more children. Thus every node of a tree is either a
leaf or an internal node. In Fig. 4.3, the leaves are v4 , v5 , v6 and v7 , and
the nodes v1 , v2 and v3 are internal nodes.
v1
v2 v3 v4
v v6 v
5 7
Fig. 4.4 Spanning tree of a graph; edges of a spanning tree are drawn by thick lines.
Based on the proof of Lemma 4.4.1 one can develop an algorithm for
finding a spanning tree of a connected graph as follows: Check whether the
graph has a cycle or not. If the graph has a cycle, delete an edge from the
cycle and repeat the process until the resulting graph is acyclic.
We now prove the following lemma.
Trees 63
Proof. Let T be the set of all spanning trees of G. Let T1 be the set of
all spanning trees of G containing e and T2 be the set of all spanning trees
not containing e. Clearly the sets T1 ∩ T2 = φ and T1 ∪ T2 = T . Thus
T1 ∪ T2 is a partition of T . One can easily observe that |T1 | = τ (G\e) and
|T2 | = τ (G − e). Therefore τ (G) = |T | = |T1 ∪ T2 | = τ (G − e) + τ (G\e). �
There is exactly one tree with a single vertex. The number of trees with
two vertices is also one. The number of labeled trees with three vertices
is three. With four vertices 16 labeled trees can be constructed. In this
section we present Cayley’s theorem on number of labeled trees.
Trees 65
1 7 8 1 7 8 1 7 8
3 3 3
2 9 2 9 9
6 6
4 5 4 5 6
4 5
SQ = 1 SQ = 1,3
(a) (b) (c)
7 8 7 8 7 8
3 3
9 9 9
6 6 6
4 5 5 5
SQ = 1,3,3 SQ = 1,3,3,7
SQ = 1,3,3,7,9
(d) (e) (f)
7 8 7 8
9 9
SQ = 1,3,3,7,9,9,7
6
SQ = 1,3,3,7,9,9 (h)
(g)
marked and each component has exactly one unmarked vertex. Incremental
construction of the remaining of the tree is shown in Figure 4.6(b)-(i). �
8 8 8
7 7 7
1 1 1
3 3 3
2 9 2 9 2 9
4 4 4
5 6 5 6 5 6
(a) (b) (c)
8 8 8
7 7 7
1 1 1
3 3 3
2 9 2 9 2 9
4 4 4
5 5 6 5
6 6
(d) (e) (f)
8 8 8
7 7 7
1 1 1
3 3 3
2 9 2 9 2 9
4 4 4
5 6 5 6 5 6
(g) (h) (i)
The proof of Theorem 4.5.1 is due to Prüffer and Clarke and the se-
quence used in the proof is known as Prüffer’s code. Some other proofs can
be found in [Moo70].
Cayley’s formula immediately gives the number of spanning trees of a
complete graph. Since Kn has all the edges that can be used in forming
trees of n vertices, the number of spanning trees of Kn is equal to the
number of trees of n vertices, i.e., nn−2 .
Trees 67
by d(u, v). For the graph in Figure 4.7 d(a, j) = 5 although there is a path
of length 8 between a and j. If G has no u, v-path then d(u, v) = ∞. The
diameter of G is the longest distance among the distances of all pair of
vertices in G. The graph in Figure 4.7 has diameter 6. The ecentricity of a
vertex u in G is maxv∈V (G) d(u, v) and denoted by ǫ(u). Ecencrities of all
vertices of the graph in Figure 4.7 are shawn in the figure. The radius of
a graph is minu∈V (G) ǫ(u). The center of a graph G is the subgraph of G
induced by vertices of minimum ecentricity. The maximum of the vertex
ecentricities is equal to the diameter. The diameter and the radius of a
disconnected graph are infinite.
m
4
5
4 j
b 6 e 4 3
c h i
a 5
6 5 l 5 6
d 5
f g k
Following the proof of Lemma 4.6.1, we can find the center of a tree if
we continue to delete all the leaves of the tree recursively until we are left
with a single vertex or a single edge as illustrated in Figure 4.8.
(a)
(b)
(c)
(d)
Trees 69
Exercise
k
f g
b l
b i
h c
g
g
f (b)
(a)
8. Show that the center of a tree is a single vertex if the diameter of the
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur
Trees 71
tree is even.
9. Compute the Prüffer’s code for Figures 4.12(a) and (b).
10. Construct the tree corresponding to Prüffer’s code 1,2,2,7,6,6,5.
11. Find a graceful labeling of the tree in Figure 4.12(b).
12. Develop an algorithm for computing a graceful labeling of a caterpillar.
13. Find a graceful labeling of the tree in Figure 4.13. Can you develop an
algorithm for finding graceful labelings of this types of trees?
14. Show that every tree containing a vertex of degree k contains at least k
leaves.