Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Branches without loops, and things that must come first
A family tree branches out but never loops back. That’s a tree: everything is connected, with exactly one route between any two members. A recipe is different: you must chop before you fry and boil water before adding pasta. Its steps form a DAG (directed acyclic graph), arrows with no circles. Sorting the steps so every “must come first” is respected is called topological sorting.
Spanning trees give the cheapest way to connect sensors, rovers or ground stations. DAGs schedule spacecraft assembly and test campaigns, order the operations in a neural network’s backward pass, describe Bayesian networks, and drive build systems and mission command sequences. A dependency cycle in a schedule means the plan is impossible, so it must be detected.
- 1. A tree with 10 vertices has how many edges?
- 2. A DAG cannot contain…
- 3. Topological order means…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Equivalent definitions of a tree
For a graph on n vertices, the following are equivalent:
- connected and acyclic;
- connected with n − 1 edges;
- acyclic with n − 1 edges;
- exactly one path between every pair;
- minimally connected (removing any edge disconnects it).
A forest is a disjoint union of trees. A spanning tree of G is a tree using all of G’s vertices.
DAGs
A directed graph is acyclic iff it has a topological order: a numbering in which every arc goes from a lower to a higher number. Kahn’s algorithm repeatedly removes vertices with in-degree 0. If vertices remain, there’s a cycle.
- 1. Adding any edge to a tree creates…
- 2. Kahn's algorithm starts with vertices of…
- 3. If Kahn's algorithm can't output all vertices, the graph…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.Minimum spanning trees
- Kruskal: sort the edges and add each unless it closes a cycle (union-find). .
- Prim: grow one tree, always adding the cheapest edge leaving it (heap). .
Both are correct because of the cut property: for any partition of the vertices, the lightest crossing edge belongs to some MST. MSTs also give a 2-approximation for metric TSP and the basis of single-linkage clustering.
Counting spanning trees (Kirchhoff)
For , this gives Cayley’s formula .
Longest paths and scheduling in DAGs
In a DAG, longest (and shortest) paths come from a single pass in topological order: . The critical path method adds a backward pass for the latest start times. Slack = latest start − earliest start, and tasks with zero slack form the critical path.
- 1. Why can Kruskal be greedy and still optimal?
- 2. Spanning trees of K₄:
- 3. Tasks with zero slack are…
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.Cut property
Let e be the lightest edge across a cut , and T an MST without e. Adding e to T creates a cycle, which must cross the cut through another edge f with . Then is a spanning tree no heavier than T. ∎
Topological order exists iff acyclic
If there’s a cycle, its vertices can’t all precede each other. Conversely, a finite DAG has a vertex of in-degree 0 (otherwise following arcs backward would cycle). Remove it and recurse. ∎
Why n − 1 edges
Induction: a tree has a leaf (take the end of a longest path). Removing it leaves a tree with n − 1 vertices. ∎
Exercise 3.1: spanning trees of a 4-cycle via Kirchhoff
The cycle Laplacian’s eigenvalues are 0, 2, 2, 4. So . Removing any one of the 4 edges gives a spanning path.
- 1. The cut-property proof exchanges the cut edge with…
- 2. Every finite DAG has a vertex with…
- 3. Spanning trees of the 4-cycle:
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Critical path of a spacecraft I&T campaign
A small spacecraft’s integration and test campaign has 12 tasks: structure, harness, avionics, propulsion, payload, bus integration, payload integration, functional test, thermal vacuum, vibration, review and shipping. The dependencies form a DAG. CPM gives an 88-day campaign with critical path structure → propulsion → bus → payload integration → functional test → thermal vacuum → review → ship. Avionics has 13 days of slack, payload 18 and vibration 12. Cutting thermal vacuum from 21 to 5 days saves only 12 days, because vibration (9 days) becomes critical. Project managers and space agencies use exactly this analysis for launch-readiness planning, and the same topological ordering underlies autonomous onboard schedulers.
Trees and DAGs in AI, robotics and aerospace
- Computation graphs: autodiff executes a DAG in topological order forward and in reverse for gradients (a8-5).
- Planning and scheduling: CPM/PERT for missions; temporal networks in onboard planners (e.g. EUROPA, MEXEC).
- Probabilistic models: Bayesian networks are DAGs; junction trees enable exact inference.
- Networks and perception: MSTs for sensor-network backbones and minimal wiring; single-linkage clustering of point clouds; RRT motion planners grow trees.
References
- J. Kruskal (1956). “On the shortest spanning subtree of a graph and the traveling salesman problem.” Proc. AMS, 7.
- R. Prim (1957). “Shortest connection networks and some generalizations.” Bell System Technical Journal, 36(6).
- A. Kahn (1962). “Topological sorting of large networks.” Communications of the ACM, 5(11).
- G. Kirchhoff (1847). “Über die Auflösung der Gleichungen…” Annalen der Physik, 148 (matrix-tree theorem).
- J. Kelley, M. Walker (1959). “Critical-path planning and scheduling.” Proc. Eastern Joint Computer Conference.
- T. Cormen, C. Leiserson, R. Rivest, C. Stein (2022). Introduction to Algorithms, 4th ed. MIT Press. Ch. 20–21.
- NASA (2016). NASA Systems Engineering Handbook, NASA/SP-2016-6105 Rev 2.
- S. LaValle (1998). “Rapidly-exploring random trees: a new tool for path planning.” TR 98-11, Iowa State University.