Tutorials › Graph Theory (Undergraduate) › Loops, Parallel Edges, And Spanning-Tree Counts

Spanning Trees and Counting · Tutorial 130 of 799

Loops, Parallel Edges, And Spanning-Tree Counts

Learn why loops contribute no choices, parallel edges contribute distinct choices, and both facts are reflected consistently in a multigraph Laplacian.

Advanced 11 min read

What You'll Learn

  • Define spanning trees in graphs with loops and parallel edges.
  • Explain why loops cannot appear in a spanning tree.
  • Count the effect of parallel edges by treating each edge instance distinctly.
  • Apply deletion–contraction without discarding loops or parallel edges.
  • Construct the multigraph Laplacian using edge multiplicities.
  • Prove the Laplacian cofactor count for multigraphs.

Spanning Trees When Edges Repeat

For a simple graph, an edge is determined by its pair of endpoints. In a multigraph, several distinct edge instances may join the same two vertices, and an edge may have both endpoints at the same vertex: such an edge is a loop. These possibilities do not change the basic idea of a spanning tree, but they do affect how trees are counted. In particular, parallel edges represent distinct choices, while loops represent no valid choice in a tree.

Definition: A finite multigraph consists of vertices and edge instances; an edge instance has two endpoints, which may be equal. Distinct edge instances with the same endpoints are parallel edges. A spanning tree is a connected, acyclic subgraph containing every vertex. A loop is a cycle of length one, and two parallel edges form a cycle of length two. Edge instances are counted separately: choosing one parallel edge rather than another gives a different spanning tree.

Write \(t(G)\) for the number of spanning trees. Throughout, \(G\) has at least one vertex. If \(G\) is disconnected, \(t(G)=0\); for a graph with one vertex, the empty edge set is a spanning tree, so \(t(G)=1\), even if the graph also has loops. When edge instances are listed, labels such as \(e_1,e_2\) distinguish parallel edges.

What Loops and Parallel Edges Do

Proposition: Deleting any loop from a multigraph does not change its spanning-tree count. If \(p\) parallel edge instances join two distinct vertices, then each can be chosen as a separate option in any spanning tree that uses that connection; they must not be collapsed into one edge when counting.

Proof. A spanning tree is acyclic, so it cannot contain a loop, since a loop is itself a cycle. Therefore every spanning tree of \(G\) is a spanning tree of \(G-e\) when \(e\) is a loop. Conversely, deleting a loop removes no spanning tree, because none used \(e\). This gives a bijection and hence \(t(G)=t(G-e)\).

For parallel edges, regard each edge instance as a separate element of the edge set. A spanning tree that contains one particular instance remains a different edge set if that instance is replaced by another parallel instance, provided the replacement is the only chosen edge between those endpoints. More generally, the count is over edge-instance subsets, not just over endpoint pairs. A tree cannot contain two parallel instances together because they form a cycle of length two. \(\square\)

This distinction is important in deletion–contraction. For a nonloop edge instance \(e\), the recurrence is \(t(G)=t(G-e)+t(G/e)\), where \(G/e\) contracts the endpoints of \(e\). All other edge instances are retained: parallel edges to \(e\) become loops after contraction, and other parallel edges remain distinct. Trees not containing \(e\) are counted by \(G-e\); trees containing \(e\) correspond, after contracting \(e\), to trees of \(G/e\). The loops created by contraction cannot belong to those trees, just as the corresponding redundant edges could not be included alongside \(e\) in a tree of \(G\).

Worked Example: Parallel Edges Between Two Vertices

Let \(V=\{u,v\}\). Let \(E\) consist of three distinct parallel edge instances \(e_1,e_2,e_3\) joining \(u\) to \(v\), two loops at \(u\), and one loop at \(v\). Find \(t(G)\).

A connected spanning subgraph must contain an edge between \(u\) and \(v\). It cannot contain two such edges, because they would form a cycle of length two, and it cannot contain a loop. Thus the spanning trees are exactly \(\{e_1\}\), \(\{e_2\}\), and \(\{e_3\}\), giving \(t(G)=3\).

Check: deleting the three loops leaves three parallel choices and does not change the count. Alternatively, apply deletion–contraction to \(e_1\): deleting it leaves two choices, while contracting it leaves one vertex with loops only, whose spanning-tree count is \(1\). The recurrence gives \(2+1=3\).

The Laplacian Convention for a Multigraph

To compare direct counting with a cofactor calculation, the Laplacian must encode edge multiplicities. Orient each nonloop edge instance arbitrarily and give it an incidence column with a \(+1\) at one endpoint and a \(-1\) at the other. Give each loop the zero column. If \(B\) is the resulting incidence matrix, define \(\mathbf L(G)=BB^{\mathsf T}\). Reversing an edge orientation changes the sign of one column but does not change \(BB^{\mathsf T}\).

Definition: In the Laplacian of a multigraph, each nonloop edge instance contributes \(1\) to each of its endpoint diagonal entries and \(-1\) to the two corresponding off-diagonal entries. A loop contributes zero. Thus an off-diagonal entry is minus the number of edge instances joining the two vertices, and the diagonal entry is the number of incident nonloop edge instances.

This convention agrees with \(\mathbf L=\mathbf D-\mathbf A\) if loops contribute \(2\) to the degree and the adjacency-matrix diagonal entry for each loop is also \(2\). The two contributions cancel in \(\mathbf D-\mathbf A\). Using incidence columns makes the loop cancellation explicit and avoids ambiguity about adjacency-matrix conventions. Parallel edges each contribute separately, so their multiplicity appears in the entries of \(\mathbf L\).

Theorem (multigraph cofactor formula): Let \(G\) be a finite multigraph with \(n\ge 1\) vertices, and form \(\mathbf L(G)\) using the convention above. Delete the row and column of any one vertex. The determinant of the resulting matrix is \(t(G)\).

Proof. Fix a vertex \(r\). Delete the row of \(r\) from the incidence matrix \(B\), obtaining \(B_r\). Deleting row \(r\) and column \(r\) from \(BB^{\mathsf T}\) gives \(B_rB_r^{\mathsf T}\). By the Cauchy–Binet formula, for an \(n\)-vertex graph with \(m\) edge instances,

$$ \det(B_rB_r^{\mathsf T}) = \sum_{\substack{S\subseteq E(G)\\|S|=n-1}} \det(B_r[:,S])^2 . $$

Here \(B_r[:,S]\) is the square matrix formed from the columns for the edge instances in \(S\). If \(S\) contains a loop, its column is zero, so its determinant is zero. If \(S\) contains a cycle, the signed sum of the incidence columns around that cycle is zero; this also applies to a cycle made of two parallel edges. Therefore its columns are dependent and its determinant is zero.

Now suppose the \(n-1\) edge instances in \(S\) contain no cycle. They form a forest. A forest on \(n\) vertices with \(c\) components has \(n-c\) edges: each component with \(q\) vertices is a tree and has \(q-1\) edges, and summing over components gives \(n-c\). Since \(S\) has \(n-1\) edges, \(n-c=n-1\), so \(c=1\). Thus \(S\) is a spanning tree.

For a spanning tree \(S\), \(\det(B_r[:,S])\) is \(1\) or \(-1\). To verify this, if \(n=1\), the matrix is empty and its determinant is \(1\). If \(n>1\), the tree has a leaf different from \(r\): a tree with at least two vertices has at least two leaves, so at least one is not \(r\). The row of this leaf has just one nonzero entry, equal to \(1\) or \(-1\). Expanding the determinant along that row reduces its absolute value to the determinant for the smaller tree obtained by removing the leaf and its incident edge. Repeating this step ends at the one-vertex case, giving absolute value \(1\).

Consequently, each spanning tree contributes \(1\) to the Cauchy–Binet sum, and every other set \(S\) contributes \(0\). The sum is exactly the number of spanning trees. If \(G\) is disconnected, no such \(S\) can be a spanning tree, so the determinant and \(t(G)\) are both zero. This proves the formula for every \(n\ge1\), including \(n=1\). \(\square\)

Matching the Two Counting Methods

Worked Example: A Triangle with Unequal Multiplicities

Let \(V=\{1,2,3\}\). There are two edge instances joining \(1\) to \(2\), three joining \(2\) to \(3\), and one joining \(1\) to \(3\). Also include one loop at \(1\). Find \(t(G)\) by direct enumeration and by a Laplacian cofactor.

For direct enumeration, a tree on these three vertices must use exactly two of the three endpoint pairs. If it uses the \(12\) and \(23\) pairs, there are \(2\cdot3=6\) choices of edge instances. If it uses \(12\) and \(13\), there are \(2\cdot1=2\) choices. If it uses \(23\) and \(13\), there are \(3\cdot1=3\) choices. These cases are disjoint and exhaustive, so \(t(G)=6+2+3=11\). The loop is excluded from every tree.

For the Laplacian, the numbers of nonloop edge instances at vertices \(1,2,3\) are \(3,5,4\), respectively: \(1\) has two edges to \(2\) and one to \(3\); \(2\) has two to \(1\) and three to \(3\); \(3\) has three to \(2\) and one to \(1\). The loop contributes zero. Therefore

$$ \mathbf L(G)= \begin{pmatrix} 3&-2&-1\\ -2&5&-3\\ -1&-3&4 \end{pmatrix}. $$

Delete row and column \(3\). The cofactor determinant is \(3\cdot5-(-2)(-2)=15-4=11\). It agrees with the direct count. This calculation shows why replacing the two \(12\)-edges by one edge would be incorrect: the multiplicity \(2\) appears in the off-diagonal entry and in the distinct choices counted directly.

Check: the three direct cases give \(6+2+3=11\), while the cofactor gives \(15-4=11\). The two methods count the same edge-instance trees.

Worked Example: Parallel Bundles on a Tree-Shaped Graph

Let \(V=\{a,b,c,d\}\). Include two edge instances between \(a\) and \(b\), three between \(a\) and \(c\), and one between \(a\) and \(d\). Add one loop at \(a\) and one loop at \(c\). Find the spanning-tree count.

Every spanning tree must connect each of \(b,c,d\) to the rest of the graph. The only available connections for those vertices are their respective bundles to \(a\). A tree therefore chooses one of the two \(ab\)-edges, one of the three \(ac\)-edges, and the single \(ad\)-edge. The loops cannot be chosen. This gives \(2\cdot3\cdot1=6\) spanning trees.

For the cofactor calculation, delete the row and column of \(a\). The remaining diagonal entries count the incident nonloop edge instances at \(b,c,d\), and there are no edges among those three vertices. Thus the reduced matrix is diagonal with entries \(2,3,1\), and its determinant is \(2\cdot3\cdot1=6\).

Check: there are six independent combinations of the required branch choices, and the reduced determinant is \(6\). Both calculations give \(t(G)=6\); neither loop changes the result.

Common Pitfall: Simplifying Before Counting

A frequent error is to replace every bundle of parallel edges by a single edge before counting. In the two-vertex example, that would leave one connection and lead to the incorrect count \(1\), rather than the actual count \(3\). The simplified graph records whether a connection exists, but loses which edge instance was selected. It can represent the underlying connectivity, but it cannot preserve the edge-instance spanning-tree count unless the multiplicities are retained separately.

A related error is to add a loop to a diagonal entry of \(\mathbf L\) while leaving the other matrix entries unchanged. Under the incidence convention, a loop has a zero column and contributes nothing to \(\mathbf L\). If using \(\mathbf D-\mathbf A\), use a consistent convention: count each loop twice in both the degree and the adjacency diagonal so the contributions cancel. The cofactor formula then agrees with direct enumeration, which never includes loops in a spanning tree.

Check Your Understanding

In each question, treat parallel edge instances as distinct choices and loops as cycles.

  1. A graph has two vertices joined by four parallel edges and no other edges. How many spanning trees does it have? Explain why.
  2. Why does deleting a loop preserve the spanning-tree count, even if the loop is the only edge incident to its vertex?
  3. Three vertices have two parallel edges between each pair, and there are no loops. Count the spanning trees directly by choosing endpoint pairs and edge instances.
  4. State how a loop and a bundle of \(p\) parallel edges contribute to the incidence-defined Laplacian.
  5. For a disconnected multigraph with at least one vertex, what does the multigraph cofactor formula give, and why?