Skip to main content

Trees

Theorem 6

The following definitions are equivalent:

  1. GG is a tree (connected without cycle).
  2. For every two vertices u,vu,v, there exists exactly one path from uu to vv.
  3. The graph GG is connected and deleting any edge disconnects the graph.
  4. Graph GG has no cycle and adding any edge into GG creates a cycle.
  5. GG is connected and E=V1|E| = |V|-1.

In these lecture notes, we will show the equivalence between (1) and (5). The other equivalences are left as an exercise. A leaf of a tree is a vertex of degree one. The following two lemmas will give us a natural way to do induction on a tree.

Lemma 4 (Leaf lemma)

If GG is connected without cycle and V(G)2|V(G)| \ge 2, then GG contains at least two different leaves.

This is again one of those intuitively true statements. No matter how you try to draw it, it is true. But this is not a proof, since there are infinitely many trees, whereas proofs are finite.

Proof:

Take P=(v1,,vq)P=(v_1,\ldots, v_q) to be a path of maximum length in GG. Note that q2q \ge 2. We claim that v1v_1 and vqv_q are both leaves (do you see why they are different?). Assume otherwise that deg(v1)>1\deg(v_1) > 1 (the other case is similar). Then there is an edge (u,v1)(u,v_1) where uv2u \neq v_2. If uu appears on PP, i.e., u=viu=v_i for i>2i >2, (v1,v2,,vi,v1)(v_1,v_2,\ldots, v_i, v_1) would be a cycle, which is a contradiction. Otherwise, if uu is not on PP, then the path (u,v1,,vq)(u,v_1,\ldots, v_q) is a path longer than PP, a contradiction since PP is a longest path.

Lemma 5 (Tree growing lemma)

Let vv be a leaf of GG. The following statements are equivalent: (i) GG is a tree and (ii) GvG-v is a tree.

Proof:

To prove (i)     \implies (ii), assume that GG is a tree, and we argue that GvG-v is connected (the fact that GvG-v does not have a cycle is even simpler!). Look at GvG-v and take two vertices u,wu,w in GvG-v (and thus none of those is vv). Since GG is connected, there exists a path connecting uu and ww in GG. This path cannot contain vv since the degree of vv is one. Therefore, this is a path in GvG-v. Since every uu and vv are connected via a path, the graph GvG-v is connected.

To prove (ii)     \implies (i), assume that GvG-v is a tree. Graph GG cannot have a cycle that involves vv (since vv has degree one), so we only need to check that GG is connected. Every pair of vertices u,wu,w in GvG-v is connected in GvG-v. Moreover, vv is connected to every ww in GvG-v since we can first connect vv to vV(Gv)v' \in V(G-v) via an edge and from vv' to ww due to the connectedness of GvG-v.

Notice that these lemmas are quite simple to prove, but they require some effort (especially the mental effort to resist the "proof by picture" temptation). Whenever we claim that a cycle exists, the proof explicitly shows a sequence of vertices that form a cycle. Whenever we claim connectedness, we explicitly identify a sequence of vertices on paths that connect pairs of vertices. Now we are ready to show the proof of the theorem.

Proof (Equivalence (1)     \iff (5)):

We prove this by induction on the number of vertices. The induction hypothesis (IH): For all n1n \geq 1, GG is a tree if and only if GG is connected and E=V1|E| = |V|-1. The base case when n=1n=1 is trivial. Now assume that the IH is true for n0n_0 and consider a graph with n0+1n_0+1 vertices. To prove (1)     \implies (5), we need to argue that E(G)=V(G)1|E(G)| = |V(G)|-1. From the previous two lemmas, there exists a leaf vertex vv in GG so that GvG- v is a tree. We know, from IH, that E(Gv)=V(Gv)1|E(G-v)| = |V(G-v)| -1 and this implies that E(G)=V(G)1|E(G)| = |V(G)| -1.

To prove the converse, assume that E(G)=V(G)1|E(G)| = |V(G)|-1. First we argue that there exists a leaf in GG (do you see why we cannot just use the leaf lemma we already proved?). By connectedness, every vertex in GG has degree at least one. By the Handshake's lemma, we have vV(G)deg(v)=2E(G)=2(V(G)1)\sum_{v \in V(G)} \deg(v) = 2|E(G)| = 2(|V(G)|-1). So there must be at least two vertices of degree one. Take vv to be a leaf of GG. Notice that GvG-v is connected and satisfies E(Gv)=V(Gv)1|E(G-v)| = |V(G-v)| -1, so by IH, we know that GvG-v contains no cycle. Since vv has degree one, a cycle in GG cannot contain vv, so GG cannot have any cycle.

Notice that a nice property about trees is the inductive property we use above (GG is a tree if and only if GvG-v is a tree, when vv is a leaf). Trees are a very important objects in computer science and have played fundamental roles in almost every area of algorithm design.

Exercise 19

Complete the proof of Theorem 6.

Exercise 20

Draw all trees on the vertex set V={1,2,3,4}V = \{1,2,3,4\} and all pairwise non-isomorphic trees.

Exercise 21

Let GG be a tree with V(G)2|V(G)| \ge 2. Prove:

p1=2+d3(d2)pdp_1 = 2+ \sum_{d \geq 3} (d-2) p_d

where pdp_d denotes the number of vertices in GG having degree dd.

Notice that the above exercise provides an alternative proof of the Leaf lemma.