46 CHAPTER 2. SPANNING TREESExample 2.3.4 Below is <strong>the</strong> kite. To count <strong>the</strong> <strong>spann<strong>in</strong>g</strong> <strong>trees</strong>, observe that four arepaths around <strong>the</strong> outside cycle <strong>in</strong> <strong>the</strong> draw<strong>in</strong>g. The rema<strong>in</strong><strong>in</strong>g <strong>spann<strong>in</strong>g</strong> <strong>trees</strong> use <strong>the</strong>diagonal edge. S<strong>in</strong>ce we must <strong>in</strong>clude an edge to each vertex <strong>of</strong> degree 2, we obta<strong>in</strong> fourmore <strong>spann<strong>in</strong>g</strong> <strong>trees</strong>. The total is eight.Figure 2.6: A graph G and its all <strong>spann<strong>in</strong>g</strong> <strong>trees</strong>In Example 2.3.4, we counted separately <strong>the</strong> <strong>trees</strong> that did or did not conta<strong>in</strong> <strong>the</strong> diagonaledge. This suggests a recursive procedure to count <strong>spann<strong>in</strong>g</strong> <strong>trees</strong>. It is clear that <strong>the</strong><strong>spann<strong>in</strong>g</strong> <strong>trees</strong> <strong>of</strong> G not conta<strong>in</strong><strong>in</strong>g e are simply <strong>the</strong> <strong>spann<strong>in</strong>g</strong> <strong>trees</strong> <strong>of</strong> G − e, but how dowe count <strong>the</strong> <strong>trees</strong> that conta<strong>in</strong> e? The answer uses an elementary operation on graphs.Remark 2.3.5 We denote by τ(G) <strong>the</strong> <strong>number</strong> <strong>of</strong> <strong>spann<strong>in</strong>g</strong> <strong>trees</strong> <strong>of</strong> a graph G, <strong>some</strong>timescalled <strong>the</strong> complexity <strong>of</strong> G. If G is not connected <strong>the</strong>n τ(G) = 0, so we can assume thatG is connected from now on. If G ′ is obta<strong>in</strong>ed from G by remov<strong>in</strong>g all <strong>the</strong> loops <strong>of</strong> G,<strong>the</strong>n τ(G ′ ) = τ(G), s<strong>in</strong>ce a loop can never occur <strong>in</strong> a <strong>spann<strong>in</strong>g</strong> tree, i.e., loops don’t affect<strong>spann<strong>in</strong>g</strong> <strong>trees</strong>, so we delete <strong>the</strong>m before <strong>the</strong> computation. Thus, we may assume that Gconta<strong>in</strong>s no loops as well. Multiple edges, however, do rema<strong>in</strong> a possibility.2.4 Matrices associated to a graphHow do we specify a graph? We can list <strong>the</strong> vertices and edges (with end-po<strong>in</strong>ts), but<strong>the</strong>re are o<strong>the</strong>r useful representations. Say<strong>in</strong>g that a graph is loopless means that multipleedges are allowed but loops are not. We need to def<strong>in</strong>e <strong>some</strong> matrices as follows.2.4.1 Adjacency MatrixThe adjacency matrix <strong>of</strong> a graph G is <strong>the</strong> square matrix A = A(G) <strong>in</strong>dexed by V × V ,which has its entries as: A vv = 0 for all v ∈ V , and if v ≠ u <strong>in</strong> V <strong>the</strong>n A vu is <strong>the</strong> <strong>number</strong><strong>of</strong> edges <strong>of</strong> G which have vertices v and u at <strong>the</strong>ir ends. In o<strong>the</strong>r words, <strong>the</strong> adjacencymatrix A <strong>of</strong> a graph G, is a (0, 1)-matrix, where 1’s represent adjacent vertices. A has arow for each vertex, and a column for each vertex. If a vertex v is connected to a vertexu, <strong>the</strong> entry <strong>in</strong> row v, column u is 1, and so is <strong>the</strong> entry <strong>in</strong> row u, column v. For <strong>in</strong>stance,a graph G and its adjacency matrix; see Figure 2.7
2.4. Matrices associated to a graph 47Figure 2.7: A graph G with its adjacency matrix.Remark 2.4.1 An adjacency matrix is determ<strong>in</strong>ed by a vertex order<strong>in</strong>g. Every adjacencymatrix is symmetric (a ij = a ji for all i, j). An adjacency matrix <strong>of</strong> a simple graph G hasentries 0 or 1, with 0s on <strong>the</strong> diagonal. The degree <strong>of</strong> v is <strong>the</strong> sum <strong>of</strong> <strong>the</strong> entries <strong>in</strong> <strong>the</strong>row for v <strong>in</strong> ei<strong>the</strong>r A or M.Example 2.4.2 Consider <strong>the</strong> labelled graph G <strong>in</strong> Figure 2.8.Figure 2.8: A graph with 6 vertices.which has <strong>the</strong> adjacency matrix A2.4.2 Degree Matrix⎡⎤0 1 0 0 1 01 0 1 0 1 1A =0 1 0 1 0 1⎢0 0 1 0 0 1⎥⎣1 1 0 0 0 1⎦0 1 1 1 1 0The degree <strong>of</strong> a vertex v ∈ V <strong>of</strong> G denoted by deg G (v); is <strong>the</strong> <strong>number</strong> <strong>of</strong> edges <strong>of</strong> G whichare <strong>in</strong>cident with v. The degree matrix <strong>of</strong> G is <strong>the</strong> diagonal V -by-V matrix D = D(G)such that D vv = deg G (v) for all v ∈ V , and D vu = 0 if v ≠ u; more precisely, <strong>the</strong> degreematrix D <strong>of</strong> a graph, is a diagonal matrix with <strong>the</strong> vertex degrees <strong>in</strong> <strong>the</strong> diagonal.