Unfinished learning resource · Units 1–8 available · Whole-course validation unfinished

Unit 6. Trees and spanning constructions

Unfinished learning resource · TMP-SCI-074. Units 1–8 are available. Whole-course validation remains unfinished. No completed semester, academic credit, accreditation or demonstrated competence is claimed. The retained weeks-10–11 allocation is fourteen learner hours, an unpiloted design estimate. Specialist appraisal, learner attempts, accessibility testing and rubric calibration remain outstanding.

Work on paper or in an existing local editor. Graphs are fictional and completely supplied. No actual infrastructure, accounts, purchases, private data, installations or uploads are needed. All diagrams have exact text equivalents. Spoken reasoning accompanied by a local written edge list is acceptable. Attempt tasks before opening the separate explained answers; keep your initial reasoning and a correction or justified-retention record.

Preparation and outcomes

Use Unit 5's simple undirected graph convention, degrees, paths/cycles, connected components, BFS and route certificates. A path has no repeated vertex; a cycle repeats only its first/last vertex and has length at least three. Use prior Proof teaching for induction, contradiction and equivalence arguments without reteaching that prerequisite course. We do not assume weighted optimization, matching, flows or a general algorithm-complexity theory.

Readiness

R1. On vertices {a,b,c,d}, compare edge sets {ab,bc,ca} and {ab,bc,cd}. Both have three edges. Which is connected, and which contains a cycle?

R2. Why does a path between distinct vertices contain at most |V|−1 edges? Why can walks be longer?

R3. State the degree-sum identity for finite simple undirected graphs. If a seven-vertex tree eventually proves to have six edges, what degree sum would follow?

R4. A BFS record gives each reached vertex other than s one predecessor with distance one less. Explain why following predecessors cannot cycle and why this does not yet claim every vertex of the original graph was reached.

Session A. A tree has a precise meaning

1. Nonempty, connected and acyclic

A tree is a finite nonempty simple undirected graph that is connected and has no cycle. A forest is a finite simple undirected graph with no cycle; it may be disconnected. Every connected component of a nonempty forest is a tree. An isolated vertex is a one-vertex tree with zero edges. The empty graph can be a forest, but is not a tree under our convention.

Our worked tree T has vertices {a,b,c,d,e,f} and edges ab,ac,bd,be,cf. Text diagram: a joins b and c; b joins d and e; c joins f. This list is the complete specification. It is connected, as the listed links give a route from a to every vertex. It has no cycle, as can be checked directly or later certified by a proved characterization. Its degrees in vertex order are 2,3,2,1,1,1. The degree-one vertices d,e,f are its graph leaves.

Do not identify a tree by whether a picture resembles a plant. Drawing a triangle with one edge curved still gives a cycle. Crossing two drawn segments does not create a vertex unless it is specified. A rooted tree adds a distinguished vertex to an already defined tree; being drawn at the top does not itself establish a parent relation.

2. Unique paths characterize trees

In a tree, every two vertices have exactly one vertex-simple path between them. Connectedness gives existence. For uniqueness, suppose two different simple paths connect x to y. Follow their common beginning until the first divergence u. Continue on one path until the first subsequent vertex v that lies on the other path's remaining section; y guarantees one exists. The two u-to-v sections have disjoint interiors by this first-rejoining choice. Traversing one forward and the other backward gives a cycle, contradiction. The entire union of two paths need not itself be a single cycle; the chosen sections isolate one.

Conversely, suppose a nonempty simple undirected graph has exactly one path between every two distinct vertices. It is connected. If it contained a cycle, choosing two distinct cycle vertices would give two different paths along the two sides of that cycle, contradiction. Therefore it is a tree. For a singleton the condition on distinct pairs is vacuous, and it is indeed connected and acyclic. A vertex's path to itself is the length-zero path under our convention.

Uniqueness concerns simple paths, not walks. In a tree with edge ab, a,b,a,b is a walk from a to b as well as the one-edge path a,b. Backtracking produces many walks without creating a cycle in the graph.

G1. In worked T, give the unique paths d-to-f and d-to-e. Add edge ef to form a new graph. Exhibit a cycle and two distinct simple d-to-f paths. Do not call every walk a path.

Session B. Leaves make induction possible

3. A finite tree with at least two vertices has two leaves

Choose a path of maximum length. Such a path exists because the graph is finite, and it has distinct endpoints because a connected graph with at least two vertices has an edge. Consider an endpoint x and its neighbor along the path. If x had another neighbor z outside the path, that edge would extend the path, contradicting maximal length. If z were already on the path, other than the immediate neighbor, the added edge and the intervening path segment would make a cycle. Both possibilities are impossible. Hence x has degree one. The same argument applies to the other endpoint, producing two distinct leaves.

This proves at least two, not exactly two. Worked T has three. The singleton has degree zero, so the degree-one leaf theorem does not apply to it. Infinite graphs are outside the proof; “choose a longest path” cannot be silently used where no finite maximum exists.

4. Deleting a leaf preserves the needed hypotheses

Remove a leaf x and its unique incident edge from a tree with at least two vertices. The remaining graph is nonempty. It is acyclic because deleting edges cannot introduce a cycle. It remains connected: any two remaining vertices had a simple path in the tree, and that path could not use x internally, because an internal path vertex needs two distinct incident path edges. Its endpoints are not x either. Thus their path remains after deletion.

Now prove a tree on n≥1 vertices has n−1 edges. Base n=1: a simple graph on one vertex has no edge. For n≥2, the leaf theorem supplies a removable leaf. The remaining tree has n−1 vertices, so induction gives n−2 edges. Restoring the removed edge gives n−1. The induction hypothesis was applied only after proving that the smaller graph is a tree.

G2. Delete leaf e from worked T. State the new carrier and edge set, verify it is a tree, and compare counts. Would deleting internal vertex b with all its incident edges preserve connectedness?

G3. A proposed proof says “Delete any vertex, apply induction, then restore its edges.” Explain why this is invalid as a tree edge-count proof. Use T to identify both the lost hypothesis and the uncontrolled number of restored edges.

Session C. Spanning without optimization promises

5. What spanning means

A spanning tree of a graph G=(V,E) is a subgraph with exactly the same vertex set V and some selected edges F⊆E, such that (V,F) is a tree. It must include isolated vertices if G has them; deleting difficult vertices is not a spanning construction. A disconnected graph has no spanning tree of its whole carrier, because an edge subset cannot create a route absent from the original graph.

Every finite nonempty connected graph has a spanning tree. Here is a constructive proof independent of the edge-count theorem. If the current graph has a cycle, remove one edge from that cycle. Its endpoints still have the alternative route around the remaining cycle. Any old route that used the removed edge can replace it with that alternative walk, so all old connections remain; shorten repetitions if a path is wanted. Vertices are never removed. Repeat while a cycle exists. Each deletion reduces a finite edge count, so eventually no cycle remains. The final graph is nonempty, connected and acyclic, hence a spanning tree.

The edge must belong to a cycle in the current graph. Removing several edges that belonged to cycles in the original graph can disconnect it after the first deletion changes which cycles remain. A verified deletion trace records the current cycle before each removal.

G4. On vertices {a,b,c,d}, edges are ab,ac,bc,bd,cd. Give a cycle-deletion trace ending in a spanning tree. Can you justify deleting ab and ac merely because each originally belonged to triangle abc? Check the combined result.

6. Grow by one new vertex at a time

An alternative proof starts with one vertex s and no selected edge. Let S be the reached set. If S≠V in a connected graph, some original edge crosses from S to V\S: take a path from s to an outside vertex and inspect its first exit. Choose one crossing edge uv with u∈S,v∉S. Add v and uv to the selected subgraph.

The selected graph remains connected. It remains acyclic because v was not previously present and has only one selected incident edge at the moment of addition; a new cycle would require two. Each step grows S by one, so after n−1 steps all vertices are included. The selected graph is a spanning tree. Different crossing choices can give different spanning trees; neither this proof nor the deletion method claims a cheapest one.

For a reproducible hand algorithm, repeatedly choose the alphabetically earliest ordered pair (inside vertex, outside vertex) among original crossing edges, with vertex labels fixed. Record S and the selected edge each time. This is one explicit tie policy, not a new graph property. If no crossing edge exists while vertices remain outside, stop and report that the original connectivity assumption is false for the given complete edge list. Do not invent an edge.

A BFS predecessor record from Unit 5, when all vertices are reached, is another spanning tree. Every vertex has a predecessor chain to the source, so the selected graph is connected. There are exactly n−1 selected edges, one for each non-root vertex; after the next characterization is proved, that count establishes acyclicity as well. Alternatively, first-discovery adds one new vertex per selected edge, matching the growth invariant above. A BFS tree preserves distances from its source, but an arbitrary spanning tree need not.

G5. Use the alphabetically earliest crossing-pair policy from a on G4's graph. Show each reached set and selected edge. Compare its a-to-d distance with that in the original graph, and do not infer that a coinciding distance proves all pair distances are preserved.

Session D. Counts become characterizations with hypotheses

7. The four equivalent conditions

For a finite nonempty simple undirected graph on n vertices, these are equivalent:

  1. It is connected and acyclic, hence a tree.
  2. Every two distinct vertices have exactly one simple path.
  3. It is connected and has n−1 edges.
  4. It is acyclic and has n−1 edges.

We already proved 1↔︎2 and that 1 gives n−1 edges, hence 1→3 and 1→4. For 3→1, the spanning-tree construction gives a tree on the same n vertices. That tree has n−1 edges and is an edge subset of the original graph, which also has n−1. The two finite edge sets must therefore be equal, so the original graph is a tree.

For 4→1, first derive the forest formula. If a forest has c connected components with vertex counts n₁,…,n_c, each component is a tree and has nᵢ−1 edges. The components partition vertices and edges, so total m=Σ(nᵢ−1)=n−c. If m=n−1, then c=1 and the graph is connected. This avoids using the conclusion to prove its own premise. For the empty forest, n=m=c=0 also satisfies the formula, but the tree characterizations above explicitly assume n≥1.

The edge count alone is not enough: a triangle plus an isolated vertex has n=4,m=3=n−1, yet is disconnected and cyclic. Conversely, any connected n-vertex graph has at least n−1 edges because it contains a spanning tree; any nonempty forest has at most n−1 because c≥1. Do not confuse a useful bound with a complete characterization.

8. Deleting or adding one edge

Remove an edge uv from a tree. If u and v remained connected, their remaining path plus uv would be a cycle in the original tree. Thus deletion disconnects it. The result is a forest with n vertices and n−2 edges, so n−c=n−2 gives exactly two components. Every tree edge is therefore a bridge, an edge whose deletion increases the component count.

Add one previously absent edge uv between two distinct vertices of a tree. The original tree has a unique u-to-v path. That path together with uv forms a cycle. Every cycle in the enlarged graph must use the new edge, since the old graph was acyclic; after removing the new edge from such a cycle, its remaining u-to-v path must be the unique old path. Hence exactly one cycle is created. Deleting any edge of that cycle gives another spanning tree of the enlarged graph.

In a general connected graph, an edge on a cycle is not a bridge, by the earlier alternate-route argument. If an edge is not on a cycle but its removal preserved endpoint connectivity, the remaining endpoint path plus the edge would create a cycle. Therefore an edge is a bridge exactly when it belongs to no cycle. This statement concerns the current graph, not necessarily an earlier graph in a deletion trace.

G6. Add ef to worked T. List the unique new cycle. Delete ac from that cycle and list the resulting spanning-tree edges. If instead you deleted bd, would the graph remain connected? Explain using the original leaf d.

Session E. Roots and what constructions preserve

9. Parent, child, depth and leaves

Choose a root r in a tree. For every vertex v≠r, its parent is the neighbor immediately before v on the unique r-to-v path. A child of u is a vertex whose parent is u. Depth is that path's edge length. The root has depth zero and no parent; every other vertex has exactly one parent. Each vertex's strict ancestors are the earlier vertices on its root path, excluding itself; its descendants are the vertices for which it is a strict ancestor. We use this strict convention explicitly.

Root worked T at a. Parents are b←a,c←a,d←b,e←b,f←c. Depths are a0,b1,c1,d2,e2,f2. The strict ancestors of e are a,b. Its rooted leaves, meaning vertices with no children, are d,e,f.

Root the same unaltered tree at d. Parents become b←d,a←b,e←b,c←a,f←c. The graph's degree-one leaves are still d,e,f, but rooted leaves are now e,f. The root d has degree one yet has a child, so it is not a rooted leaf. In a singleton tree the root has no children and is a rooted leaf, but its graph degree is zero, not one. Keep these conventions separate.

Diagram A, complete text equivalent: for root a, levels are {a}, {b,c}, {d,e,f}, with the five parent edges listed above. For root d, levels are {d},{b},{a,e},{c},{f}. Both diagrams represent the identical undirected edges ab,ac,bd,be,cf. Only the root-based descriptions change.

10. Preserve only what is proved

A spanning tree preserves vertices and undirected reachability in a connected graph. It generally removes routes and may increase distances. In a triangle with edges ab,ac,bc, the tree {ab,bc} changes a-to-c distance from one to two. Even a BFS tree from a need not preserve distances between other vertices: the tree {ab,ac} preserves distances from a but changes b-to-c from one to two.

Weights add another objective. Give triangle edges ab weight nine, ac weight two, bc weight two. A valid spanning tree {ab,ac} has total weight eleven; {ac,bc} has total four. The first remains a spanning tree but is not minimum weight. No minimum-spanning-tree algorithm is taught or promised here. “Has the fewest edges” does not distinguish trees on the same carrier, since all have n−1.

Independent practice

I1. Classify these complete graphs as tree, non-tree forest, or cyclic: one isolated vertex; two isolated vertices; the four-vertex path 1–2–3–4; a triangle with one additional isolated vertex. Give n,m,c and check the forest formula only where applicable.

I2. Prove that a tree on n≥2 vertices has at least two degree-one leaves using the degree sum: explain why every nonleaf has degree at least two. Keep the singleton case separate.

I3. Derive L=2+Σ(deg(v)−2), where L is the number of degree-one leaves and the sum is over vertices with degree at least three, for a tree with n≥2. Apply it when exactly two vertices have degree three, one has degree four and all others have degree one or two.

I4. On V={a,b,c,d,e}, E={ab,ac,bc,bd,cd,de}, construct one spanning tree by growth and a different one by cycle deletion. Record witnesses and verify both final edge counts. Do not claim your construction is unique.

I5. A forest has eleven vertices and seven edges. How many components? Can one of them be isolated? Give an explicit component-size example consistent with the counts.

I6. On V={p,q,r,s}, T={pq,qr,rs}, add ps. Give the unique cycle and all possible spanning trees obtainable by deleting one cycle edge. Explain why deleting no edge cannot retain a tree.

I7. Root T from I6 first at p, then at q. List parents, depths, rooted leaves and graph leaves in each case, using the original three-edge tree, not the added-cycle graph.

I8. Give a connected graph and a spanning tree that fails to preserve a shortest distance from your chosen root. Then give a BFS tree that preserves root distances but not a distance between two other vertices. A triangle may be used with complete specifications.

Homework and proof repair

H1. Write the equivalence proof for “connected with n−1 edges implies tree” without assuming acyclicity or using that implication inside your spanning-tree existence argument. Name the earlier results used.

H2. Audit: “Removing any edge leaves n−2 edges, so the result has two components.” Which original hypothesis makes that conclusion valid? Give a graph where the same bare count does not imply two components, and repair the argument for a tree.

H3. A construction on complete edge information reaches S and cannot find an edge to V\S. Explain how this certifies no spanning tree exists when S is nonempty and proper. What changes if the edge list is only a partial observation?

Retrieval and changed-data quiz

Each item is worth four formative points; maximum 24. No pass mark or automatic grade is implied.

Q1. A connected simple graph has eight vertices and seven edges. Must it be a tree? State the theorem and reasoning. Would seven edges without connectedness suffice?

Q2. A forest has ten vertices and three components. Find its edge count. Explain why the answer includes isolated components correctly.

Q3. A tree has one degree-four vertex and every other vertex degree one or two. Find the number of degree-one leaves and state the n≥2 hypothesis used.

Q4. In tree edges ab,bc,bd,de, find the unique a-to-e path and the cycle created by adding ae. If bc is deleted afterward, is the result a spanning tree?

Q5. Root Q4's original tree at c. Give b's parent and children, all rooted leaves, and c's graph degree. Explain the root/leaf distinction.

Q6. A tree-growing algorithm chooses an edge with both endpoints already in its selected connected subgraph. Why does this violate the acyclic growth invariant if the edge was not already selected? What if both endpoints are outside?

Project P1. A finite backbone with explicit certificates

Original graph G has vertices A,B,C,D,E,F,G and edges AB,AC,BC,BD,BE,CF,DE,EF,FG. The complete packet has no weights or directions. Consider the selected subgraph T with edges AB,AC,BD,BE,CF,FG.

(a) Prove T is a spanning tree by a valid growth trace and independently by connectedness plus edge count. List its degrees and graph leaves; check both handshake and the leaf formula.

(b) For each omitted original edge BC,DE,EF, add it to T separately and identify the unique cycle. Do not combine all three additions into the one-cycle theorem. Give a legal cycle-deletion trace from G to T, with a current cycle before every removal.

(c) Remove CF from T. Give the two vertex components. Find every original G edge crossing that cut, and explain how a different crossing edge repairs a spanning tree. Then remove BOTH CF and EF from the original G. Can that changed graph have a spanning tree? Supply the component certificate and a spanning forest with its edge count.

(d) Root T at A and at D, separately. List parents and depths, distinguish graph leaves from rooted leaves, and compare a shortest original-G E-to-F route with the route in T. State what your spanning tree preserves and what this distance example disproves.

(e) Audit “six edges proves it is a tree,” “every tree edge is a bridge in the original graph,” and “any spanning tree is the best network.” For each, identify the missing qualification and give packet-based evidence or an explicitly labelled counterexample.

(f) Supply an honest revision/retention ledger and a changed small graph that tests your main repaired distinction. Keep original G, selected T and changed graph separate. No fictional claim may be relabelled as real infrastructure evidence.

Formative project rubric, maximum 36: tree proof/degrees 7; cycles/deletion 7; cut/change/forest 8; roots/distances 6; audit/revision/scope 8. Complete explained anchors are in the key. Correct counts do not repair a missing connectedness proof or a deleted vertex. No stored grade, workload validation or externally assessed qualification is created.

Delayed transfer D1

D1. After a break, use vertices {Draft,Check,Review,Release,Archive} and UNDIRECTED edges Draft–Check, Check–Review, Review–Release, Release–Draft; Archive is isolated. Does a spanning tree of all five vertices exist? Give a spanning forest and count its edges. Add Review–Archive and construct a spanning tree, then root it at Archive and state parents. Explain why this undirected teaching model cannot establish a valid one-way approval sequence or anyone's authority to release a document.

Exit, references and next unit

Explain why “same vertices,” “connected,” “acyclic” and “n−1 edges” cannot be interchanged without their stated implications. Retry a failed construction on changed data before claiming mastery. Continue with Unit 7, Finite structures in a model, followed by Unit 8, final synthesis. No semester-completion percentage is inferred.

Optional references checked 4 November 2026: Oscar Levin, Discrete Mathematics: An Open Introduction, fourth edition, Trees, Propositions 2.2.3/2.2.5/2.2.6, Definition 2.2.7 and Theorem 2.2.8; David Gries, Cornell, Spanning Trees, pages 1–2. Linked weighted/MST material and runtime comparisons are outside this unit. Our path and leaf conventions are stated explicitly. These are conceptual references, not endorsement or a claim of equivalent academic credit. All cases, exercises, diagrams and prose here are original; no source exercise bank or media is reproduced. The whole-course sourceGap remains true.