A graph can have several ways to connect every robot-related station without cycles. Counting those spanning trees answers a different question from finding one with minimum total edge cost. Kirchhoff's matrix-tree theorem turns that counting problem into a determinant of a reduced graph Laplacian.
The word reduced matters. The complete Laplacian has zero row sums and is singular, even for a connected graph with many trees. A zero determinant of that complete matrix is therefore not evidence that no spanning tree exists.
Specify an original finite graph
Use five labeled vertices A, B, C, D, and E. The available undirected edges are the five-cycle AB, BC, CD, DE, EA, together with the diagonal AC. There are no other edges, loops, or parallel edges in this initial graph.
Every spanning tree has four edges, includes all five vertices, and is connected without a cycle. Trees are distinguished by their selected labeled edge sets, not by whether two drawings happen to have the same unlabeled shape.
Construct the unweighted Laplacian L by placing each vertex's degree on its diagonal, minus one for an adjacent distinct vertex, and zero otherwise. In vertex order A through E, its rows are:
[3,−1,−1,0,−1]; [−1,2,−1,0,0]; [−1,−1,3,−1,0]; [0,0,−1,2,−1]; [−1,0,0,−1,2].
Each row sums to zero. Thus the all-ones vector is in the nullspace and the full determinant vanishes. This graph is nevertheless connected: its outer cycle alone supplies paths among every pair of vertices.
Remove a matching row and column
Delete E's row and E's column. The resulting four-by-four matrix has rows [3,−1,−1,0], [−1,2,−1,0], [−1,−1,3,−1], and [0,0,−1,2]. Its determinant is eleven.
NetworkX documents this diagonal-cofactor construction for tree enumeration and its weighted extension. MathWorld independently states the counting theorem. The graph, matrices, and alternative counting checks here are original rather than outputs from either software system.
One exact elimination check starts with the leading two-by-two block [[3,−1],[−1,2]], whose determinant is five. Eliminating it leaves the lower block [[8/5,−1],[−1,2]], with determinant 11/5. Their product is eleven. Using any other matching row-and-column deletion gives the same tree count.
The deleted vertex is not removed from the graph being counted. It only chooses a cofactor representation. Deleting E from the actual graph would produce a different graph and a different counting problem.
Count the trees without a determinant
Separate trees by whether they contain AC. If they do not, they must use four edges from the five-cycle. Removing any one cycle edge gives a different spanning tree, providing five trees.
If AC is included, contract it temporarily into a single vertex X. Edges AB and BC become two distinct parallel choices connecting X to B. The remaining cycle X-D-E-X has three edges.
A contracted spanning tree must choose one of the two X-B edges and two of the triangle's three edges. There are two times three = six possibilities. Restoring AC maps each to a unique original tree that contains the diagonal.
The two cases are disjoint and total five plus six = eleven, independently matching the cofactor. The temporary parallel edges preserve the identities of AB and BC. Merging them as one unweighted choice would lose a factor of two.
Weighted counting multiplies edges inside each tree
Assign positive weight w to AC and weight one to every cycle edge. Each of the five trees without AC has product weight one. Each of the six trees containing it has product weight w. The weighted tree sum is therefore Z(w) = 5 + 6w.
At w = 2, this sum is seventeen. It is neither the number of distinct trees, which remains eleven, nor the minimum additive cost of a tree. At w = 1 all products are one and the weighted sum recovers the ordinary count.
If every edge weight is multiplied by c, every tree's product gains c^4 because every tree contains four edges. The weighted sum changes by that fourth power. An additive four-edge cost would instead change by a first power, so the interpretation of the weight field is essential.
One may define a separate random-tree model that chooses a tree with probability proportional to its product weight. Under that explicitly chosen model, the probability of including AC is 6w/(5 + 6w): six elevenths at w = 1 and twelve seventeenths at w = 2. This is a model for selecting trees, not a statement about independent link failures.
Connectivity probability counts other surviving subgraphs too
For a different experiment, let each of the six original links survive independently with probability p. A connected surviving graph need not be a tree; it can retain a cycle.
Exactly four surviving edges form a connected graph in eleven cases, contributing 11p^4(1 − p)^2. Any five of the six edges leave the graph connected, contributing 6p^5(1 − p). All six surviving contribute p^6.
At p = 1/2, the connected probability is (11 + 6 + 1)/64 = 18/64 = 0.28125. The probability of a connected graph with exactly four surviving edges is only 11/64. Tree enumeration supplies one part of this calculation, rather than the entire reliability probability.
Simply adding the probabilities that individual spanning trees survive would double-count realizations containing several trees. The disjoint surviving-edge counts above avoid that overlap.
Keep the graph and arithmetic scope explicit
A disconnected graph has no spanning tree covering all its vertices. Directed rooted trees require another orientation and Laplacian convention; they are outside this undirected example. Likewise, arbitrary rounded determinant arithmetic can obscure an exact integer count.
No graph library, communications network, or link-failure experiment was run. Exact determinants and finite enumeration verify this constructed graph while keeping total count, minimum cost, weighted selection, and connectivity probability as separate quantities.
Sources checked October 24, 2026
NetworkX 3.7: number_of_spanning_trees:
https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.tree.mst.number_of_spanning_trees.html
Eric W. Weisstein, MathWorld: Matrix Tree Theorem:
https://mathworld.wolfram.com/MatrixTreeTheorem.html
Concept illustration: A small desktop robot beside a laptop showing a generic workflow provides robotics context for this analytical model. The image does not depict the article's numerical example, a verified experiment, a product specification, or deployment evidence.