Bang Ye Wu and Kun-Mao Chao
Spanning Trees and
Optimization Problems
(Excerpt)
CRC PRESS
Chapter 1
Counting Spanning Trees
A spanning tree for a graph G is a subgraph of G that is a tree and contains all the vertices of G.
How many trees are there spanning all the vertices in Figure 1.1?
FIGURE 1.1: A four-vertex complete graph K4.
Figure 1.2 gives all 16 spanning trees of the four-vertex complete graph in Figure 1.1.
DEFINITION 1.1 A Pr¨ufer sequence of length n − 2, for n ≥ 2, is any sequence of integers between 1 and n, with repetitions allowed.
LEMMA 1.1
There are nn−2 Pr¨ufer sequences of length n − 2.
Example 1.1
The set of Pr¨ufer sequences of length 2 is {(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4)}. In total, there are 44−2= 16 Pr¨ufer sequences of length 2.
Algorithm: Pr¨ufer Encoding
Input: A labeled tree with vertices labeled by 1, 2, 3, . . . , n. Output: A Pr¨ufer sequence.
Repeat n − 2 times
2 Spanning Trees and Optimization Problems (Excerpt)
FIGURE 1.2: All 16 spanning trees of K4.
v ← the leaf with the lowest label
Put the label of v’s unique neighbor in the output sequence. Remove v from the tree.
Now consider a more complicated tree in Figure 1.3. What is its corre-sponding Pr¨ufer sequence?
Figure 1.4 illustrates the encoding process step by step. Algorithm: Pr¨ufer Decoding
Input: A Pr¨ufer sequence P = (p1, p2, . . . , pn−2).
Output: A labeled tree with vertices labeled by 1, 2, 3, . . . , n. P ← the input Pr¨ufer sequence
Counting Spanning Trees 3
FIGURE 1.3: An eight-vertex spanning tree.
FIGURE 1.4: Generating a Pr¨ufer sequence from a spanning tree.
V ← {1, 2, . . . , n}
Start with n isolated vertices labeled 1, 2, . . . , n. for i = 1 to n − 2 do
4 Spanning Trees and Optimization Problems (Excerpt) Connect vertex v to vertex pi
Remove v from the set V
Remove the element pi from the sequence P
/* Now P = (pi+1, pi+2, . . . , pn−2) */
Connect the vertices corresponding to the two numbers in V .
Figure 1.5 illustrates the decoding process step by step.
Counting Spanning Trees 5 THEOREM 1.1
The number of spanning trees in Kn is nn−2.
Let G − e denote the graph obtained by removing edge e from G. Let G\e denote the resulting graph after contracting e in G. In other words, G\e is the graph obtained by deleting e, and merging its ends. Let τ (G) denote the number of spanning trees of G. The following recursive formula computes the number of spanning trees in a graph.
THEOREM 1.2