• Tidak ada hasil yang ditemukan

Counting Trees

Dalam dokumen Undergraduate Texts in Mathematics (Halaman 55-63)

1.3 Trees

1.3.4 Counting Trees

6. Prim’s algorithm (from [228]) provides another method for finding mini- mum weight spanning trees.

Prim’s Algorithm

Given: A connected, weighted graphG.

i. Choose a vertexv, and mark it.

ii. From among all edges that have one marked end vertex and one un- marked end vertex, choose an edgeeof minimum weight. Mark the edgee, and also mark its unmarked end vertex.

iii. If every vertex ofGis marked, then the set of marked edges forms a minimum weight spanning tree. If not, repeat step ii.

Use Prim’s algorithm to find minimum weight spanning trees for the graphs in Figure 1.44. As you work, compare the stages to those of Kruskal’s al- gorithm.

7. Give an example of a connected, weighted graphGhaving (i) a cycle with two identical weights, which is neither the smallest nor the largest weight in the graph, and (ii) a unique minimum weight spanning tree which contains exactly one of these two identical weights.

a

b c

a

b c

a

b c

FIGURE 1.45. Labeled trees on three vertices.

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

a b

c d

FIGURE 1.46. Labeled trees on four vertices.

Cayley proved the following theorem in 1889 [50]. The proof technique that we will describe here is due to Pr¨ufer7[229]. Pr¨ufer’s method is almost as noteworthy as the result itself. He counted the labeled trees by placing them in one-to-one cor- respondence with a set whose size is easy to determine—the set of all sequences of lengthn−2whose entries come from the set{1, . . . , n}. There arenn2such sequences.

Theorem 1.18 (Cayley’s Tree Formula). There arenn2distinct labeled trees of ordern.

The algorithm below gives the steps that Pr¨ufer used to assign a particular se- quence to a given tree,T, whose vertices are labeled1, . . . , n. Each labeled tree is assigned a unique sequence.

7With a name like that he was destined for mathematical greatness!

Pr ¨ufer’s Method for Assigning a Sequence to a Labeled Tree Given: A treeT, with vertices labeled1, . . . , n.

1. Leti= 0, and letT0=T.

2. Find the leaf onTiwith the smallest label and call itv.

3. Record in the sequence the label ofv’s neighbor.

4. RemovevfromTito create a new treeTi+1.

5. IfTi+1 =K2, then stop. Otherwise, incrementiby 1 and go back to step 2.

Let us run through this algorithm with a particular graph. In Figure 1.47, tree T =T0 has 7 vertices, labeled as shown. The first step is finding the leaf with smallest label: This would be 2. The neighbor of vertex 2 is the vertex labeled 4. Therefore, 4 is the first entry in the sequence. Removing vertex 2 produces treeT1. The leaf with smallest label inT1is 4, and its neighbor is 3. Therefore, we put 3 in the sequence and delete 4 fromT1. Vertex 5 is the smallest leaf in treeT2 = T1− {4}, and its neighbor is1. So our sequence so far is 4, 3, 1. In T3=T2−{5}the smallest leaf is vertex 6, whose neighbor is 3. InT4=T3−{6}, the smallest leaf is vertex 3, whose neighbor is 1. SinceT5 =K2, we stop here.

Our resulting sequence is 4, 3, 1, 3, 1.

Notice that in the previous example, none of the leaves of the original treeT appears in the sequence. More generally, each vertexvappears in the sequence exactlydeg(v)1 times. This is not a coincidence (see Exercise 1). We now present Pr¨ufer’s algorithm for assigning trees to sequences. Each sequence gets assigned a unique tree.

Pr ¨ufer’s Method for Assigning a Labeled Tree to a Sequence

Given: A sequenceσ=a1, a2, . . . , akof entries from the set{1, . . . , k+ 2}.

1. Drawk+2vertices; label themv1,v2, . . . ,vk+2. LetS={1,2, . . . , k+2}.

2. Leti= 0, letσ0=σ, and letS0=S.

3. Letjbe the smallest number inSithat does not appear in the sequenceσi. 4. Place an edge between vertexvj and the vertex whose subscript appears

first in the sequenceσi.

5. Remove the first number in the sequenceσito create a new sequenceσi+1. Remove the elementjfrom the setSito create a new setSi+1.

6. If the sequence σi+1 is empty, place an edge between the two vertices whose subscripts are inSi+1, and stop. Otherwise, incrementiby 1 and return to step 3.

T5

1 7

T4

3 1

7

T3

3 1

6 7

T2

3 1 5

6 7

T1 4 3 1 5

6 7

2

4 3 1

5

6 7

T = T0

Evolving Sequence 4

4, 3

4, 3, 1, 3, 1 4, 3, 1, 3

4, 3, 1

FIGURE 1.47. Creating a Pr¨ufer sequence.

Let us apply this algorithm to a particular example. Letσ = 4,3,1,3,1 be our initial sequence to which we wish to assign a particular labeled tree. Since there are five terms in the sequence, our labels will come from the set S = {1,2,3,4,5,6,7}. After drawing the seven vertices, we look in the setS = S0

to find the smallest subscript that does not appear in the sequenceσ=σ0. Sub- script 2 is the one, and so we place an edge between verticesv2andv4, the first subscript in the sequence. We now remove the first term from the sequence and the label v2 from the set, forming a new sequence σ1 = 3,1,3,1 and a new setS1 ={1,3,4,5,6,7}. The remaining steps in the process are shown in Fig- ure 1.48.

v1

v5 v4

v6 v3

v7 v2

v1

v5 v4

v6 v3

v7 v2

v1

v5 v4

v6 v3

v7 v2

v1

v5 v4

v6 v3

v7 v2

s = s0 = 4, 3, 1, 3, 1 S = S0 = {1, 2, 3, 4, 5, 6, 7}

s1 = 3, 1, 3, 1 S1 = {1, 3, 4, 5, 6, 7}

s2 = 1, 3, 1 S2 = {1, 3, 5, 6, 7}

s3 = 3, 1 S3 = {1, 3, 6, 7}

v1

v5 v4

v6 v3

v7 v2

v1

v5 v4

v6 v3

v7 v2

s4 = 1 S4 = {1, 3, 7}

s5 is empty S5 = {1, 7}

FIGURE 1.48. Building a labeled tree.

You will notice that the tree that was created from the sequenceσin the second example is the very same tree that created the sequenceσin the first example.

Score one for Pr¨ufer!

Matrix Tree Theorem

The second major result that we present in this section is the Matrix Tree The- orem, and like Cayley’s Theorem, it provides a way of counting spanning trees of labeled graphs. While Cayley’s Theorem in essence gives us a count on the number of spanning trees of complete labeled graphs, the Matrix Tree Theorem applies to labeled graphs in general. The theorem was proved in 1847 by Kirch- hoff [175], and it demonstrates a wonderful connection between spanning trees and matrices.

The theorem involves two special matrices. One is the adjacency matrix (de- fined back in Section 1.2.2), and the other is defined as follows. LetGbe a graph with verticesv1, v2, . . . vn. The degree matrix ofGis then×nmatrixDwhose (i, j)entry, denoted by[D]i,j, is defined by

[D]i,j=

deg(vi) ifi=j,

0 otherwise.

So, the diagonal entries ofDare the vertex degrees, and the off-diagonal entries are all zero.

Given ann×nmatrixM, thei, jcofactor ofM is defined to be (1)i+jdet(M(i|j)),

wheredet(M(i|j))represents the determinant of the(n−1)×(n−1)matrix formed by deleting rowiand columnjfromM.

We are now ready to state the Matrix Tree Theorem, due to Kirchhoff. The proof that we give imitates those presented in [148] and [52].

Theorem 1.19 (Matrix Tree Theorem). IfGis a connected labeled graph with adjacency matrixAand degree matrixD, then the number of unique spanning trees ofGis equal to the value of any cofactor of the matrixD−A.

Proof. SupposeGhasnvertices (v1, . . . , vn) andkedges (f1, . . . , fk). SinceG is connected, we know thatkis at leastn−1. LetN be then×kmatrix whose (i, j)entry is defined by

[N]i,j=

1 ifviandfjare incident, 0 otherwise.

N is called the incidence matrix of G. Since every edge ofG is incident with exactly two vertices ofG, each column ofN contains two 1’s andn−2zeros.

LetM be the n×k matrix that results from changing the topmost 1 in each column to1. To prove the result, we first need to establish two facts, which we call Claim A and Claim B.

Claim A.M MT =D−A(whereMTdenotes the transpose ofM).

First, notice that the(i, j)entry ofD−Ais [D−A]i,j=

⎧⎨

deg(vi) ifi=j,

1 ifi=jandvivj ∈E(G), 0 ifi=jandvivj ∈E(G).

Now, what about the(i, j)entry ofM MT? The rules of matrix multiplication tell us that this entry is the dot product of rowiofM and columnjofMT. That is,

[M MT]i,j= ([M]i,1,[M]i,2, . . . ,[M]i,k)·

[MT]1,j,[MT]2,j, . . . ,[MT]k,j

= ([M]i,1,[M]i,2, . . . ,[M]i,k)·([M]j,1,[M]j,2, . . . ,[M]j,k)

= k r=1

[M]i,r[M]j,r.

Ifi = j, then this sum counts one for every nonzero entry in rowi; that is, it counts the degree ofvi. Ifi=jandvivj ∈E(G), then there is no column ofM in which both the rowiand rowjentries are nonzero. Hence the value of the sum in this case is 0. Ifi=jandvivj ∈E(G), then the only column in which both the rowiand the rowjentries are nonzero is the column that represents the edge vivj. Since one of these entries is 1 and the other is1, the value of the sum is

1. We have shown that the(i, j)entry ofM MT is the same as the(i, j)entry ofD−A, and thus Claim A is proved.

LetHbe a subgraph ofGwithnvertices andn−1edges. Letpbe an arbitrary integer between 1 andn, and letM be the(n−1)×(n−1)submatrix ofM formed by all rows ofM except rowpand the columns that correspond to the edges inH.

Claim B. IfH is a tree, then|det(M)|= 1. Otherwise,det(M) = 0.

First suppose thatHis not a tree. SinceHhasnvertices andn−1edges, we know from earlier work thatHmust be disconnected. LetH1be a connected component ofH that does not contain the vertex vp. LetM be the |V(H1)| ×(n−1) submatrix ofMformed by eliminating all rows other than the ones corresponding to vertices ofH1. Each column ofMcontains exactly two nonzero entries:1and

1. Therefore, the sum of all of the row vectors ofMis the zero vector, so the rows ofMare linearly dependent. Since these rows are also rows ofM, we see thatdet(M) = 0.

Now suppose thatH is a tree. Choose some leaf ofH that is notvp (Theo- rem 1.14 lets us know that we can do this), and call itu1. Let us also say thate1is the edge ofH that is incident withu1. In the treeH−u1, chooseu2to be some leaf other thanvp. Lete2be the edge ofH−u1incident withu2. Keep removing leaves in this fashion untilvpis the only vertex left. Having established the list of verticesu1, u2, . . . , un1, we now create a new(n−1)×(n−1)matrixMby rearranging the rows ofMin the following way: rowiofMwill be the row of Mthat corresponds to the vertexui.

An important (i.e., useful!) property of the matrixM is that it is lower tri- angular (we know this because for eachi, vertexui isnot incident with any of ei+1, ei+2, . . . , en1). Thus, the determinant ofMis equal to the product of the main diagonal entries, which are either1or1, since everyuiis incident withei. Thus,|det(M)|= 1, and so|det(M)|= 1. This proves Claim B.

We are now ready to investigate the cofactors ofD −A = M MT. It is a fact from matrix theory that if the row sums and column sums of a matrix are all 0, then the cofactors all have the same value. (It would be a nice exercise—and a nice review of matrix skills—for you to try to prove this.) Since the matrixM MT satisfies this condition, we need to consider only one of its cofactors. We might as well chooseiandjsuch thati+jis even—let us choosei= 1andj= 1. So, the(1,1)cofactor ofD−Ais

det ((D−A)(1|1)) = det

M MT(1|1)

= det(M1M1T)

whereM1is the matrix obtained by deleting the first row ofD−A.

At this point we make use of the Cauchy–Binet Formula, which says that the determinant above is equal to the sum of the determinants of(n−1)×(n−1) submatrices ofM1(for a more thorough discussion of the Cauchy–Binet Formula, see [40]). We have already seen (in Claim B) that any(n−1)×(n−1)submatrix that corresponds to a spanning tree ofGwill contribute 1 to the sum, while all others contribute 0. This tells us that the value ofdet(D−A) = det(M MT)is precisely the number of spanning trees ofG.

Figure 1.49 shows a labeled graphGand each of its eight spanning trees.

v1 v2

v4 v3

FIGURE 1.49. A labeled graph and its spanning trees.

The degree matrixDand adjacency matrixAare

D=

⎢⎢

2 0 0 0 0 2 0 0 0 0 3 0 0 0 0 3

⎥⎥

, A=

⎢⎢

0 0 1 1 0 0 1 1 1 1 0 1 1 1 1 0

⎥⎥

,

and so

D−A=

⎢⎢

2 0 1 1 0 2 1 1

1 1 3 1

1 1 1 3

⎥⎥

.

The(1,1)cofactor ofD−Ais det

⎣ 2 1 1

1 3 1

1 1 3

⎦= 8.

Score one for Kirchhoff!

Exercises

1. LetTbe a labeled tree. Prove that the Pr¨ufer sequence ofTwill not contain any of the leaves’ labels. Also prove that each vertexv will appear in the sequence exactlydeg(v)1times.

2. Determine the Pr¨ufer sequence for the trees in Figure 1.50.

1

2

6 7 8 9 10 11

1 5

4 9

2 3 8

6 7

3 4 5

FIGURE 1.50. Two labeled trees.

3. Draw and label a tree whose Pr¨ufer sequence is 5,4,3,5,4,3,5,4,3.

4. Which trees have constant Pr¨ufer sequences?

5. Which trees have Pr¨ufer sequences with distinct terms?

6. Letebe an edge ofKn. Use Cayley’s Theorem to prove thatKn−ehas (n−2)nn3spanning trees.

7. Use the Matrix Tree Theorem to prove Cayley’s Theorem. Hint: Look back at the discussion prior to the statement of the Matrix Tree Theorem.

Dalam dokumen Undergraduate Texts in Mathematics (Halaman 55-63)