MGU Mathematics Series — Discrete Mathematics
Part IV: Graph Theory, Networks, and Algorithms
Trees · Spanning Trees · Shortest Paths · Euler & Hamilton · Planarity
Chapter 11 of 14
MGU Mathematics Series  ·  Discrete Mathematics  ·  Library Textbook Edition

Chapter 11:
Trees, Paths, and
Network Optimization

Rooted and binary trees, spanning trees, minimum spanning trees, Kruskal's and Prim's algorithms, shortest paths, Dijkstra's algorithm, Euler and Hamilton paths, and planar graphs — the structures that turn networks into solvable problems

■ Math Level: Discrete Mathematics ■

■ 14 Sections  •  Part IV of 5 ■

Follows Chapter 10: Graph Theory Foundations  ·  Prepares students for Chapter 12: Algorithms and Complexity

Purpose and Overview

Chapter 10 introduced the language of graph theory: vertices, edges, degree, paths, cycles, connectedness, and representation. This chapter builds on that foundation to study one of the most important and widely applied families of graphs — trees — and to develop algorithms that solve real optimization problems on networks.

Trees appear throughout computing and mathematics: in file systems, search procedures, decision processes, syntax parsers, databases, and compression algorithms. Spanning trees connect networks efficiently. Shortest-path algorithms route messages, traffic, and data. Euler and Hamilton paths model traversal problems that arise in logistics, planning, and circuit design. And planar graphs describe networks that can be drawn without crossing wires or roads.

This chapter does not require calculus. It builds on graph vocabulary from Chapter 10, on logical reasoning from earlier chapters, and on the counting and algorithmic thinking introduced throughout the book. The optimization in this chapter is discrete: it proceeds by examining finite choices, comparing weights or lengths, and following systematic procedures.

Opening Question

A network engineer needs to connect eight server buildings using fiber-optic cable. She has surveyed possible cable routes between pairs of buildings and recorded the cost of each route. She wants to connect all eight buildings so that data can travel between any two of them — but she wants to use as few total meters of cable as possible. She cannot afford to run redundant lines. How should she decide which routes to build? This is a minimum spanning tree problem. By the end of this chapter, you will know exactly how to solve it, why the solution is correct, and how the same mathematical structure appears throughout engineering, logistics, data science, and computing.

Why This Chapter Matters

Graph theory, as you learned in Chapter 10, gives mathematics a language for describing relationships. But relationships in the real world usually come with practical demands: What is the cheapest connection? What is the fastest route? Can this network be traversed without repeating an edge? Can all locations be visited without backtracking?

These are not abstract questions. They are asked every day by network engineers, delivery companies, chip designers, airline schedulers, and database architects. The mathematical tools developed in this chapter — trees, spanning trees, shortest-path algorithms, Euler and Hamilton paths — are the tools used to answer them.

Studying trees and network algorithms also reinforces a core principle of discrete mathematics: structure matters. A tree is not just a graph without cycles. It is a graph with a precise, useful structure that makes certain problems efficient to solve. Understanding that structure is what allows mathematics to support real-world decisions.

14Sections
13Objectives
22Key Terms
12+Worked Examples

Learning Objectives

  1. 1Define a tree and identify its structural properties.
  2. 2Distinguish between trees, forests, rooted trees, and binary trees.
  3. 3Explain what a spanning tree is and why it exists in connected graphs.
  4. 4Describe what makes a spanning tree a minimum spanning tree.
  5. 5Apply Kruskal's algorithm to find a minimum spanning tree.
  6. 6Apply Prim's algorithm to find a minimum spanning tree.
  7. 7Set up and solve shortest-path problems on weighted graphs.
  8. 8Trace Dijkstra's algorithm on small examples.
  9. 9Identify Euler paths and circuits and state the conditions for their existence.
  10. 10Identify Hamilton paths and circuits and explain why they are harder to analyze.
  11. 11Describe what a planar graph is and apply Euler's formula as an introduction.
  12. 12Explain how trees and network algorithms appear in computing, transportation, and data systems.
  13. 13Recognize and avoid common mistakes in tree and network reasoning.

Key Terms

Tree, forest, leaf, rooted tree, root, parent, child, sibling, depth, height, binary tree, spanning tree, minimum spanning tree, Kruskal's algorithm, Prim's algorithm, weighted graph, edge weight, shortest path, Dijkstra's algorithm, relaxation, Euler path, Euler circuit, Hamilton path, Hamilton circuit, planar graph, Euler's formula for planar graphs, face, network optimization.

Sections at a Glance

Sections 11.1 – 11.3
Trees: A Lean and Useful Structure
What a Tree Is · Rooted Trees · Binary Trees

What a Tree Is

The word "tree" in everyday language suggests something that branches — a structure that spreads outward from a base without forming loops. The mathematical definition of a tree captures exactly this idea.

Definition

A tree is a connected graph that contains no cycles.

Every definition in mathematics carries weight. Let us take this one apart.

A tree must be connected: there must be a path between every pair of vertices. A tree must have no cycles: there must be no closed loop of distinct vertices and edges. Both conditions are required. A graph with no cycles that is not connected is called a forest (because it looks like several unconnected trees). A graph that is connected but contains cycles is not a tree.

Why These Two Conditions Together?

Connectivity says: the tree holds together. No vertex is isolated or unreachable.

Acyclicity says: the tree has no redundant edges. Every edge is the only connection between some part of the tree and the rest. Remove any edge, and the tree becomes disconnected.

This "no redundancy" property is one of the most important properties of trees. It means that trees are lean: they use the minimum number of edges needed to stay connected.

The Edge-Count Property

If a tree has \(n\) vertices, how many edges does it have? The answer is always exactly \(n - 1\).

Why? Think about building a tree starting from scratch. You begin with \(n\) isolated vertices — no edges, no connections. Each edge you add either connects a new vertex to the growing tree, or creates a cycle. Since a tree has no cycles, every edge must connect a new vertex. To connect all \(n\) vertices, you need exactly \(n - 1\) edges.

Three Equivalent Characterizations of a Tree

A connected graph with \(n\) vertices and \(n - 1\) edges.

A connected graph with no cycles.

A graph in which every pair of vertices is connected by exactly one simple path.

These three characterizations describe the same family of graphs. If any one of them is satisfied and the graph is connected, the graph is a tree.

Example 11.1.1
Identifying Trees
  • ProblemDetermine which of the following graphs is a tree. Graph A: five vertices, four edges, connected, no cycles. Graph B: five vertices, five edges, connected, one cycle. Graph C: five vertices, four edges, two components (not connected).
  • ThinkCheck each graph against the definition: connected and acyclic. Also check the edge count — a tree on five vertices should have exactly four edges.
  • Solve Graph A: connected, no cycles, four edges for five vertices. This is a tree.
    Graph B: connected, but contains a cycle. This is not a tree.
    Graph C: four edges for five vertices, but not connected. This is a forest (two separate trees), not a single tree.
  • CheckGraph A satisfies all three characterizations. Graph B fails the acyclicity condition. Graph C fails the connectivity condition.
Answer: Only Graph A is a tree. Graph C is a forest. Graph B is neither.

Leaves

A leaf of a tree is a vertex with degree 1 — a vertex connected by exactly one edge. Leaves are the endpoints of a tree. In a tree with three or more vertices, there are always at least two leaves.

Every tree (except a single edge with two vertices) has interior vertices and leaf vertices. The structural role of leaves and interior vertices becomes clearer when we study rooted trees.

Student Warning

The word "tree" in graph theory has a precise meaning. It does not mean any branching picture. A path on five vertices is technically a tree. A star graph — one central vertex connected to many outer vertices — is technically a tree. The definition is about connectivity and acyclicity, not visual appearance.

Practice 11.1Concept and Skill
  1. State the definition of a tree in your own words. Why are both conditions — connectivity and acyclicity — necessary?
  2. A graph has 9 vertices and 8 edges and is connected. Without more information, can you conclude it is a tree? Explain.
  3. A graph has 9 vertices and 8 edges but is not connected. What can you conclude about this graph? Could it still be acyclic?
  4. Explain why every tree with at least two vertices has at least one leaf.
  5. Sketch (in words) a tree on 6 vertices that is a straight path, and a different tree on 6 vertices that is a star. How many leaves does each have?

Rooted Trees

An unrooted tree is simply a connected acyclic graph, with no vertex given special status. A rooted tree is a tree in which one vertex has been designated the root.

Choosing a root gives the tree a direction and a hierarchy. Every other vertex can be described in terms of its relationship to the root.

Diagram Instruction

Draw a tree with vertices A, B, C, D, E, F, and G. Connect A to B and A to C. Connect B to D and B to E. Connect C to F and C to G. Designate A as the root. Draw A at the top, B and C below it on the second level, and D, E, F, G on the third level at the bottom.

Vocabulary of Rooted Trees

Once a root is chosen, the standard vocabulary of rooted trees applies:

Rooted Tree Vocabulary

The root is the topmost vertex. It has no parent.

The children of a vertex \(v\) are the vertices directly connected to \(v\) that are one level below \(v\).

The parent of a vertex \(v\) is the vertex directly above \(v\) on the path from \(v\) to the root.

Siblings are vertices that share the same parent.

A leaf in a rooted tree is a vertex with no children.

An internal vertex (or internal node) is a vertex with at least one child.

The depth of a vertex is the length of the path from the root to that vertex. The root has depth 0.

The height of the tree is the maximum depth of any vertex in the tree.

Example 11.2.1
Rooted Tree Vocabulary
  • ProblemUse the tree drawn in the diagram instruction above, with root A. Identify the parent, children, depth, and any siblings for each vertex.
  • ThinkTrace the hierarchy from root A downward.
  • Solve A (root): depth 0, no parent, children: B and C.
    B: depth 1, parent: A, children: D and E, sibling: C.
    C: depth 1, parent: A, children: F and G, sibling: B.
    D: depth 2, parent: B, no children (leaf), sibling: E.
    E: depth 2, parent: B, no children (leaf), sibling: D.
    F: depth 2, parent: C, no children (leaf), sibling: G.
    G: depth 2, parent: C, no children (leaf), sibling: F.

    Height of the tree: 2 (the maximum depth is 2).
  • CheckThe root A is the only vertex with depth 0. Every leaf (D, E, F, G) has depth 2, which equals the height. The hierarchy is consistent.
Answer: The root is A. The internal vertices are A, B, and C. The leaves are D, E, F, and G. The height is 2.

Why Rooted Trees Matter

Rooted trees are one of the most fundamental structures in computer science. A file system is a rooted tree: the root directory contains folders, each folder may contain subfolders or files, and the hierarchy never loops back.

A parse tree in a programming language or a compiler is a rooted tree that represents the structure of a program. A decision tree in machine learning is a rooted tree in which each internal node represents a test and each leaf represents a conclusion. A binary search tree in data structures is a rooted tree used to store and retrieve information efficiently.

MGU Library Connection
  • The MGU Computer Science pages cover binary search trees, AVL trees, and heap structures as applications of rooted trees in data structures courses. These connect directly to Section 11.3.
Practice 11.2Rooted Tree Vocabulary
  1. A rooted tree has root R. R has children X and Y. X has children M and N. Y has child P, and P has child Q (a leaf). Identify: the leaves, the internal vertices, the depth of each vertex, and the height of the tree.
  2. In a rooted tree, can the root have a sibling? Explain why or why not.
  3. Two vertices in a rooted tree have the same depth. Must they be siblings? Give an example to support your answer.
  4. A file system folder structure is modeled as a rooted tree. What does the root represent? What do the leaves represent?
  5. Explain the difference between the depth of a vertex and the height of a tree.

Binary Trees as an Introduction

A binary tree is a rooted tree in which every vertex has at most two children. When a vertex has two children, they are called the left child and the right child.

Binary trees appear in sorting algorithms, compression algorithms, expression evaluation, and database indexing. They are simple to define but powerful in application.

Diagram Instruction

Draw a rooted binary tree with root P. P has left child Q and right child R. Q has left child S and right child T. R has left child U and no right child. S, T, and U are leaves.

Full and Complete Binary Trees

Two special types of binary trees appear frequently:

Key Definitions

A full binary tree is one in which every internal vertex has exactly two children (never one).

A complete binary tree is one in which all levels except possibly the last are fully filled, and all leaves on the last level are as far left as possible.

These definitions support analysis of algorithms that use binary trees. For example, in a full binary tree with \(k\) internal vertices, the total number of vertices is \(2k + 1\) (each internal vertex contributes two children, plus the root). This kind of structural count often appears in algorithm analysis.

Counting Leaves in Full Binary Trees

Claim: In a full binary tree, the number of leaves equals the number of internal vertices plus one.

This can be proved by induction (see Chapter 5 for the induction technique). The key idea is: each time you add an internal vertex to a full binary tree, you are converting a leaf into an internal vertex and adding two new leaves — a net gain of one leaf. Starting with one vertex (one leaf, zero internal vertices), each internal vertex added increases the leaf count by one.

Student Note

You do not need to memorize every formula about binary trees right now. The important thing is to understand what a binary tree is, why it is useful, and how rooted-tree vocabulary applies to it.

Practice 11.3Binary Trees
  1. A rooted tree has a vertex with three children. Is this tree a binary tree? Explain.
  2. A full binary tree has 5 internal vertices. How many leaves does it have? How many total vertices?
  3. A complete binary tree has height 2. What is the maximum possible number of vertices?
  4. Explain in your own words why a binary search tree is useful for storing and retrieving sorted data.
  5. Draw (in words) a binary tree with 4 vertices that is not full. Identify which internal vertex has only one child.
Sections 11.4 – 11.7
Connecting Networks Efficiently
Spanning Trees · Minimum Spanning Trees · Kruskal's Algorithm · Prim's Algorithm

Spanning Trees

Return now to connected graphs that may contain cycles. Trees are maximally lean. But what if you have a graph that is more complex — one with extra edges creating cycles — and you want to find the leanest connected subgraph hidden inside it?

Definition

A spanning tree of a connected graph \(G\) is a subgraph of \(G\) that includes all the vertices of \(G\) and forms a tree.

In other words, a spanning tree keeps all the vertices but removes edges until no cycles remain and the graph is still connected.

Every connected graph has at least one spanning tree.

To find one, start with the entire graph. If there is a cycle, remove one edge from that cycle — the graph remains connected, because the other edges of the cycle still provide an alternate path. Repeat until no cycles remain. What is left is a spanning tree.

Example 11.4.1
Finding a Spanning Tree
  • ProblemThe graph \(G\) has vertices A, B, C, D, E with edges AB, BC, CD, DE, AC, and BE. Find a spanning tree.
  • ThinkThe graph has 5 vertices. A spanning tree on 5 vertices must have exactly 4 edges. The graph has 6 edges, so we must remove exactly 2. We must not disconnect the graph.
  • Solve Step 1: Check for cycles. The edges AB, BC, CA form a triangle (a cycle). Remove edge AC. The graph is still connected because A can reach C via A–B–C.

    Step 2: Check again. The edges BE and the path B–C–D–E form a cycle (BE, ED, DC, CB). Remove edge BE. Still connected: B can reach E via B–C–D–E.

    Step 3: Verify. Remaining edges: AB, BC, CD, DE. This is four edges on five vertices. Check connectivity: A–B–C–D–E is a single path connecting all vertices. Check acyclicity: the remaining graph is a path, which has no cycles.
  • Check4 edges on 5 vertices, connected, no cycles — satisfies all three characterizations of a tree from Section 11.1.
Answer: One spanning tree consists of the edges AB, BC, CD, DE. This is the simple path A–B–C–D–E.

How Many Spanning Trees Can a Graph Have?

A connected graph with many edges may have many different spanning trees. Each spanning tree is a different subset of edges that connects all vertices without cycles. Choosing which spanning tree to use depends on the criteria — if edges have weights (costs, distances, times), we usually want the minimum spanning tree.

Practice 11.4Spanning Trees
  1. A connected graph has 7 vertices and 9 edges. How many edges must be removed to form a spanning tree, and how many edges will the spanning tree have?
  2. A graph has vertices P, Q, R, S with edges PQ, QR, RS, SP, and PR. Find a spanning tree by removing one edge. Which edge(s) could be removed? Are there multiple choices?
  3. Explain why every connected graph has at least one spanning tree, using the cycle-removal argument from this section.
  4. Can a disconnected graph have a spanning tree? Explain your reasoning.
  5. A connected graph is itself a tree (it has no cycles). How many spanning trees does it have? Explain.

Minimum Spanning Trees

In many real-world problems, edges have weights. A weight might represent:

In a weighted graph, every edge \(e\) has an associated number \(w(e)\), its weight.

Definition

A minimum spanning tree (MST) of a connected weighted graph is a spanning tree whose total edge weight is as small as possible.

The minimum spanning tree answers the question: what is the cheapest way to connect all the vertices?

Important

There may be more than one spanning tree with the same minimum total weight (especially if multiple edges have equal weights). In this case, any of them qualifies as a minimum spanning tree.

Why Greedy Algorithms Work for MSTs

The algorithms for finding minimum spanning trees (Kruskal's and Prim's, developed in the next two sections) are both greedy algorithms: at each step, they make the locally best choice available.

For many optimization problems, greedy choices do not lead to global optima. But for minimum spanning trees, the structure of trees guarantees that greedy approaches work — no locally good edge selection leads to a globally worse tree. This can be proved rigorously; the key property is called the cut property, which is typically studied in an advanced algorithms course.

Practice 11.5Minimum Spanning Trees
  1. Explain in your own words what a minimum spanning tree minimizes. What does it not minimize?
  2. A weighted graph has two different spanning trees, both with total weight 20. Are both valid minimum spanning trees? Explain.
  3. What does it mean for an algorithm to be "greedy"? Why is it reasonable to expect greedy choices to work for MSTs?
  4. Give a real-world example (other than those listed in this section) where edge weights might represent a quantity you would want to minimize across a network.

Kruskal's Algorithm

Kruskal's algorithm finds a minimum spanning tree by building the tree one edge at a time, always selecting the cheapest available edge that does not create a cycle.

The Algorithm

Input: A connected weighted graph \(G\) with \(n\) vertices.

Output: A minimum spanning tree \(T\).

Steps:

1. Sort all edges of \(G\) in non-decreasing order of weight.

2. Initialize \(T\) as an empty set of edges (and all \(n\) vertices).

3. For each edge \(e\) in the sorted order: if adding \(e\) to \(T\) does not create a cycle, add \(e\) to \(T\); if it would create a cycle, skip \(e\).

4. Stop when \(T\) contains \(n - 1\) edges (or all edges have been examined).

5. Return \(T\).

Pseudocode — KRUSKAL
KRUSKAL(G):
  Sort edges of G by weight (ascending)
  T = empty spanning tree (all vertices, no edges)
  For each edge e = (u, v) in sorted order:
    If u and v are in different components of T:
      Add e to T
  Return T

Checking whether two vertices are "in different components" is the cycle check. If \(u\) and \(v\) are already connected by a path in \(T\), adding edge \((u, v)\) would close a cycle.

Example 11.6.1
Applying Kruskal's Algorithm
  • ProblemFind a minimum spanning tree for a graph with vertices A, B, C, D, E and edges: AB (weight 2), AC (weight 4), BC (weight 1), BD (weight 5), CD (weight 8), CE (weight 3), DE (weight 6).
  • ThinkSort edges by weight. Add edges one by one, skipping any that would create a cycle. Stop after 4 edges (since 5 vertices need 4 edges in a spanning tree).
  • Solve Step 1 — Sort edges by weight:
EdgeWeight
BC1
AB2
CE3
AC4
BD5
DE6
CD8
  • Step 2 — Process edges in order:

    Add BC (weight 1): no cycle. Components: {A}, {B, C}, {D}, {E}. \(T\) contains: BC.
    Add AB (weight 2): A and B are in different components. No cycle. Components: {A, B, C}, {D}, {E}. \(T\) contains: BC, AB.
    Add CE (weight 3): C and E are in different components. No cycle. Components: {A, B, C, E}, {D}. \(T\) contains: BC, AB, CE.
    Add AC (weight 4): A and C are already in the same component {A, B, C, E}. Skip — would create a cycle.
    Add BD (weight 5): B is in {A, B, C, E}, D is in {D}. No cycle. Components: {A, B, C, D, E}. \(T\) contains: BC, AB, CE, BD.

    Step 3: \(T\) now has 4 edges and 5 vertices. All vertices are connected. Stop.
  • CheckTotal weight \(= 1 + 2 + 3 + 5 = 11\). Verify: A–B–C–E connected; B–D connected. All 5 vertices in one component. No cycles (4 edges on 5 vertices is a tree).
Answer: The minimum spanning tree has edges BC, AB, CE, BD with total weight 11.
Diagram Instruction

Draw five vertices A, B, C, D, E. Draw the edges BC, AB, CE, and BD as the tree edges, making a branching structure. Label each edge with its weight. Confirm the shape is a tree (connected, no cycles).

Why Kruskal's Algorithm Works

Kruskal's algorithm always produces a minimum spanning tree because of the cycle property: if the most expensive edge in any cycle is unique, then it cannot belong to any minimum spanning tree. By always choosing the cheapest available edge and skipping edges that create cycles, Kruskal's algorithm avoids selecting any edge that the cycle property rules out.

A complete proof requires more machinery, but the intuition is sound: adding the cheapest available edge can never hurt, because any MST that avoids this edge can be modified to include it (at no extra cost) while remaining minimal.

Practice 11.6Kruskal's Algorithm
  1. A graph has vertices P, Q, R, S, T with edges PQ (3), QR (1), RS (4), ST (2), PT (5), PR (6). Apply Kruskal's algorithm. List the edges in the order added and the total weight.
  2. During Kruskal's algorithm, why is it important to check whether two vertices are already in the same component before adding an edge?
  3. A graph has two edges of equal weight, both candidates at the same step of Kruskal's algorithm. Does it matter which one is chosen first? Explain.
  4. Suppose Kruskal's algorithm has processed all edges but \(T\) has fewer than \(n - 1\) edges. What does this tell you about the original graph?

Prim's Algorithm

Prim's algorithm finds a minimum spanning tree by growing the tree one vertex at a time, always adding the cheapest edge that connects a new vertex to the current tree.

The Algorithm

Input: A connected weighted graph \(G\) with \(n\) vertices and a starting vertex \(s\).

Output: A minimum spanning tree \(T\).

Steps:

1. Initialize \(T\) to contain only the starting vertex \(s\).

2. Repeat until \(T\) contains all \(n\) vertices: find the minimum-weight edge that connects a vertex in \(T\) to a vertex not yet in \(T\); add that edge and its new vertex to \(T\).

3. Return \(T\).

Pseudocode — PRIM
PRIM(G, s):
  T = {s}   (tree starts with only vertex s)
  While T does not include all vertices:
    Find the minimum-weight edge (u, v) where u is in T and v is not in T
    Add edge (u, v) and vertex v to T
  Return T
Example 11.7.1
Applying Prim's Algorithm
  • ProblemFind a minimum spanning tree for the same graph as Example 11.6.1, starting from vertex A. Edges: AB (2), AC (4), BC (1), BD (5), CD (8), CE (3), DE (6).
  • ThinkStart at A. Each step, look at all edges connecting \(T\) to vertices outside \(T\). Add the cheapest one.
  • Solve Step 1: \(T = \{A\}\). Edges from A to outside \(T\): AB (2), AC (4). Minimum: AB (2). Add B. \(T = \{A, B\}\).

    Step 2: \(T = \{A, B\}\). Edges from \(T\) to outside \(T\): from A: AC (4); from B: BC (1), BD (5). Minimum: BC (1). Add C. \(T = \{A, B, C\}\).

    Step 3: \(T = \{A, B, C\}\). Edges from \(T\) to outside \(T\): AC no longer qualifies (C already in \(T\)); from B: BD (5); from C: CD (8), CE (3). Minimum: CE (3). Add E. \(T = \{A, B, C, E\}\).

    Step 4: \(T = \{A, B, C, E\}\). Edges from \(T\) to outside \(T\): from B: BD (5); from C: CD (8); from E: DE (6). Minimum: BD (5). Add D. \(T = \{A, B, C, D, E\}\).

    All vertices included. Stop.
  • CheckEdges selected: AB (2), BC (1), CE (3), BD (5). Total weight \(= 11\). Same as Kruskal's result.
Answer: The minimum spanning tree has edges AB, BC, CE, BD with total weight 11.

Kruskal's vs. Prim's

Both algorithms always produce a minimum spanning tree. They differ in how they build it:

Kruskal's works globally — it sorts all edges first, then greedily adds the cheapest edge that does not create a cycle.

Prim's works locally — it grows the tree from a single starting vertex, always choosing the cheapest edge that connects the growing tree to a new vertex.

For small graphs, both are equally practical. For very large graphs, the efficiency of implementation depends on the data structures used. Both algorithms run in polynomial time — a topic studied in Chapter 12.

MGU Library Connection
  • The data structure used to efficiently check whether two vertices are in the same component in Kruskal's algorithm is called a union-find (or disjoint-set) structure. Prim's algorithm benefits from a priority queue. Both data structures are studied in computer science courses on data structures.
Practice 11.7Prim's Algorithm
  1. Apply Prim's algorithm to the graph from Practice 11.6, Problem 1 (vertices P, Q, R, S, T with edges PQ (3), QR (1), RS (4), ST (2), PT (5), PR (6)), starting from vertex P. List the vertices and edges as they are added and verify the total weight matches Kruskal's result.
  2. Explain the difference between how Kruskal's algorithm and Prim's algorithm "see" the graph at each step.
  3. Suppose Prim's algorithm is run from two different starting vertices on the same graph. Will the resulting minimum spanning trees necessarily contain the same edges? Will they necessarily have the same total weight?
  4. Why does Prim's algorithm never need to perform a separate cycle check, unlike Kruskal's algorithm?
Sections 11.8 – 11.11
Routes Through Networks
Shortest Path Problems · Dijkstra's Algorithm · Euler Paths and Circuits · Hamilton Paths and Circuits

Shortest Path Problems

The minimum spanning tree problem asks: how do we connect all vertices cheaply? A different question is equally important: what is the cheapest path from one specific vertex to another?

This is the shortest path problem. In a weighted graph, the shortest path from vertex \(s\) to vertex \(t\) is the path whose total edge weight is minimized.

Note: "shortest" refers to minimum weight, not minimum number of edges. In an unweighted graph (or a graph where all weights are equal), the shortest path by weight is the same as the shortest path by edge count. In a weighted graph, these can differ.

Applications

Setting Up a Shortest Path Problem

Given a weighted graph \(G\) and a starting vertex \(s\), the single-source shortest path problem asks for the shortest path from \(s\) to every other vertex.

We represent the shortest known distance from \(s\) to each vertex in a distance table. Initially, the distance to \(s\) is 0, and the distance to every other vertex is unknown (often written as \(\infty\)).

As we explore the graph, we update (or relax) distance estimates whenever we find a shorter route.

Relaxation Rule

If the current shortest known distance from \(s\) to vertex \(u\) is \(d(u)\), and the edge \((u, v)\) has weight \(w\), then the distance estimate for \(v\) can be improved to \(d(u) + w\) if \(d(u) + w < d(v)\).

Practice 11.8Shortest Path Setup
  1. Explain the difference between "shortest path by weight" and "shortest path by edge count." Give an example of a graph where these differ.
  2. A distance table currently shows \(d(v) = 12\). A new edge from a vertex \(u\) with \(d(u) = 7\) and weight 3 is examined. Apply the relaxation rule. What is the new value of \(d(v)\)?
  3. Why is the distance from the source vertex to itself always 0?
  4. List two real-world situations (beyond those given in this section) that can be modeled as single-source shortest path problems.

Dijkstra's Algorithm as an Introduction

Dijkstra's algorithm (named for computer scientist Edsger Dijkstra, who developed it in 1956) solves the single-source shortest path problem on graphs with non-negative edge weights.

Important

Dijkstra's algorithm requires that all edge weights be non-negative. Negative edge weights require a different algorithm (Bellman-Ford), which is beyond the scope of this chapter.

The Algorithm

Input: A connected weighted graph \(G\) with non-negative edge weights and a source vertex \(s\).

Output: The shortest distance from \(s\) to every other vertex.

Steps:

1. Set \(d(s) = 0\) and \(d(v) = \infty\) for all other vertices \(v\).

2. Mark all vertices as unvisited.

3. While there are unvisited vertices: (a) select the unvisited vertex \(u\) with the smallest \(d(u)\); (b) mark \(u\) as visited; (c) for each unvisited neighbor \(v\) of \(u\), if \(d(u) + w(u,v) < d(v)\), update \(d(v) = d(u) + w(u,v)\).

4. Return all distance values.

Pseudocode — DIJKSTRA
DIJKSTRA(G, s):
  For each vertex v in G:
    d(v) = infinity
    visited(v) = false
  d(s) = 0

  While there are unvisited vertices:
    u = unvisited vertex with smallest d(u)
    visited(u) = true
    For each neighbor v of u where visited(v) = false:
      If d(u) + weight(u,v) < d(v):
        d(v) = d(u) + weight(u,v)

  Return d
Example 11.9.1
Tracing Dijkstra's Algorithm
  • ProblemFind the shortest distance from vertex A to all other vertices in a graph with vertices A, B, C, D, E and edges: AB (6), AC (2), BC (3), BD (5), CD (7), CE (4), DE (1).
  • ThinkSet up the distance table. Repeatedly select the unvisited vertex with the smallest known distance, then relax its neighbors.
Initial State
Vertexd(v)Visited
A0No
B∞No
C∞No
D∞No
E∞No
Step 1 — Select A (d = 0). Mark visited.

Neighbor B: \(d(A) + w(AB) = 0 + 6 = 6 < \infty\). Update \(d(B) = 6\).
Neighbor C: \(d(A) + w(AC) = 0 + 2 = 2 < \infty\). Update \(d(C) = 2\).

Vertexd(v)Visited
A0Yes
B6No
C2No
D∞No
E∞No
Step 2 — Select C (d = 2). Mark visited.

Neighbor B: \(d(C) + w(BC) = 2 + 3 = 5 < 6\). Update \(d(B) = 5\).
Neighbor D: \(d(C) + w(CD) = 2 + 7 = 9 < \infty\). Update \(d(D) = 9\).
Neighbor E: \(d(C) + w(CE) = 2 + 4 = 6 < \infty\). Update \(d(E) = 6\).

Vertexd(v)Visited
A0Yes
B5No
C2Yes
D9No
E6No
Step 3 — Select B (d = 5). Mark visited.

Neighbor D: \(d(B) + w(BD) = 5 + 5 = 10 > 9\). No update to \(d(D)\).

Vertexd(v)Visited
A0Yes
B5Yes
C2Yes
D9No
E6No
Step 4 — Select E (d = 6). Mark visited.

Neighbor D: \(d(E) + w(DE) = 6 + 1 = 7 < 9\). Update \(d(D) = 7\).

Vertexd(v)Visited
A0Yes
B5Yes
C2Yes
D7No
E6Yes

Step 5: Select D (only unvisited, \(d = 7\)). Mark D visited. No unvisited neighbors.

Final Distances from A
VertexShortest Distance from A
A0
B5
C2
D7
E6
  • CheckVerify the path to D: A → C (cost 2) → E (cost 4, total 6) → D (cost 1, total 7). This is indeed shorter than A → C → D (cost \(2 + 7 = 9\)) or A → B → D (cost \(6 + 5 = 11\)).
Answer: The shortest distances from A are: to B = 5 (via A–C–B), to C = 2 (via A–C), to D = 7 (via A–C–E–D), to E = 6 (via A–C–E).

Why Dijkstra's Algorithm Works

At each step, Dijkstra's algorithm selects the unvisited vertex with the smallest known distance. This vertex's distance cannot be improved further, because all remaining paths to it would require going through an unvisited vertex whose distance is at least as large (since all edge weights are non-negative). This is the key insight that makes the greedy selection correct.

If edge weights could be negative, this reasoning would fail, because a later path through a negative edge might reduce an already-finalized distance.

Practice 11.9Dijkstra's Algorithm
  1. A graph has vertices A, B, C, D and edges AB (4), AC (1), BC (2), BD (5), CD (8). Apply Dijkstra's algorithm starting from A. Show the distance table after each step.
  2. In the graph from problem 1, what is the shortest path (sequence of vertices) from A to D, and what is its total weight?
  3. Explain in your own words why Dijkstra's algorithm "finalizes" a vertex's distance once it is marked visited.
  4. Suppose a graph contains an edge with weight \(-3\). Why might Dijkstra's algorithm give an incorrect answer if applied to this graph?

Euler Paths and Circuits

The question of Euler paths and circuits is one of the oldest problems in graph theory, famously posed and solved by Leonhard Euler in 1736 through the Königsberg Bridge Problem.

The problem: the city of Königsberg had seven bridges connecting its land masses and islands. Could a walker traverse every bridge exactly once and return to the starting point? Euler proved that no such walk exists — and his reasoning established the foundations of graph theory.

Definitions

Euler path: A path in a graph that visits every edge exactly once. The path does not need to return to its starting vertex.

Euler circuit: A closed path (circuit) in a graph that visits every edge exactly once and returns to the starting vertex.

Note: Euler paths and circuits are about traversing every edge exactly once. This is different from paths about vertices — that distinction becomes important when we discuss Hamilton paths in Section 11.11.

The Euler Conditions

Euler's great discovery was a precise condition characterizing when Euler paths and circuits exist. The condition depends entirely on vertex degrees.

Euler's Theorems

Euler Circuit Theorem: A connected graph has an Euler circuit if and only if every vertex has even degree.

Euler Path Theorem: A connected graph has an Euler path (but not necessarily a circuit) if and only if it has exactly two vertices of odd degree. The Euler path begins at one odd-degree vertex and ends at the other.

Why does degree matter? Think about traversing edges at a vertex. Every time the path enters a vertex, it must also leave (unless the vertex is a starting or ending point). If every vertex has even degree, the path can always leave every vertex it enters, enabling it to return to the start. If exactly two vertices have odd degree, those two must serve as the start and end — the path can enter without being able to leave (at the end) or leave without having entered (at the start).

Example 11.10.1
Checking Euler Conditions
  • ProblemDetermine whether the following graph has an Euler circuit, an Euler path (but not a circuit), or neither. Graph: vertices A, B, C, D, E. Edges: AB, AC, BC, BD, CD, DE, AE.
  • ThinkCount the degree of each vertex and apply the Euler conditions.
  • Solve Degree of each vertex:
    A: edges AB, AC, AE → degree 3 (odd)
    B: edges AB, BC, BD → degree 3 (odd)
    C: edges AC, BC, CD → degree 3 (odd)
    D: edges BD, CD, DE → degree 3 (odd)
    E: edges DE, AE → degree 2 (even)

    Count of odd-degree vertices: 4 (vertices A, B, C, D).
  • CheckFor an Euler circuit, we need all even degrees. For an Euler path, we need exactly two odd-degree vertices. We have four odd-degree vertices.
Answer: The graph has neither an Euler circuit nor an Euler path.
Example 11.10.2
The Königsberg Bridge Problem
  • ProblemThe city of Königsberg has four land masses: two river banks (N and S), and two islands (I₁ and I₂). The seven bridges create the following connections: N to I₁, two bridges; N to I₂, one bridge; S to I₁, two bridges; S to I₂, one bridge; I₁ to I₂, one bridge. Can a walker traverse all seven bridges exactly once and return to the starting point?
  • ThinkModel this as a graph where land masses are vertices and bridges are edges. Check degrees.
  • Solve Degrees:
    N: connected by \(2 + 1 = 3\) edges → degree 3 (odd)
    S: connected by \(2 + 1 = 3\) edges → degree 3 (odd)
    I₁: connected by \(2 + 2 + 1 = 5\) edges → degree 5 (odd)
    I₂: connected by \(1 + 1 + 1 = 3\) edges → degree 3 (odd)

    All four vertices have odd degree.
  • CheckFor an Euler circuit, all degrees must be even. For an Euler path, exactly two vertices must have odd degree. This graph has four odd-degree vertices.
Answer: Neither an Euler circuit nor an Euler path exists. No walker can traverse all seven bridges exactly once, with or without returning to the start.

Finding an Euler Circuit or Path

When an Euler circuit exists (all even degrees), a systematic procedure for finding it is Hierholzer's algorithm: start at any vertex, follow edges until you return to the start (forming a circuit), then iteratively extend the circuit by following unused edges from any vertex in the current circuit that still has unused edges. Continue until all edges are used.

The full procedure is described in advanced graph theory courses, but the key insight is: once you know the Euler conditions are met, you know the circuit exists and can be found.

Practice 11.10Euler Paths and Circuits
  1. A graph has 6 vertices, each of degree 4. Does it have an Euler circuit? Explain.
  2. A graph has vertices with degrees 3, 3, 4, 4, 4. Does it have an Euler path, an Euler circuit, or neither?
  3. A cycle graph \(C_6\) (a hexagon — 6 vertices arranged in a ring) has every vertex of degree 2. Does it have an Euler circuit? Describe it.
  4. Explain why the sum of all vertex degrees in any graph must be even. Use this fact to explain why a graph can never have exactly one vertex of odd degree.
  5. A delivery route must travel down every street in a small neighborhood exactly once and return to the depot. Under what condition on the street graph is this possible without retracing any street?

Hamilton Paths and Circuits

A natural variation on the Euler question changes "traverse every edge exactly once" to "visit every vertex exactly once."

Definitions

Hamilton path: A path in a graph that visits every vertex exactly once. The path does not need to return to the starting vertex.

Hamilton circuit: A closed path (circuit) that visits every vertex exactly once and returns to the starting vertex.

These are named after the mathematician William Rowan Hamilton, who studied related puzzles in the 1850s.

The Critical Difference from Euler

At first glance, Hamilton paths and Euler paths sound similar — both ask about traversing a graph "completely." But they are fundamentally different in terms of difficulty:

Euler paths have a simple, complete characterization: check vertex degrees. The Euler conditions give an exact yes/no answer in any graph.

Hamilton paths have no known simple characterization. No one has found a general condition that tells you, just by looking at local properties of a graph, whether a Hamilton path exists.

Determining whether a Hamilton circuit exists in a general graph is one of the famous NP-complete problems in computer science. This means that no efficient algorithm is known that solves it for all graphs (though efficient algorithms might exist for special cases or may be discovered in the future). The problem of finding an optimal Hamilton circuit — visiting all vertices at minimum total cost — is the famous Traveling Salesman Problem (TSP).

Sufficient Conditions

While no simple necessary and sufficient condition exists for Hamilton circuits, a few sufficient conditions are known:

Sufficient Conditions for Hamilton Circuits

Dirac's Theorem: If a graph has \(n \geq 3\) vertices and every vertex has degree at least \(n/2\), then the graph has a Hamilton circuit.

Ore's Theorem: If a graph has \(n \geq 3\) vertices and for every pair of non-adjacent vertices \(u\) and \(v\), \(\deg(u) + \deg(v) \geq n\), then the graph has a Hamilton circuit.

These are sufficient conditions, not necessary ones. A graph can have a Hamilton circuit even if neither condition is met. And a graph can fail both conditions and still have a Hamilton circuit. The conditions are tools to identify some graphs that definitely have one.

Student Note

The asymmetry between Euler and Hamilton problems is striking. Euler paths have an elegant, complete solution through degree analysis. Hamilton paths are theoretically hard — no degree-based shortcut exists in general. This is one of the places where discrete mathematics touches deep open questions in theoretical computer science.

Example 11.11.1
Identifying Hamilton and Euler Conditions
  • ProblemA graph has 6 vertices, each with degree 3. Determine: (a) Does an Euler circuit exist? (b) Does Dirac's theorem guarantee a Hamilton circuit?
  • Think(a) Euler circuit requires all even degrees. (b) Dirac's theorem requires every vertex to have degree \(\geq n/2 = 6/2 = 3\).
  • Solve (a) Every vertex has degree 3 — odd. All vertices have odd degree. No Euler circuit. (And since all 6 vertices have odd degree, no Euler path either, since we need exactly 2 odd-degree vertices for a path.)

    (b) Every vertex has degree 3, and \(n/2 = 3\). So \(\deg(v) \geq n/2 = 3\) for every vertex. Dirac's theorem applies.
  • CheckThe Euler condition and the Hamilton sufficient condition are evaluated independently using different criteria — one is exact, the other is only sufficient.
Answer: No Euler circuit exists (all degrees are odd). Dirac's theorem guarantees a Hamilton circuit exists.

The Traveling Salesman Problem

The Traveling Salesman Problem (TSP) asks: given a complete weighted graph (every pair of vertices is connected), find the Hamilton circuit with minimum total weight.

This models situations like: a delivery driver who must visit a set of locations and return to the starting point, minimizing total distance. Or a manufacturing robot that must visit a set of points on a circuit board and return to start, minimizing time.

For small numbers of vertices, the TSP can be solved by listing all Hamilton circuits and comparing their total weights. But the number of Hamilton circuits in a complete graph on \(n\) vertices grows as \((n-1)!/2\) — which grows faster than any polynomial. For large \(n\), this brute-force approach is completely impractical.

Approximation algorithms and heuristic methods (including some based on minimum spanning trees) can find Hamilton circuits that are guaranteed to be within a certain factor of the true optimum. These algorithms are studied in advanced courses on algorithms and theoretical computer science.

Practice 11.11Hamilton Paths and Circuits
  1. A complete graph \(K_5\) has 5 vertices, each of degree 4. Does Dirac's theorem guarantee a Hamilton circuit? Verify by listing a Hamilton circuit directly.
  2. A graph has 7 vertices, each with degree at least 4. Does Dirac's theorem apply? What does it conclude?
  3. Explain, in your own words, why the Hamilton circuit problem is considered much harder than the Euler circuit problem.
  4. A delivery driver must visit 6 locations and return to the depot. The locations form a complete weighted graph. How many distinct Hamilton circuits are there (not counting direction or starting point)? How does this number grow as the number of locations increases?
  5. Can a graph have both an Euler circuit and a Hamilton circuit at the same time? Can it have one without the other? Explain with reference to the conditions for each.
Sections 11.12 – 11.14
Drawing Without Crossings, and the Road Ahead
Planar Graphs · Network Optimization in Practice · Common Mistakes

Planar Graphs as an Introduction

Definition

A planar graph is a graph that can be drawn in the plane so that no two edges cross (except at shared endpoints).

Note: the definition says "can be drawn" — it does not say the graph must be drawn without crossings. A graph might look like it has crossings in one drawing but still be planar if a different arrangement of vertices and edges is crossing-free.

Why Planarity Matters

Planar graphs appear naturally in applications where crossing is not allowed or not possible:

Euler's Formula for Planar Graphs

When a connected planar graph is drawn without crossings, it divides the plane into regions called faces. The outer, unbounded region also counts as a face.

Euler's Formula

For any connected planar graph with \(V\) vertices, \(E\) edges, and \(F\) faces:

$$V - E + F = 2$$

This remarkable formula says that no matter how you draw a connected planar graph, the combination \(V - E + F\) always equals 2. This is one of the most elegant results in discrete mathematics.

Example 11.12.1
Verifying Euler's Formula
  • ProblemA triangle (3 vertices, 3 edges) is drawn in the plane. How many faces does it have? Verify Euler's formula.
  • ThinkDraw the triangle. The interior region is one face. The exterior unbounded region is another face.
  • Solve\(V = 3\), \(E = 3\), \(F = 2\) (the interior and the exterior).
  • Check\(V - E + F = 3 - 3 + 2 = 2\). ✓
Answer: Euler's formula is satisfied.
Example 11.12.2
Applying Euler's Formula
  • ProblemA connected planar graph has 10 vertices and 15 edges. How many faces does it have?
  • ThinkUse Euler's formula and solve for \(F\).
  • Solve\(V - E + F = 2\), so \(10 - 15 + F = 2\), so \(F = 7\).
  • Check\(10 - 15 + 7 = 2\). ✓
Answer: The graph has 7 faces (including the outer face).

Non-Planar Graphs

Not every graph is planar. Two important non-planar graphs are:

Kuratowski's Theorem (stated as an introduction): A graph is planar if and only if it contains no subdivision of \(K_5\) or \(K_{3,3}\). A subdivision of a graph is obtained by inserting additional vertices along its edges. This theorem gives a complete characterization of planarity, but its proof is advanced.

Student Note

You are not expected to use Kuratowski's Theorem to determine planarity in this chapter. The key takeaway is: planarity is a property of the graph itself, not of any particular drawing; Euler's formula applies to planar graphs; and \(K_5\) and \(K_{3,3}\) are the two fundamental non-planar graphs.

Practice 11.12Planar Graphs and Euler's Formula
  1. A connected planar graph has 6 vertices and 9 edges. How many faces does it have?
  2. A connected planar graph has 8 vertices and 6 faces. How many edges does it have?
  3. A tree has \(n\) vertices and \(n - 1\) edges. Use Euler's formula to determine how many faces a tree has, and explain why this answer makes sense.
  4. Explain why the definition of a planar graph says "can be drawn" rather than "is drawn" without crossings.
  5. Why are \(K_5\) and \(K_{3,3}\) considered the fundamental obstructions to planarity?

Network Optimization in Transportation and Computing

The topics of this chapter — trees, spanning trees, shortest paths, Euler circuits, Hamilton circuits, planarity — come together in a broad area called network optimization. This section surveys how these ideas are applied in real systems.

Transportation Networks

Road and rail networks are naturally modeled as graphs. Vertices represent cities, intersections, or stations. Edges represent roads or rail lines, usually weighted by distance or travel time.

Airline route planning uses similar tools. A graph of airports and routes can be analyzed for redundancy (are all airports reachable if one route is closed?), efficiency (shortest connection between cities), and cost optimization.

Communication and Data Networks

The Internet is a massive graph. Routers are vertices; network links are edges with weights representing latency, bandwidth, or cost. Routing protocols (like OSPF and BGP) implement shortest-path and spanning-tree algorithms on this graph.

Spanning trees prevent broadcast storms in network switching: a switched network uses a spanning tree (implemented by the Spanning Tree Protocol) to ensure that data frames travel without looping.

Minimum spanning trees are used when building new network infrastructure — connecting data centers, fiber-optic lines, or wireless access points at minimum cost.

Scheduling and Assignment Problems

Many scheduling problems can be modeled as graph problems. Bipartite graphs (studied in Chapter 10) model matching problems: assigning students to project teams, matching job applicants to positions, or pairing items with slots. Finding a maximum matching in a bipartite graph is an important optimization problem.

Chromatic scheduling (also related to graph coloring, a topic in advanced graph theory) assigns resources to tasks so that no two conflicting tasks share a resource — just as no two adjacent vertices in a graph share a color.

Logistics and Distribution

Euler circuit algorithms are used in route planning for:

When all edge degrees are even, the Euler circuit solves the problem exactly. When some vertices have odd degree, the Chinese Postman Problem finds the minimum-weight traversal by duplicating some edges — a solvable variant studied in operations research.

Artificial Intelligence and Search

Tree structures are fundamental to AI search:

MGU Library Connection
  • The MGU Computer Science and Artificial Intelligence pages cover search algorithms, game trees, and machine learning decision trees in detail. The graph-theoretic foundations developed in Chapters 10 and 11 connect directly to these applications.
Practice 11.13Applications Discussion
  1. Explain how a minimum spanning tree could help a company decide where to install new fiber-optic lines.
  2. Why might a switched network use a spanning tree rather than allowing all possible connections to remain active?
  3. Describe, in your own words, the difference between the Euler circuit problem and the Chinese Postman Problem.
  4. Explain how a game tree models the possible moves in a game like tic-tac-toe.

Common Tree and Network Mistakes

This section identifies the most frequent errors students make when working with trees, spanning trees, shortest paths, and Euler and Hamilton problems.

Mistake 1 — Confusing Trees with Arbitrary Connected Graphs
"This graph is connected and branches outward, so it must be a tree." Correct: A tree is a connected acyclic graph. A connected graph with cycles is not a tree. Always verify: count edges. A tree on n vertices has exactly n − 1 edges. If a connected graph has n or more edges, it has a cycle and is not a tree.
Mistake 2 — Thinking Every Connected Graph Has a Unique Spanning Tree
"The spanning tree of this graph is..." Correct: Most connected graphs have many spanning trees. The minimum spanning tree minimizes total edge weight, but there may be multiple spanning trees with the same minimum weight (a tie). When Kruskal's or Prim's algorithm encounters a tie among edges, either choice may be valid, and different tie-breaking choices may produce different but equally valid MSTs.
Mistake 3 — Applying Dijkstra's Algorithm to Graphs with Negative Edge Weights
Running Dijkstra's algorithm without checking edge weights for negatives. Correct: Dijkstra's algorithm assumes all edge weights are non-negative. With negative weights, the "visited" finalization step breaks down — a later path through a negative edge might improve a distance that was already finalized. For graphs with negative weights, use the Bellman-Ford algorithm. If all weights are non-negative, Dijkstra's algorithm is safe.
Mistake 4 — Confusing Euler Paths with Hamilton Paths
"Visit every city exactly once" treated as an Euler problem. Correct: Euler paths traverse every edge exactly once. Hamilton paths visit every vertex exactly once. A helpful memory aid: Euler → Edges; Hamilton → Homes (vertices, the places you stop). "Visit every city exactly once" is a Hamilton problem. "Travel every road exactly once" is an Euler problem.
Mistake 5 — Using Euler Degree Conditions to Determine Hamilton Path Existence
"This graph satisfies the Euler circuit condition, so it must have a Hamilton circuit too." Correct: The Euler degree conditions say nothing about Hamilton paths. A graph can satisfy the Euler circuit condition and still have no Hamilton circuit, or vice versa. For Hamilton paths, use Dirac's or Ore's theorem (sufficient conditions only), or check small graphs by inspection.
Mistake 6 — Forgetting the Outer Face in Euler's Formula
Counting only the interior regions of a planar drawing as "faces." Correct: Always include the outer face. Every planar graph has at least one face — the outer region — even if it has no interior faces. For a tree (no cycles), there is exactly one face. Check: for a tree with n vertices and n − 1 edges, Euler's formula gives n − (n−1) + 1 = 2. ✓
Mistake 7 — Applying Spanning Tree Algorithms to Disconnected Graphs
Running Kruskal's or Prim's algorithm on a graph without checking connectivity. Correct: Kruskal's and Prim's algorithms find spanning trees in connected graphs. If the graph is disconnected, no spanning tree exists, because a spanning tree must reach all vertices. The algorithms will produce a spanning forest instead. Verify connectivity before applying spanning tree algorithms.
Mistake 8 — Confusing Minimum Spanning Trees with Shortest Paths
"The shortest path between two vertices must use edges from the minimum spanning tree." Correct: A minimum spanning tree connects all vertices at minimum total cost, but it does not minimize the path length between any specific pair of vertices. The shortest path between two vertices may not use edges from the minimum spanning tree. Use Dijkstra's algorithm for shortest-path problems and Kruskal's or Prim's algorithm for minimum spanning tree problems — they answer different questions.

Chapter Summary

Key Terms Review

tree
A connected graph with no cycles. On n vertices, it has exactly n − 1 edges.
forest
A graph with no cycles, possibly disconnected; each component is a tree.
leaf
A vertex of degree 1 in a tree, or a vertex with no children in a rooted tree.
rooted tree
A tree with a designated root vertex, introducing a hierarchy.
root
The topmost vertex of a rooted tree; has no parent.
parent, child, sibling
Vocabulary describing the hierarchy in a rooted tree.
depth
The distance, in edges, from the root to a vertex.
height
The maximum depth of any vertex in a rooted tree.
binary tree
A rooted tree in which every vertex has at most two children.
spanning tree
A subgraph of a connected graph that includes all vertices and forms a tree.
minimum spanning tree
A spanning tree with minimum total edge weight.
Kruskal's algorithm
An MST algorithm that sorts edges by weight and adds the cheapest non-cycle-creating edge at each step.
Prim's algorithm
An MST algorithm that grows the tree from a starting vertex, always adding the cheapest edge to a new vertex.
shortest path
A path between two vertices with minimum total edge weight.
Dijkstra's algorithm
A shortest-path algorithm for graphs with non-negative edge weights.
relaxation
Updating a distance estimate when a shorter path is found.
Euler path / circuit
A path or closed path traversing every edge exactly once.
Hamilton path / circuit
A path or closed path visiting every vertex exactly once.
Traveling Salesman Problem
The problem of finding a minimum-weight Hamilton circuit.
planar graph
A graph that can be drawn in the plane without edge crossings.
face
A region of the plane bounded by edges in a planar drawing, including the outer face.
Euler's formula
For connected planar graphs, V − E + F = 2.

Concept Review Questions

Answer in full sentences.

  1. State the definition of a tree. What two conditions must both be satisfied?
  2. What is the relationship between the number of vertices and the number of edges in a tree?
  3. What is the difference between a tree and a forest?
  4. What does it mean for a tree to be rooted? What vocabulary does the root introduce?
  5. What is a binary tree? Give an example of where binary trees appear in computing.
  6. What is a spanning tree of a connected graph? How is it different from the original graph?
  7. What makes a spanning tree a minimum spanning tree?
  8. State the main idea behind Kruskal's algorithm in one or two sentences.
  9. State the main idea behind Prim's algorithm in one or two sentences.
  10. What does Dijkstra's algorithm compute? What restriction does it require on edge weights?
  11. What is the relaxation step in Dijkstra's algorithm? Why is it necessary?
  12. State the condition for an Euler circuit to exist in a connected graph.
  13. State the condition for an Euler path (not a circuit) to exist in a connected graph.
  14. What is the difference between an Euler path and a Hamilton path?
  15. Why is the Hamilton circuit problem considered harder than the Euler circuit problem?
  16. Define a planar graph. Does a graph's planarity depend on how it is drawn?
  17. State Euler's formula for connected planar graphs. What do V, E, and F represent?
  18. What are \(K_5\) and \(K_{3,3}\)? Why are they significant?

Tree Practice

Part AConcept Check
  1. Determine whether each graph is a tree, a forest, or neither: (a) 6 vertices, 5 edges, connected, no cycles. (b) 6 vertices, 5 edges, two components. (c) 6 vertices, 6 edges, connected. (d) 1 vertex, 0 edges.
  2. A tree has 9 vertices. How many edges does it have?
  3. Can a tree have a cycle? Explain.
  4. A tree has 12 edges. How many vertices does it have?
Part BRooted Tree Practice
  1. Draw a rooted tree with root A, where A has children B and C, B has children D and E, and C has child F (a leaf). F has child G. (a) What is the height of the tree? (b) What is the depth of G? (c) What are the leaves? (d) Who is the parent of E?
  2. A rooted binary tree has 7 vertices. What is the minimum possible height? What is the maximum possible height?
  3. Explain why a rooted tree with height 3 can have at most \(2^4 - 1 = 15\) vertices if it is a binary tree.
Part CSkill Practice
  1. List all non-isomorphic trees with exactly 4 vertices. (Isomorphic trees have the same structure up to labeling.)
  2. A tree is called a path if it looks like a sequence of vertices with each connected to the next. A tree is called a star if one central vertex is connected to all others. Describe the degree sequence of: (a) a path on 5 vertices. (b) a star with 5 vertices (one center, four leaves).
  3. A tree on 8 vertices has exactly one vertex of degree 4. What are the possible degree sequences for such a tree? (Remember: the sum of all degrees equals twice the number of edges.)

Answers may be placed in the answer key.

Spanning Tree Practice

Part AConcept Check
  1. Does every connected graph have a spanning tree? Does every disconnected graph have a spanning tree?
  2. How many edges does a spanning tree of a connected graph on 10 vertices have?
  3. If a connected graph on 7 vertices has 10 edges, how many edges must be removed to produce a spanning tree?
Part BSkill Practice
  1. A graph has vertices A, B, C, D, E and edges AB, AC, BC, BD, CD, CE, DE. Find two different spanning trees of this graph. Confirm each has the correct number of edges.
  2. A graph has vertices A, B, C, D, E, F with edges and weights: AB: 3, AC: 1, BC: 4, BD: 2, CD: 5, CE: 6, DE: 7, EF: 2, DF: 9. Apply Kruskal's algorithm to find a minimum spanning tree. List the edges in the order they are added and the total weight.
  3. Apply Prim's algorithm to the same graph in problem 2, starting from vertex A. List the vertices and edges as they are added and verify the total weight matches.
  4. Two students apply Kruskal's algorithm to a graph. One student gets the spanning tree {AC, BD, AB, CE, EF}. The other gets {AC, BD, BC, CE, EF}. Both have total weight 14. Can both be correct? Explain.

Answers may be placed in the answer key.

Shortest Path Practice

Part AConcept Check
  1. What is the difference between a shortest path and a minimum spanning tree?
  2. Can a shortest path between two vertices include a vertex more than once? Why or why not?
  3. Why does Dijkstra's algorithm require non-negative edge weights?
Part BSkill Practice
  1. A weighted graph has vertices A, B, C, D, E and edges: AB: 10, AC: 3, BC: 4, BD: 8, CD: 6, CE: 7, DE: 2. Apply Dijkstra's algorithm starting from A. Show the distance table after each step. What is the shortest distance from A to D?
  2. In the graph from problem 1, trace the actual shortest path (not just the distance) from A to D. What sequence of vertices does it use?
  3. A student applies Dijkstra's algorithm and selects vertex C before vertex B, even though d(B) < d(C) at the time. What mistake has the student made? How would this affect the result?
  4. A weighted graph has edges AB: 5, AC: 2, BC: 1, BD: 4, CD: 3. Starting from A, find the shortest distances to all other vertices. Which path connects A to D most cheaply?

Answers may be placed in the answer key.

Euler and Hamilton Practice

Part AEuler Practice
  1. For each graph described, determine whether an Euler circuit, Euler path (not circuit), or neither exists. (a) All 6 vertices have degree 4. (b) Exactly 2 vertices have odd degree; the rest are even. (c) All 5 vertices have odd degree. (d) A cycle graph \(C_6\) (a hexagon — 6 vertices arranged in a ring).
  2. A graph has 8 vertices with degrees 2, 2, 3, 3, 4, 4, 5, 5. Does it have an Euler circuit? An Euler path?
  3. A graph has 5 vertices with degrees all equal to 2. What type of graph is this? Does it have an Euler circuit?
  4. Explain why the sum of all degrees in any graph must be even. Use this to explain why a graph can never have exactly one vertex of odd degree.
Part BHamilton Practice
  1. A complete graph \(K_4\) has 4 vertices, each with degree 3. Does Dirac's theorem guarantee a Hamilton circuit? Check directly whether a Hamilton circuit exists by listing the vertices.
  2. A graph has 8 vertices. Each vertex has degree at least 4. Does Dirac's theorem apply? What does it conclude?
  3. A graph has 6 vertices with degrees 2, 2, 3, 3, 3, 3. Does Dirac's theorem guarantee a Hamilton circuit?
  4. Explain in your own words why the Hamilton circuit problem is considered much harder than the Euler circuit problem.
  5. A delivery driver must visit 5 locations and return to the starting depot. The locations form a complete weighted graph (all pairwise distances given). How many distinct Hamilton circuits are there (not counting direction or starting point)? How does this number grow as the number of locations increases?

Answers may be placed in the answer key.

Applications

Problem 1Network Design

A municipality wants to install fiber-optic internet in a neighborhood with 7 key locations (homes, businesses, and a central hub). An engineer has surveyed all possible cable routes and their costs:

RouteCost (thousands)
Hub to A4
Hub to B7
Hub to C3
A to B2
A to D5
B to D1
B to E6
C to F8
D to E4
E to F3
  1. Apply Kruskal's algorithm to find the minimum spanning tree. What routes should be built, and what is the total cost?
  2. If the route Hub to C (cost 3) is unavailable (the terrain makes it infeasible), apply Kruskal's algorithm again. How does the MST change? What is the new total cost?
Problem 2Navigation

A city's public transit network connects 6 stations: Central, North, South, East, West, and Terminal. Travel times in minutes between directly connected stations are:

ConnectionTime
Central to North8
Central to South12
Central to East6
North to West5
North to Terminal10
South to East7
East to Terminal9
West to Terminal4
  1. Apply Dijkstra's algorithm from Central. What is the minimum travel time from Central to Terminal?
  2. What sequence of stations minimizes travel from Central to Terminal?
  3. If the East–Terminal connection closes, what is the new minimum travel time from Central to Terminal?
Problem 3Euler and Route Planning

A city's sanitation department needs to sweep every street in a small district. The district has 5 intersections (A, B, C, D, E) and the following streets (edges): AB, BC, CD, DE, EA, AC, BD.

  1. Count the degree of each intersection.
  2. Does an Euler circuit exist? If not, how many odd-degree vertices are there?
  3. If the department must traverse every street at least once and wants to minimize repetitions, which streets must be repeated, and why?
Problem 4Circuit Board

A simplified circuit board has 5 components arranged so that connections must be made between: 1–2, 1–3, 2–3, 2–4, 3–4, 3–5, 4–5.

  1. Model this as a graph. Is it planar? (Draw it and try to arrange components so no connections cross.)
  2. If the board has 5 components (vertices) and 7 connections (edges) and is planar, how many faces does Euler's formula predict?
  3. Explain why minimizing connections (using a spanning tree) might reduce the risk of short circuits.

Error Analysis

In each problem below, a student has made an error. Identify the error and explain the correct approach.

Problem 1
"This graph has 7 vertices and 6 edges, so it must be a tree."

What is missing from the student's reasoning?

Problem 2
A student applies Kruskal's algorithm and produces a spanning subgraph with 5 vertices and 6 edges (two more than a spanning tree would have). The student says: "I got the minimum spanning tree; I added the minimum-weight edges."

What went wrong?

Problem 3
A student is asked whether an Euler path exists in a graph where all 8 vertices have degree 3. The student says: "All degrees are odd, so the graph has an Euler path."

Identify and correct the error.

Problem 4
A student applies Dijkstra's algorithm and updates the distance to vertex B to 12. Later, a shorter path to B (total length 9) is discovered through vertex C. The student says: "We already finalized B at distance 12, so we can't change it."

Identify and correct the error. Under what circumstances would it actually be wrong to update a finalized vertex?

Problem 5
"If a graph has a Hamilton circuit, then it also has an Euler circuit."

Is this true? Provide a counterexample if it is false.

Problem 6
A student draws a planar graph with 6 vertices and 9 edges and counts 4 faces. They check: 6 − 9 + 4 = 1 ≠ 2. They conclude: "Euler's formula is wrong."

What is the likely error? What should the correct face count be?

Answers may be placed in the answer key.

Chapter 11 Checkpoint

Chapter 11 Checkpoint
Complete without assistance — assesses all key skills and concepts from Chapter 11
Problem 1 — Trees and Spanning Trees
  1. A graph has vertices A, B, C, D, E with edges AB, BC, CD, DE, AC, BD. Is this graph a tree? Explain by checking both connectivity and acyclicity (or by counting edges).
  2. Find a spanning tree of this graph. State which edge(s) you removed and why.
Problem 2 — Kruskal's and Dijkstra's Algorithms
  1. A weighted graph has edges AB: 6, AC: 2, BC: 5, BD: 3, CD: 4, CE: 8, DE: 1. Apply Kruskal's algorithm to find a minimum spanning tree. List edges in the order added and state the total weight.
  2. Apply Dijkstra's algorithm starting from vertex A to find the shortest distance from A to every other vertex. Show the distance table after each step.
Problem 3 — Euler and Hamilton Conditions
  1. A connected graph has 8 vertices with degrees 2, 2, 2, 4, 4, 4, 4, 2. Does an Euler circuit exist? Justify your answer.
  2. Does Dirac's theorem guarantee a Hamilton circuit for this graph? (\(n = 8\), so \(n/2 = 4\).) Justify.
Problem 4 — Planar Graphs
  1. A planar graph has 9 vertices and 13 edges. How many faces does Euler's formula predict?
  2. A student draws this graph and counts only 5 faces (not counting the outer face). Without checking the student's drawing, use Euler's formula to determine whether they made an error. What should the face count be?
Problem 5 — Short Proof
  1. Claim: A tree on \(n \geq 2\) vertices has at least 2 leaves (vertices of degree 1). Write a clear argument supporting this claim. You may reason from the properties of trees rather than producing a formal induction proof. Hint: Consider what happens when you follow a path in a tree as far as possible. What kind of vertex must you end at? Why must this happen in at least two directions?
Problem 6 — Application
  1. A logistics company needs to connect 6 warehouses (W1 through W6) with a road network at minimum construction cost. The possible roads and their costs are: W1–W2: 9, W1–W3: 4, W2–W4: 7, W2–W5: 2, W3–W4: 5, W3–W6: 3, W4–W5: 6, W4–W6: 8, W5–W6: 1. Apply Kruskal's algorithm to find the minimum spanning tree and the minimum total road cost.
  2. A road inspector must travel every road in the minimum spanning tree exactly once to inspect it. The tree has 5 roads (edges). Does an Euler path exist on this spanning tree? (Hint: what are the degrees of the vertices in a spanning tree?)
  3. Explain why Euler paths on trees are always straightforward to analyze.
Looking Ahead
Chapter 12: Algorithms and Complexity

Trees and network algorithms are among the most practically important topics in discrete mathematics. The connections to computing and higher mathematics are direct. Rooted trees, binary trees, binary search trees, heaps, and tries are foundational data structures in every programming language and every major software system. Kruskal's and Prim's algorithms are taught in every algorithms course as canonical examples of greedy algorithm design, and Dijkstra's algorithm appears in GPS navigation systems, network routing protocols, and shortest-path computations in social networks and recommendation systems.

The Hamilton circuit problem and the Traveling Salesman Problem are among the most famous NP-complete problems, and their difficulty is central to the unsolved \(P \neq NP\) problem — one of the Millennium Prize Problems in mathematics. Understanding why Euler circuits are easy and Hamilton circuits are hard is an entry point into this deep theoretical territory. Decision trees and random forests are among the most powerful machine learning algorithms, and search algorithms on trees and graphs form the backbone of AI planning, puzzle solving, and game playing. Properties like connectivity, shortest paths, spanning subgraphs, and planarity are central to network science — the study of social networks, the internet, biological networks, and citation networks.

Chapter 12 will continue this bridge, asking not just "does a solution exist?" but "how efficiently can we find it?" The efficiency of Kruskal's, Prim's, and Dijkstra's algorithms will be analyzed using the Big-O notation introduced in Chapter 12.

MGU Library Connection
  • Graph Theory Vocabulary Reference — Appendix L of this textbook
  • Tree and Network Algorithm Reference — Appendix M of this textbook
  • Chapter 5: Mathematical Induction and Recursion — for the inductive argument behind the leaf-counting claim in Checkpoint Problem 5
  • Chapter 12: Algorithms and Complexity — for Big-O analysis of Kruskal's, Prim's, and Dijkstra's algorithms
  • MGU Computer Science pages: binary search trees, heaps, union-find structures, priority queues, breadth-first and depth-first search
  • MGU Artificial Intelligence Foundations pages: game trees, A* search, decision trees
  • MGU Dictionary entries: tree, spanning tree, minimum spanning tree, shortest path, Euler circuit, Hamilton circuit, planar graph