Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

4.1 Introduction

“Trees” form an important class of graphs. Of late, their importance has grown considerably in view of their wide applicability in theoretical computer science.

In this chapter, we present the basic structural properties of trees, their centers and centroids. In addition, we present two interesting consequences of the Tutte–Nash–Williams theorem on the existence of k pairwise edge-disjoint spanning trees in a simple connected graph. We also present Cayley’s formula for the number of spanning trees in the labeled complete graph K n . As applications, we present Kruskal’s algorithm and Prim’s algorithm, which determine a minimum-weight spanning tree in a connected weighted graph and discuss Dijkstra’s algorithm, which determines a minimum-weight shortest path between two specified vertices of a connected weighted graph.

4.2 Definition, Characterization, and Simple Properties

Certain graphs derive their names from their diagrams. A “tree” is one such graph. Formally, a connected graph without cycles is defined as a tree. A graph without cycles is called an acyclic graph or a forest. So each component of a forest is a tree. A forest may consist of just a single tree! Figure 4.1 displays two pairs of isomorphic trees.

Fig. 4.1
figure 1

Examples of isomorphic trees

Remarks 4.2.1.

  1. 1.

    It follows from the definition that a forest (and hence a tree) is a simple graph.

  2. 2.

    A subgraph of a tree is a forest and a connected subgraph of a tree T is a subtree of T.

In a connected graph, any two distinct vertices are connected by at least one path. Trees are precisely those simple connected graphs in which every pair of distinct vertices is joined by a unique path.

Theorem 4.2.2.

A simple graph is a tree if and only if any two distinct vertices are connected by a unique path.

Proof.

Let T be a tree. Suppose that two distinct vertices u and v are connected by two distinct u-v paths. Then their union contains a cycle (cf. Exercise 5.9, Chap. 1) in T, contradicting that T is a tree.

Conversely, suppose that any two vertices of a graph G are connected by a unique path. Then G is obviously connected. Also, G cannot contain a cycle, since any two distinct vertices of a cycle are connected by two distinct paths. Hence G is a tree.

A spanning subgraph of a graph G, which is also a tree, is called a spanning tree of G. A connected graph G and two of its spanning trees T 1 and T 2 are shown in Fig. 4.2.

The graph G of Fig. 4.2 shows that a graph may contain more than one spanning tree; each of the trees T 1 and T 2 is a spanning tree of G.

A loop cannot be an edge of any spanning tree, since such a loop constitutes a cycle (of length 1). On the other hand, a cut edge of G must be an edge of every spanning tree of G. Theorem 4.2.3 shows that every connected graph contains a spanning tree.

Fig. 4.2
figure 2

Graph G and two of its spanning trees T 1 and T 2

Theorem 4.2.3.

Every connected graph contains a spanning tree.

Proof.

Let G be a connected graph. Let \(\mathcal{C}\) be the collection of all connected spanning subgraphs of G. \(\mathcal{C}\) is nonempty as \(G \in \mathcal{C}\). Let \(T \in \mathcal{C}\) have the fewest number of edges. Then T must be a spanning tree of G. If not, T would contain a cycle of G, and the deletion of any edge of this cycle would give a (spanning) subgraph in \(\mathcal{C}\) having one edge less than that of T. This contradicts the choice of T. Hence, T has no cycles and is therefore a spanning tree of G.

There is a nice relation between the number of vertices and the number of edges of any tree.

Theorem 4.2.4.

The number of edges in a tree on n vertices is n − 1. Conversely, a connected graph on n vertices and n − 1 edges is a tree.

Proof.

Let T be a tree. We use induction on n to prove that \(m = n - 1\). When n = 1 or n = 2, the result is straightforward.

Now assume that the result is true for all trees on (n − 1) or fewer vertices, n ≥ 3. Let T be a tree with n vertices. Let e = uv be an edge of T. Then uv is the unique path in T joining u and v. Hence the deletion of e from T results in a disconnected graph having two components T 1 and T 2. Being connected subgraphs of a tree, T 1 and T 2 are themselves trees. As n(T 1) and n(T 2) are less than n(T), by an induction hypothesis, \(m({T}_{1}) = n({T}_{1}) - 1\) and \(m({T}_{2}) = n({T}_{2}) - 1\). Therefore, \(m(T) = m({T}_{1})+m({T}_{2})+1 = n({T}_{1})-1+n({T}_{2})-1+1 = n({T}_{1})+n({T}_{2})-1 = n(T)-1\). Hence, the result is true for T. By induction, the result follows in one direction.

Conversely, let G be a connected graph with n vertices and n − 1 edges. By Theorem 4.2.3, there exists a spanning tree T of G. T has n vertices and being a tree has (n − 1) edges. Hence G = T, and G is a tree.

Exercise 2.1.

Give an example of a graph with n vertices and n − 1 edges that is not a tree.

Theorem 4.2.5.

A tree with at least two vertices contains at least two pendant vertices (i.e., end vertices or vertices of degree 1).

Proof.

Consider a longest path P of a tree T. The end vertices of P must be pendant vertices of T; otherwise, at least one of the end vertices of P has a second neighbor in P, and this yields a cycle, a contradiction.

Corollary 4.2.6.

If δ(G) ≥ 2, G contains a cycle.

Proof.

If G has no cycles, G is a forest and hence δ(G) ≤ 1 by Theorem 4.2.5.

Exercise 2.2.

Show that a simple graph with ω components is a forest if and only if \(m = n - \omega \).

Exercise 2.3.

A vertex v of a tree T with at least three vertices is a cut vertex of T if and only if v is not a pendant vertex.

Exercise 2.4.

Prove that every tree is a bipartite graph.

Our next result is a characterization of trees.

Theorem 4.2.7.

A connected graph G is a tree if and only if every edge of G is a cut edge of G.

Proof.

If G is a tree, there are no cycles in G. Hence, no edge of G can belong to a cycle. By Theorem 3.2.7, each edge of G is a cut edge of G. Conversely, if every edge of a connected graph G is a cut edge of G, then G cannot contain a cycle, since no edge of a cycle is a cut edge of G. Hence, G is a tree.

Theorem 4.2.8.

A connected graph G with at least two vertices is a tree if and only if its degree sequence (d 1 , d 2 , …, d n ) satisfies the condition: \({\sum \nolimits }_{i=1}^{n}{d}_{i} = 2(n - 1)\) with d i > 0 for each i.

Proof.

Let G be a tree. As G is connected and nontrivial, it can have no isolated vertex. Hence every term of the degree sequence of G is positive. Further, by Theorem 1.4.4, \(\sum\limits_{i=1}^{n}{d}_{i} = 2m = 2(n - 1)\).

Conversely, assume that the condition \({\sum \nolimits }_{i=1}^{n}{d}_{i} = 2(n - 1)\) holds. This implies that \(m = n - 1\) as \({\sum \nolimits }_{i=1}^{n}{d}_{i} = 2m\). Now apply Theorem 4.2.4.

Lemma 4.2.9.

If u and v are nonadjacent vertices of a tree T, then T + uv contains a unique cycle.

Proof.

If P is the unique u-v path in T, then P + uv is a cycle in T + uv. It is unique, as the path P is unique in T.

Example 4.2.10.

Prove that if m(G) = n(G) for a simple connected graph G, then G is unicyclic, that is, a graph containing exactly one cycle.

Proof.

By Theorem 4.2.3, G contains a spanning tree T. As T has n(G) − 1 edges, E(G) ∖ E(T) consists of a single edge e. Then G = T ∪ e is unicyclic.

Exercise 2.5.

If for a simple graph G, m(G) ≥ n(G), prove that G contains a cycle.

Exercise 2.6.

Prove that every edge of a connected graph G that is not a loop is in some spanning tree of G.

Exercise 2.7.

Prove that the following statements are equivalent:

  1. (i)

    G is connected and unicyclic (i.e., G has exactly one cycle).

  2. (ii)

    G is connected and n = m.

  3. (iii)

    For some edge e of G, G − e is a tree.

  4. (iv)

    G is connected and the set of edges of G that are not cut edges forms a cycle.

Example 4.2.11.

Prove that for a simple connected graph G, L(G) is isomorphic to G if and only if G is a cycle.

Proof.

If G is a cycle, then clearly L(G) is isomorphic to G. Conversely, let G  ≃ L(G). Then n(G) = n(L(G)), and m(G) = m(L(G)). But since n(L(G)) = m(G), we have m(G) = n(G). By Example 4.2.10, G is unicyclic. Let C = v 1 v 2 …v k v 1 be the unique cycle in G. If GC, there must be an edge eE(C) incident with some vertex v i of C (as G is connected). Thus, there is a star with at least three edges at v i . This star induces a clique of size at least 3 in L(G) ( ≃ G). This shows that there exists at least one more cycle in L(G) distinct from the cycle corresponding to C in G. This contradicts the fact that L(G)  ≃ G (as G is unicyclic).

4.3 Centers and Centroids

There are certain parameters attached to any connected graph. These are defined below.

Definitions 4.3.1.

Let G be a connected graph.

  1. 1.

    The diameter of G is defined as max{d(u, v) : u, v ∈ V (G)} and is denoted by diam(G).

  2. 2.

    If v is a vertex of G, its eccentricitye(v) is defined by e(v) = max{d(v, u) : u ∈ V (G)}.

  3. 3.

    The radiusr(G) of G is the minimum eccentricity of G; that is, r(G) = min{e(v) : v ∈ V (G)}. Note that diam(G) = max{e(v) : v ∈ V (G)}.

  4. 4.

    A vertex v of G is called a central vertex if e(v) = r(G). The set of central vertices of G is called the center of G.

Example 4.3.2.

Figure 4.3 displays two graphs T and G with the eccentricities of their vertices. We find that r(T) = 4 and diam(T) = 7. Each of u and v is a central vertex of T. Also, r(G) = 3 and diam(G) = 4. Further, G has five central vertices.

Fig. 4.3
figure 3

Eccentricities of vertices for graphs G and T

Remark 4.3.3.

It is obvious that r(G) ≤ diam(G). For a complete graph, \(r(G) = \mathrm{diam}(G) = 1\). For a complete bipartite graph G(X, Y ) with | X | ≥ 2 and | Y | ≥ 2, \(r(G) = \mathrm{diam}(G) = 2\). For the graphs of Fig. 4.3, r(G) < diam(G). The terms ”radius” and ”diameter” tempt one to expect that diam(G) = 2r(G). But this need not be the case as the complete graphs and the graphs of Fig. 4.3 show. In a tree, for any vertex u, d(u, v) is maximum only when v is a pendant vertex. We use this observation in the proof of Theorem 4.3.4.

Theorem 4.3.4 (Jordan [117]). 

Every tree has a center consisting of either a single vertex or two adjacent vertices.

Proof.

The result is obvious for the trees K 1 and K 2. The vertices of K 1 and K 2 are central vertices. Now let T be a tree with n(T) ≥ 3. Then T has at least two pendant vertices (cf. Theorem 4.2.5). Clearly, the pendant vertices of T cannot be central vertices. Delete all the pendant vertices from T. This results in a subtree T of T. As any maximum-distance path in T from any vertex of T ends at a pendant vertex of T, the eccentricity of each vertex of T is one less than the eccentricity of the same vertex in T. Hence the vertices of minimum eccentricity of T are the same as those of T. In other words, T and T have the same center. Now, if T ′′ is the tree obtained from T by deleting all the pendant vertices of T , then T ′′ and T have the same center. Hence the centers of T ′′ and T are the same. Repeat the process of deleting the pendant vertices in the successive subtrees of T until there results a K 1 or K 2. This will always be the case as T is finite. Hence the center of T is either a single vertex or a pair of adjacent vertices.

The process of determining the center described above is illustrated in Fig. 4.4 for the tree T of Fig. 4.3. We observe that the center of T consists of the pair of adjacent vertices v 2 and v 3.

Fig. 4.4
figure 4

Determining the center of tree T

Exercise 3.1.

Construct a tree with 85 vertices that has Δ = 5 and the center consisting of a single vertex.

Exercise 3.2.

Show that an automorphism of a tree on an odd number ( ≥ 3) of vertices has a fixed vertex; that is, for any automorphism f of a tree T with \(n = 2k + 1\) (k ≥ 1) vertices, there exists a vertex v of T with f(v) = v. (Hint: Use the fact that f permutes the end vertices of T.)

Exercise 3.3.

Show that the distinct eccentricities of the vertices of a (connected) graph G form a set of consecutive integers starting from the radius of G and ending in the diameter of G.

Definitions 4.3.5.

  1. 1.

    A branch at a vertex u of a tree T is a maximal subtree containing u as an end vertex. Hence the number of branches at u is d(u).

    For instance, in Fig. 4.5, there are three branches of the tree at u.

  2. 2.

    The weight of a vertex u of T is the maximum number of edges in any branch at u.

  3. 3.

    A vertex v is a centroid vertex of T if v has minimum weight. The set of all centroid vertices is called the centroid of T.

Fig. 4.5
figure 5

Tree showing three branches at u

In Fig. 4.6 the numbers in the parentheses indicate the weights of the corresponding vertices. It is clear that all the end vertices of T have the same weight, namely, m(T).

Fig. 4.6
figure 6

Weights of vertices of a tree

As in the case of centers, any tree has a centroid consisting of either two adjacent vertices or a single vertex. But there is no relation between the center and centroid of a tree either with regard to the number of vertices or with regard to their location.

Exercise 3.4.

Give an example of

  1. (i)

    A tree with just one central vertex that is also a centroidal vertex;

  2. (ii)

    A tree with two central vertices, one of which is also a centroidal vertex;

  3. (iii)

    A tree with two centroidal vertices, one of which is also a central vertex;

  4. (iv)

    A tree with two central vertices, both of which are also centroidal vertices; and

  5. (v)

    A tree with a disjoint center and centroid.

Exercise 3.5.

Show that the radius of a tree T is equal to { ∖ lceil}{diam(T)} {2} { ∖ rceil}.

Exercise 3.6.

Show that in a tree, any path of maximum length contains the center of the tree.

Exercise 3.7.

Show that the center of a tree consists of two adjacent vertices if and only if its diameter is even.

4.4 Counting the Number of Spanning Trees

Counting the number of spanning trees in a graph occurs as a natural problem in many branches of science. Spanning trees were used by Kirchoff to generate a “cycle basis” for the cycles in the graphs of electrical networks. In this section, we consider the enumeration of spanning trees in graphs.

The number of spanning trees of a connected labeled graph G will be denoted by τ(G). If G is disconnected, we take τ(G) = 0. There is a recursive formula for τ(G). Before we establish this formula, we shall define the concept of edge contraction in graphs.

Definition 4.4.1.

An edge e of a graph G is said to be contracted if it is deleted from G and its ends are identified. The resulting graph is denoted by G ∘ e.

Edge contraction is illustrated in Fig. 4.7.

Fig. 4.7
figure 7

Edge contraction

If e is not a loop of G, then \(n(G \circ e) = n(G) - 1\), \(m(G \circ e) = m(G) - 1\), and ω(G ∘ e) = ω(G). For a loop e, n(G ∘ e) = n(G), \(m(G \circ e) = m(G) - 1\), and ω(G ∘ e) = ω(G). Theorem 4.4.2 gives a recursive formula for τ(G).

Theorem 4.4.2.

If e is not a loop of a connected graph G, \(\tau (G) = \tau (G - e) + \tau (G \circ e).\)

Proof.

τ(G) is the sum of the number of spanning trees of G containing e and the number of spanning trees of G not containing e.

Since \(V (G - e) = V (G)\), every spanning tree of G − e is a spanning tree of G not containing e, and conversely, any spanning tree of G for which e is not an edge is also a spanning tree of G − e. Hence the number of spanning trees of G not containing e is precisely the number of spanning trees of G − e, that is, τ(G − e). If T is a spanning tree of G containing e, the contraction of e in both T and G results in a spanning tree T ∘ e of G ∘ e.

Conversely, if T 0 is a spanning tree of G ∘ e, there exists a unique spanning tree T of G containing e such that T ∘ e = T 0. Thus, the number of spanning trees of G containing e is τ(G ∘ e). Hence \(\tau (G) = \tau (G - e) + \tau (G \circ e)\).

We illustrate below the use of Theorem 4.4.2 in calculating the number of spanning trees. In this illustration, each graph within parentheses stands for the number of its spanning trees. For example,

stands for the number of spanning trees of C 4.

Example 4.4.3.

Find τ(G) for the following graph G:

Hence τ(G) = 12.

We have seen in Sect. 3.2 that every connected graph has a spanning tree. When will it have k edge-disjoint spanning trees? An answer to this interesting question was given by both Tutte [181] and Nash-Williams [145] at just about the same time.

Theorem 4.4.4 (Tutte [181]; Nash-Williams [145]). 

A simple connected graph G contains k pairwise edge-disjoint spanning trees if and only if for each partition \(\mathcal{P}\) of V (G) into p parts, the number \(m(\mathcal{P})\) of edges of G joining distinct parts is at least k(p − 1), 2 ≤ p ≤|V (G)|.

Proof.

We prove only the easier part of the theorem (necessity of the condition). Suppose G has k pairwise edge-disjoint spanning trees. If T is one of them and if \(\mathcal{P} =\{ {V }_{1},\ldots,{V }_{p}\}\) is a partition of V (G) into p parts, then G must have at least \(\vert \mathcal{P}\vert - 1\) edges of T. As this is true for each of the k pairwise edge-disjoint trees of G, the number of edges joining distinct parts of \(\mathcal{P}\) is at least k(p − 1).

For the proof of the converse part of the theorem, we refer the reader to the references cited.

As a consequence of Theorem 4.4.4, we obtain immediately at least one family of graphs that possesses the property stated in the theorem.

Corollary 4.4.5.

Every 2k-edge-connected (k ≥ 1) graph contains k pairwise edge-disjoint spanning trees.

Proof.

Let G be 2k-edge connected, and let \(\mathcal{P} =\{ {V }_{1},\ldots,{V }_{p}\}\) be a partition of V into p subsets. By hypothesis on G, there are at least 2k edges from each part V i to \(V \setminus {V }_{i} ={ \bigcup \nolimits }_{\stackrel{j=1}{ j\neq i}}^{p}\ {V }_{j}\). The total number of such edges is at least kp (as each such edge is counted twice). Hence, \(m(\mathcal{P}) \geq kp > k(p - 1)\). Theorem 4.4.4 now ensures that there are at least k pairwise edge-disjoint spanning trees in G.

Setting k = 2 in the above corollary, we get the result of Kundu.

Corollary 4.4.6 (Kundu [128]). 

Every 4-edge-connected graph contains two edge-disjoint spanning trees.

Corollary 4.4.7.

Every 3-edge-connected graph G has three spanning trees whose intersection is a spanning totally disconnected subgraph of G.

Proof.

Let G be a 3-edge-connected graph. Duplicate each edge of G by a parallel edge. The resulting graph, say, G , is 6-edge connected, and hence by Corollary 4.4.5, G has three pairwise edge-disjoint spanning trees, say, T 1 , T 2 , and T 3 . Hence E(T 1  ∩ T 2  ∩ T 3 ) = ϕ. Let T i , 1 ≤ i ≤ 3, be the tree obtained from T i by replacing any parallel edge of G by its original edge in G. Then, clearly, T 1, T 2, and T 3 are three spanning trees of G with E(T 1 ∩ T 2 ∩ T 3) = ϕ because neither an edge of G nor its parallel edge can belong to all of T 1 , T 2 , and T 3 .

4.5 Cayley’s Formula

Cayley was the first mathematician to obtain a formula for the number of spanning trees of a labeled complete graph.

Theorem 4.5.1 (Cayley [33]). 

\(\tau ({K}_{n}) = {n}^{n-2},\) where K n is a labeled complete graph on n vertices, n ≥ 2.

Before we prove Theorem 4.5.1, we establish two lemmas.

Lemma 4.5.2.

Let (d 1 ,…,d n ) be a sequence of positive integers with \({\sum \nolimits }_{i=1}^{n}\ {d}_{i} = 2(n - 1)\) . Then there exists a tree T with vertex set {v 1 ,…,v n } and d(v i ) = d i , 1 ≤ i ≤ n.

Proof.

It is easy to prove the result by induction on n.

Lemma 4.5.3.

Let {v 1 ,…,v n }, n ≥ 2 be given and let {d 1 ,…,d n } be a sequence of positive integers such that \({\sum \nolimits }_{i=1}^{n}\ {d}_{i} = 2(n - 1)\) . Then the number of trees with {v 1 ,…,v n } as the vertex set in which v i has degree d i , 1 ≤ i ≤ n, is \(\frac{(n-2)!} {({d}_{1}-1)!\ \ldots \ ({d}_{n}-1)!}.\)

Proof.

We prove the result by induction on n. For n = 2, \(2(n - 1) = 2\), so that \({d}_{1} + {d}_{2} = 2\). Since d 1 ≥ 1 and d 2 ≥ 1, \({d}_{1} = {d}_{2} = 1\). Hence K 2 is the only tree in which v i has degree d i , i = 1, 2. So the result is true for n = 2. Now assume that the result is true for all positive integers up to n − 1, n ≥ 3. Let {d 1, , d n } be a sequence of positive integers such that \({\sum \nolimits }_{i=1}^{n}\ {d}_{i} = 2(n - 1)\), and let {v 1, , v n } be any set. If d i  ≥ 2 for every i, 1 ≤ i ≤ n, then ∑ i = 1 n d i  ≥ 2n. Hence, there exists an i, 1 ≤ i ≤ n, for which d i  = 1. For the sake of definiteness, assume that d n  = 1. By Lemma 4.5.2, there exists a tree T with V (T) = { v 1, , v n } and degree of v i  = d i . Let v j be the unique vertex of T adjacent to v n . Delete v n from T. The resulting graph is a tree T with {v 1, , v n − 1} as its vertex set and \(({d}_{1},\ldots,{d}_{j-1},{d}_{j} - 1,{d}_{j+1},\ldots,{d}_{n-1})\) as its degree sequence.

In the opposite direction, given a tree T with {v 1, , v n − 1} as its vertex set and \(({d}_{1},\ldots,{d}_{j-1},{d}_{j} - 1,{d}_{j+1},\ldots,{d}_{n-1})\) as its degree sequence, a tree T with vertex set {v 1, , v n } and degree sequence (d 1, , d n ), d n  = 1, can be obtained by introducing a new vertex v n and taking \(T = {T}^{{\prime}} + {v}_{j}{v}_{n}\). Hence the number of trees with vertex set {v 1, , v n } and degree sequence (d 1, , d n ) with d n  = degree of v n  = 1 and v n adjacent to v j is the same as the number of trees with vertex set {v 1, , v n − 1} and degree sequence \(({d}_{1},\ldots,{d}_{j-1},{d}_{j} - 1,{d}_{j+1},\ldots,{d}_{n-1})\). By the induction hypothesis, the latter number is equal to

$$\begin{array}{ccc} \frac{(n - 3)!} {({d}_{1} - 1)!\ \ldots \ ({d}_{j-1} - 1)!\ ({d}_{j} - 2)!\ ({d}_{j+1} - 1)!\ \ldots \ ({d}_{n-1} - 1)!}\qquad & \\ \quad = \frac{(n - 3)!({d}_{j} - 1)} {({d}_{1} - 1)!\ \ldots \ ({d}_{j-1} - 1)!\ ({d}_{j} - 1)!\ ({d}_{j+1} - 1)!\ \ldots \ ({d}_{n-1} - 1)!}.& \end{array}$$

Summing over j, the number of trees with {v 1, , v n } as its vertex set and (d 1, , d n ) as its degree sequence is

$$\begin{array}{rcl} & \sum\limits_{j=1}^{n-1}\ \frac{(n-3)!\ ({d}_{j}-1)} {({d}_{1}-1)!\ \ldots \ ({d}_{n-1}-1)!} & \\ & \quad = \frac{(n-3)!} {({d}_{1}-1)!\ \ldots \ ({d}_{n-1}-1)!}\ \sum\limits_{j=1}^{n-1}\ ({d}_{j} - 1) & \\ & \quad = \frac{(n-3)!} {({d}_{1}-1)!\ \ldots \ ({d}_{n-1}-1)!}\ \left [\left (\sum\limits_{j=1}^{n-1}\,{d}_{j}\right ) - (n - 1)\right ]& \\ & \quad = \frac{(n-3)!} {({d}_{1}-1)!\ \ldots \ ({d}_{n-1}-1)!}\left [(2n - 3) - (n - 1)\right ] & \\ & \quad = \frac{(n-3)!} {({d}_{1}-1)!\ \ldots \ ({d}_{n-1}-1)!}\,(n - 2) & \\ & \quad = \frac{(n-2)!} {({d}_{1}-1)!\ \ldots \ ({d}_{n-1}-1)!} & \\ & \quad = \frac{(n-2)!} {({d}_{1}-1)!\ \ldots \ ({d}_{n}-1)!}\ (\text{ recall that}\ {d}_{n} = 1). & \\ \end{array}$$

This completes the proof of Lemma 4.5.2.

Proof of theorem  4.5.1. The total number of trees T n with vertex set {v 1, , v n } is obtained by summing over all possible sequences (d 1, , d n ) with \({\sum \nolimits }_{i=1}^{n}\ {d}_{i} = 2n - 2\). Hence,

$$\begin{array}{rcl} \tau ({K}_{n})& =& \sum\limits_{{d}_{i}\geq 1}\ \frac{(n - 2)!} {({d}_{1} - 1)!\ \ldots \ ({d}_{n} - 1)!}\ \mathrm{with}\ \sum\limits_{i=1}^{n}\ {d}_{ i} = 2n - 2 \\ & =& \sum\limits_{{k}_{i}\,\geq \,0}\frac{(n - 2)!} {{k}_{1}!\ \ldots \ {k}_{n}!} \ \mathrm{with}\ \sum\limits_{i=1}^{n}\ {k}_{ i} = n - 2,\ \mathrm{where}\ {k}_{i} = {d}_{i} - 1,1 \leq i \leq n\end{array}$$

Putting \({x}_{1} = {x}_{2} = \cdots = {x}_{n} = 1\) and \(m = n - 2\) in the multinomial expansion \({({x}_{1} + {x}_{2} + \cdots + {x}_{n})}^{m} =\sum\limits_{{k}_{i}\geq 0}\ \dfrac{{x}_{1}^{{k}_{1}}\,{x}_{2}^{{k}_{2}}\,\ldots \,{x}_{n}^{{k}_{n}}} {{k}_{1}!\,{k}_{2}!\ldots {k}_{n}!} \ m!\) with \(({k}_{1} + {k}_{2} + \cdots + {k}_{n}) = m\), we get \({n}^{n-2} =\sum\limits_{{k}_{i}\geq 0}\, \dfrac{(n - 2)!} {{k}_{1}!\,{k}_{2}!\ldots {k}_{n}!}\) with \(({k}_{1} + {k}_{2} + \cdots + {k}_{n}) = n - 2\). Thus, \(\tau ({K}_{n}) = {n}^{n-2}\).

4.6 Helly Property

Definitions 4.6.1.

A family {A i  : i ∈ I} of subsets of a set A is said to satisfy the Helly property if, whenever J ⊆ I and A i   ∩ A j ≠ϕ for every i, j ∈ J, then ⋂ j ∈ J A j ≠ϕ.

Theorem 4.6.2.

Any family of subtrees of a tree satisfies the Helly property.

Proof.

Let  = { T i  : i ∈ I} be a family of subtrees of a tree T. Suppose that for all i, j ∈ J ⊆ I, T i  ∩ T j ≠ϕ. We have to prove that ⋂ j ∈ J T j ≠ϕ. If for some i ∈ J, tree T i is a single-vertex tree {v} (i.e., K 1), then, clearly, ⋂ j ∈ J T j  = { v}. We therefore suppose that each tree T i  ∈  with i ∈ J has at least two vertices.

We now apply induction on the number of vertices of T. Let the result be true for all trees with at most n vertices, and let T be a tree with (n + 1) vertices. Let v 0 be an end vertex of T, and u 0 its unique neighbor in T. Let \({T}_{i}^{{\prime}} = {T}_{i} - {v}_{0}\), i ∈ J, and \({T}^{{\prime}} = T - {v}_{0}\). (If v 0T i , we take T i  = T i .) By the induction assumption, the result is true for the tree T . Moreover, T i  ∩ T j ≠ϕ for any i, j ∈ J. In fact, if T i and T j have a vertex u (≠ v 0) in common, then T i and T j also have u in common, whereas if T i and T j have v 0 in common, then T i and T j have u 0 also in common and so do T i and T j . Hence, by the induction assumption, ⋂ j ∈ J T j ≠ϕ, and therefore ⋂ j ∈ J T j ≠ϕ.

Exercise 6.1.

In the cycle C 5, give a family of five paths such that the intersection of the vertex sets of any two of them is nonempty while the intersection of the vertex sets of all of them is empty.

Exercise 6.2.

Prove that a connected graph G is a tree if and only if every family of paths in G satisfies the Helly property.

4.7 Applications

We conclude this chapter by presenting some immediate applications of trees in everyday life problems.

4.7.1 The Connector Problem

Problems 1.

Various cities in a country are to be linked via roads. Given the various possibilities of connecting the cities and the costs involved, what is the most economical way of laying roads so that in the resulting road network, any two cities are connected by a chain of roads? Similar problems involve designing railroad networks and water-line transports.

Problems 2.

A layout for a housing settlement in a city is to be prepared. Various locations of the settlement are to be linked by roads. Given the various possibilities of linking the locations and their costs, what is the minimum-cost layout so that any two locations are connected by a chain of roads?

Problems 3.

A layout for the electrical wiring of a building is to be prepared. Given the costs of the various possibilities, what is the minimum-cost layout?

These three problems are particular cases of a graph-theoretical problem known as the connector problem.

Definition 4.7.1.

Let G be a graph. To each edge e of G, we associate a nonnegative number w(e) called its weight. The resulting graph is a weighted graph. If H is a subgraph of G, the sum of the weights of the edges of H is called the weight of H. In particular, the sum of the weights of the edges of a path is called the weight of the path.

We shall now concentrate on Problem 1. Problems 2 and 3 can be dealt with similarly. Let G be a graph constructed with the set of cities as its vertex set. An edge of G corresponds to a road link between two cities. The cost of constructing a road link is the weight of its corresponding edge. Then a minimum-weight spanning tree of G provides the most economical layout for the road network.

We present two algorithms, Kruskal’s algorithm and Prim’s algorithm, for determining a minimum-weight spanning tree in a connected weighted graph. We can assume, without loss of generality, that the graph is simple because, since no loop can be an edge of a spanning tree, we can discard all loops. Also, since we are interested in determining a minimum-weight spanning tree, we can retain, from a set of multiple edges having the same ends, an edge with the minimum weight, and we can discard all the others.

First, we describe Kruskal’s algorithm [127].

4.7.2 Kruskal’s Algorithm

Let G be a simple connected weighted graph with edge set E = { e 1, , e m }. The three steps of the algorithm are as follows:

Step 1 : :

Choose an edge e 1 with its weight w(e 1) as small as possible.

Step 2 : :

If the edges e 1, e 2, , e i , i ≥ 1, have already been chosen, choose e i + 1 from the set E ∖ {e 1, e 2, , e i } such that

  1. (i)

    The subgraph induced by the edge set {e 1, e 2, , e i + 1} is acyclic, and

  2. (ii)

    w(e i + 1) is as small as possible subject to (i).

Step 3 : :

Stop when step 2 cannot be implemented further.

We now show that Kruskal’s algorithm does indeed produce a minimum-weight spanning tree.

Theorem 4.7.2.

Any spanning tree produced by Kruskal’s algorithm is a minimum-weight spanning tree.

Proof.

Let G be a simple connected graph of order n with edge set E(G) = { e 1, , e m }. Let T  ∗  be a spanning tree produced by Kruskal’s algorithm and let \(E({T}^{{_\ast}}) =\{ {e}_{1},\ldots,{e}_{n-1}\}\). For any spanning tree T of G, let f(T) be the least value of i such that e i E(T). Suppose T  ∗  is not of minimum weight. Let T 0 be any minimum-weight spanning tree with f(T 0) as large as possible.

Suppose f(T 0) = k. This means that e 1, , e k − 1 are in both T 0 and T  ∗ , but e k T 0. Then T 0 + e k contains a unique cycle C. Since not every edge of C can be in T  ∗ , C must contain an edge e k not belonging to T  ∗ . Let \({T}_{0}^{{\prime}} = {T}_{0} + {e}_{k} - {e}_{k}^{{\prime}}\). Then T 0 is another spanning tree of G. Moreover,

$$w({T}_{0}^{{\prime}}) = w({T}_{ 0}) + w({e}_{k}) - w({e}_{k}^{{\prime}}).$$
(4.1)

Now, in Kruskal’s algorithm, e k was chosen as an edge with the smaller weight such that G[{e 1, , e k − 1, e k }] was acyclic. Since G[{e 1, , e k − 1, e k }] is a subgraph of the tree T 0, it is also acyclic. Hence,

$$w({e}_{k}) \leq w({e}_{k}^{{\prime}}),$$
(4.2)

and therefore from (4.1) and (4.2),

$$\begin{array}{rcl} w({T}_{0}^{{\prime}})& = w({T}_{ 0}) + w({e}_{k}) - w({e}_{k}^{{\prime}})& \\ & \leq w({T}_{0}). & \\ \end{array}$$

But T 0 is of minimum weight. Hence, w(T 0 ) = w(T 0), and so T 0 is also of minimum weight. However, as {e 1, , e k } ⊂ E(T 0 ),

$$f({T}_{0}^{{\prime}}) > k = f({T}_{ 0}),$$

contradicting the choice of T 0. Thus, T  ∗  is a minimum-weight spanning tree of G.

When the graph is not weighted, we can give the weight 1 to each of its edges and then apply the algorithm. The algorithm then gives an acyclic subgraph with as many edges as possible, that is, a spanning tree of G.

Illustration

The distances in miles between some of the Indian cities connected by air are given in Table 4.1.

Table 4.1 Mileage between Indian cities

Determine a minimum-cost operational system so that every city is connected to every other city. Assume that the cost of operation is directly proportional to the distance.

Let G be a graph with the set of cities as its vertex set. An edge corresponds to a pair of cities for which the ticketed mileage is indicated. The ticketed mileage is the weight of the corresponding edge (see Fig. 4.8).

Fig. 4.8
figure 8

Graph of mileage between cities

The required operation system demands a minimum-cost spanning tree of G. We shall apply Kruskal’s algorithm and determine such a system. The following is a sequence of edges selected according to the algorithm.

$$HN,\,HCh,\,HM,\,ND,\,NCa.$$

The corresponding spanning tree is shown in bold lines, and its weight is \(255 + 329 + 385 + 531 + 679 = 2,179\).

We next describe Prim’s algorithm [159].

4.7.3 Prim’s Algorithm

Let G be a simple connected weighted graph having n vertices. Let the vertices of G be labeled as v 1, v 2, , v n . Let \(W = W(G) = ({w}_{ij})\) be the weight matrix of G. That is, W is the n ×n matrix with

  1. (i)

    w ii  = , for 1  ≤ i  ≤ n,

  2. (ii)

    \({w}_{ij} = {w}_{ji} =\)the weight of the edge (v i , v j ) if v i and v j are adjacent,

  3. (iii)

    \({w}_{ij} = {w}_{ji} = \infty \) if v i and v j are nonadjacent.

The algorithm constructs a minimum-cost spanning tree.

Step 1::

Start with v 1. Connect v 1 to v k , where v k is a nearest vertex to v 1 (v k is nearest to v 1 if v 1 v k is an edge with minimum possible weight). The vertex v k could be easily determined by observing the matrix W. Actually, v k is a vertex corresponding to which the entry in row 1 of W is minimum.

Step 2::

Having chosen v k , let v i v 1 or v k be a vertex corresponding to the smallest entry in rows 1 and k put together. Then v i is the vertex “nearest” the edge subgraph defined by the edge v 1 v k . Connect v i to v 1 or v k , according to whether the entry is in the first row or kth row. Suppose it is, say, in the kth row; then it is the (k, i)th entry of W.

Step 3::

Consider the edge subgraph defined by the edge set {v 1 v k , v k v i }. Determine the nearest neighbor to the set of vertices {v 1, v k , v i }.

Step 4::

Continue the process until all the n vertices have been connected by (n − 1) edges. This results in a minimum-cost spanning tree.

Proof of correctness: Let T be a tree obtained by applying Prim’s algorithm. We want to show that T is a minimum-weight spanning tree (that is, an optimal tree) of G. We prove by induction on n =  | V (G) | . Suppose e = v 1 v 2 is an edge of least weight incident at v 1.

Claim.

There exists a minimum-weight spanning tree of G that contains e. To see this, consider an optimal tree T of G. Suppose T does not contain e. As T contains the vertex v 1, T must contain some edge f of G incident at v 1. By Prim’s algorithm, w(e) ≤ w(e ) for every edge e of G incident at v 1 and consequently, w(e) ≤ w(f), where w denotes the weight function. Hence, the spanning tree \({T}^{{\prime\prime}} = {T}^{{\prime}} + e - f\) of G has the property that \(w({T}^{{\prime\prime}}) = w({T}^{{\prime}}) + w(e) - w(f) \leq w({T}^{{\prime}})\).

As T is optimal, T ′′ is also optimal. But T ′′ contains e. This establishes our claim.

Let G  = G ∘ e, the contraction of G obtained by contracting the edge e. Every spanning tree of G that contains e gives rise to a unique spanning tree of G . Conversely, every spanning tree of G gives rise to a unique spanning tree of G containing e.

Let S denote the set of vertices of the tree T p (with e ∈ E(T p )) grown by Prim’s algorithm at the end of p steps, p ≥ 2, and S denote the set of vertices of T p  = T p  ∘ e. Then [S, V (G) ∖ S] = [S , V (G ) ∖ S ]. Therefore, an edge of minimum weight in [S, V (G) ∖ S] is also an edge of minimum weight in [S , V (G ) ∖ S ]. As the final tree T is a Prim tree of G, the final tree T ∘ e of G is a Prim tree of G . But then G has one vertex less than that of G and so T ∘ e is an optimal tree of G ∘ e. Consequently, T is an optimal tree of G.

Illustration

Consider the weighted graph G shown in Fig. 4.8. The weight matrix W of G is

In row M (i.e., in the row corresponding to the city M, namely, Mumbai), the smallest weight is 385, which occurs in column H. Hence join M and H. Now, after omitting columns M and H, 255 is the minimum weight in the rows M and H put together. It occurs in row H and column N. Hence, join H and N. Now, omitting columns M, H, and N, the smallest number in the rows M, H, and N put together is 329, and it occurs in row H and column Ch, so join H and Ch. Again, the smallest entry in rows M, H, N and Ch not belonging to the corresponding columns is 531, and it occurs in row N and column D. So join N and D. Now, the lowest entry in rows M, H, N, D and Ch not belonging to the corresponding columns is 679, and it occurs in row N and column Ca. So join N and Ca. This construction gives the same minimum-weight spanning tree of Fig. 4.8.

Remark.

In each iteration of Prim’s algorithm, a subtree of a minimum-weight spanning tree is obtained, whereas in any step of Kruskal’s algorithm, just a subgraph of a minimum-weight spanning tree is constructed.

4.7.4 Shortest-Path Problems

A manufacturing concern has a warehouse at location X and the market for the product at another location Y. Given the various routes of transporting the product from X to Y and the cost of operating them, what is the most economical way of transporting the materials? This problem can be tackled using graph theory. All such optimization problems come under a type of graph-theoretic problem known as “shortest-path problems.” Three types of shortest-path problems are well known:

Let G be a connected weighted graph.

  1. 1.

    Determine a shortest path, that is, a minimum-weight path between two specified vertices of G.

  2. 2.

    Determine a set of shortest paths between all pairs of vertices of G.

  3. 3.

    Determine a set of shortest paths from a specified vertex to all other vertices of G.

We consider only the first problem. The other two problems are similar. We describe Dijkstra’s algorithm [52] for determining the shortest path between two specified vertices. Once again, it is clear that in shortest-path problems, we could restrict ourselves to simple connected weighted graphs.

4.7.5 Dijkstra’s Algorithm

Let G be a simple connected weighted graph having vertices v 1, v 2, , v n . Let s and t be two specified vertices of G. We want to determine a shortest path from s to t. Let W be the weight matrix of G. Dijkstra’s algorithm allots weights to the vertices of G. At each stage of the algorithm, some vertices have permanent weights and others have temporary weights.

To start with, the vertex s is allotted the permanent weight 0 and all other vertices the temporary weight . In each iteration of the algorithm, one new vertex is allotted a permanent weight by the following rules:

Rule 1::

If v j is a vertex that has not yet been allotted a permanent weight, determine for each vertex v i that had already been allotted a permanent weight,

$${\alpha }_{ij} =\min \{ \text{ old weight of }{v}_{j},\,\text{ (old weight of }{v}_{i}) + {w}_{ij}\}.$$

Let w j  = Min i  α ij . Then w j is a new temporary weight of v j not exceeding the previous temporary weight.

Rule 2::

Determine the smallest among the w j ’s. If this smallest weight is at v k , w k becomes the permanent weight of v k . In case there is a tie, any one vertex is taken for allotting a permanent weight.

The algorithm stops when the vertex t gets a permanent weight.

It is clear from the algorithm that the permanent weight of each vertex is the shortest weighted distance from s to that vertex. The shortest path from s to t is constructed by working backward from the terminal vertex t. Let P be a shortest path and p i a vertex of P. The weight of p i − 1, the vertex immediately preceding p i on P, is such that the weight of the edge p i − 1 p i equals the difference in permanent weights of p i and p i − 1.

We present below an illustrative example. Let us find the shortest path from A to B in the graph of Fig. 4.9.

Fig. 4.9
figure 9

Graph of mileage between cities

We present the various iterations of the algorithm by arrays of weights of the vertices, one consisting of weights before iteration and another after it. Temporary weights will be enclosed in squares and the permanent weights enclosed in double squares. The steps of the algorithm for determining the shortest path from vertex A to vertex B in graph G of Fig. 4.9 are given in Table 4.2.

Table 4.2 Steps of algorithm for shortest path from A to B

In our example, B is the last vertex to get a permanent weight. Hence the algorithm stops after Iteration 6, in which B is allotted the permanent weight. However, the algorithm may be stopped as soon as vertex B gets the permanent weight.

The shortest distance from A to B is 8. A shortest path with weight 8 is AFEDB.

4.8 Exercises

  1. 8.1.

    Show that any tree of order n contains a subtree of order k for every k ≤ n.

  2. 8.2.

    Let u, v, w be any three vertices of a tree T. Show that either u, v, w all lie in a path of T or else there exists a unique vertex z of T which is common to the u-v, v-w, w-u paths of T.

  3. 8.3.

    Show that in a tree, the number of vertices of degree at least 3 is at most the number of end vertices minus 2.

  4. 8.4.

    Show that if G is a connected graph with at least three vertices, then G contains two vertices u and v such that G − { u, v} is also connected.

  5. 8.5.

    * If H is a graph of minimum degree at least k − 1, then prove that H contains every tree on k vertices. (Hint: Prove by induction on k.) (See [88].)

  6. 8.6.

    Prove that a nontrivial simple graph G is a tree if and only if for any set of r distinct vertices in G, r ≥ 2, the minimum number of edges required to separate them is r − 1. (See E. Sampathkumar [168].)

  7. 8.7.

    Show that a simple connected graph contains at least \(m - n + 1\) distinct cycles.

  8. 8.8.

    Prove that for a connected graph G, r(G) ≤ diam(G) ≤ 2r(G). (The graphs of Fig. 4.3 show that the inequalities can be strict.)

  9. 8.9.

    Prove that a tree with at least three vertices has diameter 2 if and only if it is a star.

  10. 8.10.

    Determine the number of spanning trees of the two graphs in Fig. 4.10:

    figure 10

    Fig. 4.10

    figure 11

    Fig. 4.11

  11. 8.11.

    If T is a tree with at least two vertices, show that there exists a set of edge-disjoint paths covering all the vertices of T such that each of these paths has at least one end vertex that is an end vertex of T.

  12. 8.12.

    Let T be a tree of order n with V (T) = { 1, 2, , n}, and let A be a set of transpositions defined by A = { (i, j) : ij ∈ E(T)}. Show that A is a minimal set of transpositions that generates the symmetric group S n .

  13. 8.13.

    For the graph G of Fig. 4.11, determine two distinct minimum-weight spanning trees using

    1. (i)

      Kruskal’s algorithm,

    2. (ii)

      Prim’s algorithm.

    What is the weight of such a tree? Also, determine a minimum-weight s-t path using Dijkstra’s algorithm.

  14. 8.14.

    Apply Prim’s algorithm to the illustrative example given in Sect. 4.7.3 by starting from the third row of the weight matrix.

  15. 8.15.

    If G is a connected weighted graph in which no two edges have the same weight, show that G has a unique minimum-weight spanning tree.

  16. 8.16.

    Establish the correctness of Dijkstra’s algorithm.

4.9 Notes

In 1847, G. R. Kirchoff (1824–1887) developed the theory of trees for their applications in electrical networks. Ten years later, in 1857, the English mathematician A. Cayley (1821–1895) rediscovered trees while he was trying to enumerate the isomers of the saturated hydrocarbons C n H 2n + 2 (see also Chap. 1). Since then “trees” have grown both vertically and horizontally. They are widely used today in computer science.

There is also a simpler (?) proof of the converse part of Theorem 4.4.4 using matroid theory (see pp. 126–127 of [191]).

Corollary 4.4.6 is due to Kilpatrick [122], but the elegant proof given here is due to Jaeger [114]. The proof of Cayley’s theorem presented here (Theorem 4.5.1) is based on Moon [142], which also contains nine other proofs. The book by Serre [170] entitled Trees is mainly concerned with the connection between trees and the group SL 2(Q p ).

For general algorithmic results related to graphs, see [3, 72, 153].