You are on page 1of 15

September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

Chapter 4

Trees

4.1 Introduction

A tree is a connected graph that contains no cycle. Figure 4.1(a)–(c) illus-


trates trees with one, two and three vertices respectively. Figure 4.1(d)–(e)
illustrates two different trees with four vertices. A path is always a tree.
The trees in Fig. 4.1(a)–(d) are all paths. Recall that a path with n vertices
has n − 1 edges. In fact, every tree has n − 1 edges as we shall see later
in this chapter. For example, Fig. 4.1(f) illustrates a tree with 14 vertices
and 13 edges.
A vertex with degree one in a tree T is called a leaf of T . All the vertices
of T other than the leaves are called the internal vertices of T . The vertex
d of the tree in Fig. 4.1(f) is a leaf and the vertex a is an internal vertex.
A collection of trees is called a forest. In other words, a forest is a
graph with no cycle. Such a graph is also called an acyclic graph. Each
component of a forest is a tree.

4.2 Properties of a Tree

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

58 Basic Graph Theory

(a) (b) (c)

(d) (e)

(f)

Fig. 4.1 Trees

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.

Proof. Let T be a tree of two or more vertices and let P be a maximal


path in T . Then the end vertices u and v of P have degree 1, otherwise P
would not be a maximal path in T . �

Lemma 4.2.2 Every edge in a tree is a cut edge.

Proof. Immediate from Lemma 3.1.4. �

The following lemma gives some characterization of trees.

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

(b) G contains no cycle.


(c) G has n − 1 edges.

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

60 Basic Graph Theory

(1) A forest with n vertices and k components has n − k edges.


(2) A forest with n vertices and m edges contains n − m components.
(3) A graph with n vertices, m edges and n − m components is acyclic.

We also have the following lemma, which give another characterizations


of a tree.

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

Fig. 4.2 An illustration for the proof of Lemma 4.2.5

We now prove that if for each pair of vertices u and v of a graph G,


there is a unique u, v-path in G, then G is a tree. It is obvious from the
assumption that G is connected. G is also acyclic since if G contains any
cycle C, then C induces two distinct path in G between any pair of vertices
on C. �
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

Trees 61

4.3 Rooted Trees

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.3 A tree.

The parent-child relationship can be extended naturally to ancestors


and descendants. Suppose that u1 , u2 , · · · , ul is a sequence of nodes in a
tree such that u1 is the parent of u2 , which is a parent of u3 , and so on.
Then node u1 is called an ancestor of ul and node ul a descendant of u1 . The
root is an ancestor of every node in a tree and every node is a descendant
of the root. In Fig. 4.3, all nodes are descendants of root v1 , and v1 is an
ancestor of all nodes.
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

62 Basic Graph Theory

4.4 Spanning Trees of a Graph

A subgraph G′ of a graph G is a spanning subgraph of G if G′ contains all


vertices of G. A spanning subgraph T of a graph G is a spanning tree of
G if T is a tree. In Figure 4.4 the edges of a spanning tree of a graph is
drawn by thick lines. The following claim holds.

Fig. 4.4 Spanning tree of a graph; edges of a spanning tree are drawn by thick lines.

Lemma 4.4.1 Every connected graph contains a spanning tree.

Proof. Let G be a connected graph. If G has no cycle, then G itself a


spanning tree of G. We thus assume that G has cycles. We delete edges
from cycles 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. Hence G′ is a
desired spanning tree T of G. �

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.

Lemma 4.4.2 Let G = (V, E) be a connected graph and let S ⊆ E such


that G − S is disconnected. Then every spanning tree of G has an edge in
S.
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

Trees 63

Proof. Let T be a spanning tree of G. Assume for a contradiction that


T does not contain any edge in S. Then G − S would not be disconnected
since T contains all vertices of G. �

A graph may have many spanning trees. Counting spanning trees is an


essential step in many methods for computing, bounding, and approximat-
ing network reliability; in a network modeled by a graph, intercommunica-
tion between all nodes of the network implies that the graph must contain
a spanning tree and thus, maximizing the number of spanning trees is a
way of maximizing reliability [NPP11]. We denote by τ (G) the number of
spanning trees of a connected graph G. Recall that we denote by G − e
the graph obtained from a graph G by deleting its edge e, and by G\e
the graph obtained from G by contracting its edge e. These two graph
operations play crucial role in counting the number of a spanning trees of
a graph, as shown in the following lemma.

Lemma 4.4.3 Let G be a connected graph and let e be an edge in G.


Then τ (G) = τ (G − e) + τ (G\e).

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). �

Note that τ (G − e) = 0 if e is a cut-edge of G. We can use Lemma 4.4.3


for counting number of spanning trees of a graph recursively, although
this is not an effcient way of counting spanning trees. A more effecient
method for counting spanning trees of graphs is to use Matrix-Tree theorem
due to Kirchhoff [1847]. Recently Nikolopoulos et. al. used a modular
decomposition technique to calculate the number of spanning trees in some
special classes of graphs in linear time [NPP11].
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

64 Basic Graph Theory

4.5 Counting of Trees

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.

Theorem 4.5.1 There are nn−2 distinct labeled trees of n vertices.

Proof. The idea is to establish a one to one correspondence between the


set of labeled trees of n vertices and the set of sequences (a1 , a2 , · · · , an−2 ),
where each ai is an integer satisfying 1 ≤ ai ≤ n. Since there are precisely
nn−2 such sequences, the result follows immediately.
We assume n ≥ 3, since the result is trivial if n = 1 or 2.
Let T be a labeled tree of n vertices. We can obtain a unique sequence
(x1 , x2 , · · · , xn−2 ) from tree T as follows. Let y1 be the smallest label
among the labels assigned to all leaf vertices, and let x1 be the label of the
vertex adjacent to y1 . We delete the vertex y1 . Clearly T ′ = T − y1 is
a tree of n − 1 vertices. Let y2 be the leaf vertex in T ′ with the smallest
label and let x2 be the nieghbor of y2 . We delete y2 . We continue the
process until there are only two vertices left and we obtain the sequence
(x1 , x2 , · · · , xn−2 ). An illustrative example for step by step construction of
the sequence from a tree is given in Figure 4.5, where the edge (yi , xi ) is
drawn by dotted line in each step.
We now show that from a sequence (x1 , x2 , · · · , xn−2 ) we can construct
a unique tree of n vertices. Let {1, 2, · · · n} be the set of n vertices. We
will construct a tree with the vertex set {1, 2, · · · n}. Let y1 be the small-
est number that does not appear in (x1 , x2 , · · · , xn−2 ). We add the edge
(x1 , y1 ), remove x1 from the sequence and remove y1 from consideration
and continue the process. Finally we add the last edge between two ver-
tices whose label have not appeared in {y1 , y2 , · · · , yn−2 }. We now need to
show that the process mentioned above constructs a tree. We started with
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

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)

Fig. 4.5 Construction of the sequence from a tree.

n isolated vertices labeled by {1, 2, · · · n}. We consider each of the vertices


unmarked, and each component has an unmarked vertices. First we join
edge (x1 , y1 ), mark y1 and x1 remains unmarked. Hence each component
has an unmarked vertices. One can observed that when we add an edge
(xi , yi ), both xi and yi are unmarked vertices and hence they are in two
different components. After adding the edge (xi , yi ), the two components
are marged to one component and we mark y1 . Hence each component
has exactly one unmarked vertex. Finally we have eaxctly two components
and each component has exactly one unmarked vertex. We join the two
unmarked vertices and obtained a connected graph. Since we have added
n − 1 edges the connected graph is a tree. An illustrative example for con-
struction of tree from a sequence 1, 3, 3, 7, 9, 9, 7 is give in Figure 4.6. In
Figure 4.6(a) each vertex is a component and every vertex is unmarked. In
Figure 4.6(b), x1 = 1 and Y1 = 2 since 2 is the smallest integer that does
not appear in the sequence 1, 3, 3, 7, 9, 9, 7. After adding edge (x1 , y1 ), y1 is
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

66 Basic Graph Theory

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)

Fig. 4.6 Construction of the tree from a sequence.

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 .

4.6 Distances in Trees and Graphs

If G has a u, v-path, then the distance from u to v is the length of a shortest


u, v-path. The distance from u to v in G is denoted by dG (u, v) or simply
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

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

Fig. 4.7 Ecentricities of vertices.

Lemma 4.6.1 The center of a tree is a vertex or an edge.

Proof. We use induction on the number of vertices in a tree T . If n ≤ 2


then the entire tree is the center of the tree. Assume that n ≥ 3 and the
claim holds for any tree with less than n vertices. Let T ′ be the graph
obtained from T by deleting all leaves of T . T ′ has at least one vertex,
since T has a non-leaf vertex as n ≥ 3. Clearly T ′ is connected and has
no cycle, and hence T ′ be a tree with less than n vertices. By induction
hypothesis the center of T ′ is a vertex or an edge. To complete the proof,
we now show that T and T ′ have the same center. Let v be a vertex in T .
Every vertex u in T which is at maximum distance from v is a leaf. Since
all leaves of T have been deleted to obtain T ′ and any path between two
non-leaf vertices in T does not contain a leaf, ǫT ′ (u) = ǫT (u) − 1 for every
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

68 Basic Graph Theory

vertex u in T ′ . Furthermore, the ecentricity of a leaf is greater than the


ecentricity of its neighbors in T . Hence the vertices whose ecentricities are
minimum in T and the vertices whose ecentricities are minimum in T ′ are
the same. Therefore T and T ′ have the same center. �

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)

Fig. 4.8 Finding a center of a tree.

4.7 Graceful Labeling

A graceful labeling of a simple graph G, with n vertices and m edges, is a


one-to-one mapping f of the vertex set V into the set {0, 1, 2, · · · , m}, so
that distinct vertices receive distinct numbers and it satisfies {|f (u)−f (v)| :
uv ∈ E(G)} = {1, 2, 3, · · · , m}. The absolute difference of the labels of two
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

Trees 69

end vertices of an edge e in a graceful labeling is regarded as the label of e


in the graceful labeling.
One can easily compute a graceful labeling of a path as follows. Start
labeling at either end. The first vertex is labeled by 0 and the next vertex
on the path is labeled by n − 1, the next vertex is labeled by 1, the next
vetex is labled by n − 2, and so on. Figure 4.9 illustrates a graceful labeling
of a tree. It is not difficult to observe that edges get labels n−1, n−2, · · · , 1.

Fig. 4.9 Labels of vertices and edges in a graceful labeling of a path.

An interesting patern of labeling exits for a graceful labeling of a cater-


pillars. Observe Figure 4.10 for the interseting patern.

Fig. 4.10 Labels of vertices in a graceful labeling of a caterpillar.

All trees are graceful - is the famous Ringel-Kotzig conjecture which


has been the focus of many papers. Graphs of different classes have been
proven mathematically to be graceful of nongraceful. All trees with 27
vertices are graceful was shown by Aldred and McKay using a computer
program in 1998. Aryabhatta et. al. showed that a fairly large class of
trees constructed from caterpillars are graceful [ARUR11].
September 4, 2014 11:56 WSPC/Book Trim Size for 9in x 6in bgtbook˙saidur

70 Basic Graph Theory

Exercise

1. Show that a forest with n vertices and k components has n − k edges.


2. Show that a forest with n vertices and m edges contains n − m compo-
nents.
3. Show that a graph with n vertices, m edges and n − m components is
acyclic.
4. Draw all labelled trees with four vertices.
5. Construct all labelled spanning trees of K4 . How many of them are
non-isomorphic?
6. Compute the ecentricities of the vertices in the graph in Figure 4.11.
e i
a
c d h m
j
n

k
f g
b l

Fig. 4.11 A graph.

7. Find the centers of the trees in Figures 4.12(a) and (b).


a
d f
b
e
c
d e
j a
h

b i
h c
g

g
f (b)
(a)

Fig. 4.12 Trees.

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?

Fig. 4.13 A graceful tree.

14. Show that every tree containing a vertex of degree k contains at least k
leaves.

You might also like