Contemporary Mathematics

# 12.10Trees

Figure 12.203 In graph theory, graphs known as trees have structures in common with live trees. (credit: “Row of trees in Roslev” by AKA CJ/Flickr, Public Domain)

### Learning Objectives

After completing this section, you should be able to:

1. Describe and identify trees.
2. Determine a spanning tree for a connected graph.
3. Find the minimum spanning tree for a weighted graph.
4. Solve application problems involving trees.

We saved the best for last! In this last section, we will discuss arguably the most fun kinds of graphs, trees. Have you every researched your family tree? Family trees are a perfect example of the kind of trees we study in graph theory. One of the characteristics of a family tree graph is that it never loops back around, because no one is their own grandparent!

### What Is A Tree?

Whether we are talking about a family tree or a tree in a forest, none of the branches ever loops back around and rejoins the trunk. This means that a tree has no cyclic subgraphs, or is acyclic. A tree also has only one component. So, a tree is a connected acyclic graph. Here are some graphs that have the same characteristic. Each of the graphs in Figure 12.204 is a tree.

Figure 12.204 Graphs T, P, and S

Let’s practice determining whether a graph is a tree. To do this, check if a graph is connected and has no cycles.

### Example 12.46

#### Identifying Trees

Identify any trees in Figure 12.205. If a graph is not a tree, explain how you know.

Figure 12.205 Graphs M, N, and P

1.
There are some configurations that are commonly used when setting up computer networks. Several of them are shown in the given figure. Which of the configurations in the figure appear to have the characteristics of a tree graph? If a configuration does not appear to have the characteristics of a tree graph, explain how you know.
Common Network Configurations

### Types of Trees

Mathematicians have had a lot of fun naming graphs that are trees or that contain trees. For example, the graph in Figure 12.206 is not a tree, but it contains two components, one containing vertices a through d, and the other containing vertices e through g, each of which would be a tree on its own. This type of structure is called a forest. There are also interesting names for trees with certain characteristics.

• A path graph or linear graph is a tree graph that has exactly two vertices of degree 1 such that the only other vertices form a single path between them, which means that it can be drawn as a straight line.
• A star tree is a tree that has exactly one vertex of degree greater than 1 called a root, and all other vertices are adjacent to it.
• A starlike tree is a tree that has a single root and several paths attached to it.
• A caterpillar tree is a tree that has a central path that can have vertices of any degree, with each vertex not on the central path being adjacent to a vertex on the central path and having a degree of one.
• A lobster tree is a tree that has a central path that can have vertices of any degree, with paths consisting of either one or two edges attached to the central path.

Examples of each of these types of structures are given in Figure 12.207.

Figure 12.206 Forest Graph F
Figure 12.207 Six Types of Trees

### Example 12.47

#### Identifying Types of Trees

Each graph in Figure 12.208 is one of the special types of trees we have been discussing. Identify the type of tree.

Figure 12.208 Graphs U and V

Of the network configurations from Figure 12.297, which, if any, has the characteristics of a
1.
Star tree?
2.
Caterpillar tree?
3.
Path graph?

### Characteristics of Trees

As we study trees, it is helpful to be familiar with some of their characteristics. For example, if you add an edge to a tree graph between any two existing vertices, you will create a cycle, and the resulting graph is no longer a tree. Some examples are shown in Figure 12.209. Adding edge bj to Graph T creates cycle (b, c, i, j). Adding edge rt to Graph P creates cycle (r, s, t). Adding edge tv to Graph S creates cycle (t, u, v).

Figure 12.209 Adding Edges to Trees

It is also true that removing an edge from a tree graph will increase the number of components and the graph will no longer be connected. In fact, you can see in Figure 12.210 that removing one or more edges can create a forest. Removing edge qr from Graph P creates a graph with two components, one with vertices o, p and q, and the other with vertices r, s, and t. Removing edge uw from Graph S creates two components, one with just vertex w and the other with the rest of the vertices. When two edges were removed from Graph T, edge bf and edge cd, creates a graph with three components as shown in Figure 12.210.

Figure 12.210 Removing Edges from Trees

A very useful characteristic of tree graphs is that the number of edges is always one less than the number of vertices. In fact, any connected graph in which the number of edges is one less than the number of vertices is guaranteed to be a tree. Some examples are given in Figure 12.211.

Figure 12.211 Number of Vertices and Edges in Trees vs. Other Graphs

### FORMULA

The number of edges in a tree graph with $nn$ vertices is $n−1n−1$.

A connected graph with n vertices and $n−1n−1$ edges is a tree graph.

### Example 12.48

#### Exploring Characteristics of Trees

Use Graphs I and J in Figure 12.212 to answer each question.

Figure 12.212 Graphs I and J
1. Which vertices are in each of the components that remain when edge be is removed from Graph I?
2. Determine the number of edges and the number of vertices in Graph J. Explain how this confirms that Graph J is a tree.
3. What kind of cycle is created if edge im is added to Graph J?

Use Graphs I and J in Figure 12.301 to answer each question.
1.
Which vertices are in each of the components that remain when edge jl is removed from Graph J?
2.
Determine the number of edges and the number of vertices in Graph I. Explain how this confirms that Graph I is a tree.
3.
What kind of cycle is created if edge cf is added to Graph I?

### Who Knew?

#### Graph Theory in the Movies

In the 1997 film Good Will Hunting, the main character, Will, played by Matt Damon, solves what is supposed to be an exceptionally difficult graph theory problem, “Draw all the homeomorphically irreducible trees of size $n=10n=10$.” That sounds terrifying! But don’t panic. Watch this great Numberphile video to see why this is actually a problem you can do at home!

### Spanning Trees

Suppose that you planned to set up your own computer network with four devices. One option is to use a “mesh topology” like the one in Figure 12.213, in which each device is connected directly to every other device in the network.

Figure 12.213 Common Network Configurations

The mesh topology for four devices could be represented by the complete Graph A1 in Figure 12.214 where the vertices represent the devices, and the edges represent network connections. However, the devices could be networked using fewer connections. Graphs A2, A3, and A4 of Figure 12.214 show configurations in which three of the six edges have been removed. Each of the Graphs A2, A3 and A4 in Figure 12.214 is a tree because it is connected and contains no cycles. Since Graphs A2, A3 and A4 are also subgraphs of Graph A1 that include every vertex of the original graph, they are also known as spanning trees.

Figure 12.214 Network Configurations for Four Devices

By definition, spanning trees must span the whole graph by visiting all the vertices. Since spanning trees are subgraphs, they may only have edges between vertices that were adjacent in the original graph. Since spanning trees are trees, they are connected and they are acyclic. So, when deciding whether a graph is a spanning tree, check the following characteristics:

• All vertices are included.
• No vertices are adjacent that were not adjacent in the original graph.
• The graph is connected.
• There are no cycles.

### Example 12.49

#### Identifying Spanning Trees

Use Figure 12.215 to determine which of graphs M1, M2, M3, and M4, are spanning trees of Q.

Figure 12.215 Graphs Q, M1, M2, M3, and M4

Use the given figure for the following exercises.
1.
Since sq is not an edge in Graph H, Graph N1 cannot be a spanning tree of H.
1. True
2. False
2.
Graph N2 is a spanning tree of Graph H.
1. True
2. False
3.
Graph N3 is a spanning tree of Graph H.
1. True
2. False
4.
Since there is no path between p and t in Graph N4, it cannot be a spanning tree of any graph.
1. True
2. False

### Constructing a Spanning Tree Using Paths

Suppose that you wanted to find a spanning tree within a graph. One approach is to find paths within the graph. You can start at any vertex, go any direction, and create a path through the graph stopping only when you can’t continue without backtracking as shown in Figure 12.216.

Figure 12.216 First Phase to Construct a Spanning Tree

Once you have stopped, pick a vertex along the path you drew as a starting point for another path. Make sure to visit only vertices you have not visited before as shown in Figure 12.217.

Figure 12.217 Intermediate Phase to Construct a Spanning Tree

Repeat this process until all vertices have been visited as shown in Figure 12.218.

Figure 12.218 Final Phase to Construct a Spanning Tree

The end result is a tree that spans the entire graph as shown in Figure 12.219.

Figure 12.219 The Resulting Spanning Tree

Notice that this subgraph is a tree because it is connected and acyclic. It also visits every vertex of the original graph, so it is a spanning tree. However, it is not the only spanning tree for this graph. By making different turns, we could create any number of distinct spanning trees.

### Example 12.50

#### Constructing Spanning Trees

Construct two distinct spanning trees for the graph in Figure 12.220.

Figure 12.220 Graph L

1.
Construct three distinct spanning trees for Graph J.
Graph J

### Revealing Spanning Trees

Another approach to finding a spanning tree in a connected graph involves removing unwanted edges to reveal a spanning tree. Consider Graph D in Figure 12.223.

Figure 12.223 Graph D

Graph D has 10 vertices. A spanning tree of Graph D must have 9 edges, because the number of edges is one less than the number of vertices in any tree. Graph D has 13 edges so 4 need to be removed. To determine which 4 edges to remove, remember that trees do not have cycles. There are four triangles in Graph D that we need to break up. We can accomplish this by removing 1 edge from each of the triangles. There are many ways this can be done. Two of these ways are shown in Figure 12.224.

Figure 12.224 Removing Four Edges from Graph D

### Example 12.51

#### Removing Edges to Find Spanning Trees

Use the graph in Figure 12.225 to answer each question.

Figure 12.225 Graph V
1. Determine the number of edges that must be removed to reveal a spanning tree.
2. Name all the undirected cycles in Graph V.
3. Find two distinct spanning trees of Graph V.

1.
Name three edges that you could remove from Graph V in Figure 12.316 to form a third spanning tree, different from those in the solution to Example 12.50 Exercise 3.

### Who Knew?

#### Chains of Affection

Here is a strange question to ask in a math class: Have you ever dated your ex’s new partner’s ex? Research suggests that your answer is probably no. When researchers Peter S. Bearman, James Moody, and Katherine Stovel attempted to compare the structure of heterosexual romantic networks at a typical midwestern high school to simulated networks, they found something surprising. The actual social networks were more like spanning trees than other possible models because there were very few short cycles. In particular, there were almost no four-cycles.

Figure 12.228 Chains of Affection

“…the prohibition against dating (from a female perspective) one’s old boyfriend’s current girlfriend’s old boyfriend – accounts for the structure of the romantic network at [the highschool].”

In their article “Chains of Affection: The Structure of Adolescent Romantic and Sexual Networks,” the researchers went on to explain the implications for the transmission of sexually transmitted diseases. In particular, social structures based on tree graphs are less dense and more likely to fragment. This information can impact social policies on disease prevention. (Peter S. Bearman, James Moody, and Katherine Stovel, “Chains of Affection: The Structure of Adolescent Romantic and Sexual Networks,” American Journal of Sociology Volume 110, Number 1, pp. 44-91, 2004)

### Kruskal’s Algorithm

In many applications of spanning trees, the graphs are weighted and we want to find the spanning tree of least possible weight. For example, the graph might represent a computer network, and the weights might represent the cost involved in connecting two devices. So, finding a spanning tree with the lowest possible total weight, or minimum spanning tree, means saving money! The method that we will use to find a minimum spanning tree of a weighted graph is called Kruskal’s algorithm. The steps for Kruskal’s algorithm are:

Step 1: Choose any edge with the minimum weight of all edges.

Step 2: Choose another edge of minimum weight from the remaining edges. The second edge does not have to be connected to the first edge.

Step 3: Choose another edge of minimum weight from the remaining edges, but do not select any edge that creates a cycle in the subgraph you are creating.

Step 4: Repeat step 3 until all the vertices of the original graph are included and you have a spanning tree.

### Example 12.52

#### Using Kruskal’s Algorithm

A computer network will be set up with six devices. The vertices in the graph in Figure 12.229 represent the devices, and the edges represent the cost of a connection. Find the network configuration that will cost the least. What is the total cost?

Figure 12.229 Graph of Network Connection Costs

1.
Find a minimum spanning tree for the weighted graph. Give its total weight.
Weighted Graph

85.
The number of cycles in a spanning tree is one less than the number of vertices.
1. True
2. False
86.
A spanning tree contains no triangles.
1. True
2. False
87.
A spanning tree includes every vertex of the original graph.
1. True
2. False
88.
There is a unique path between each pair of vertices in a spanning tree.
1. True
2. False
89.
A spanning tree must be connected.
1. True
2. False
90.
Kruskal’s algorithm is a method for finding all the different spanning trees in a given graph.
1. True
2. False
91.
Only graphs that are trees have spanning trees.
1. True
2. False
92.
A minimum spanning tree of a given graph can be found using Kruskal’s algorithm.
1. True
2. False
93.
A minimum spanning tree of a given graph is the subgraph, which is a tree, includes every vertex of the original graph, and which has the least weight of all spanning trees.
1. True
2. False
94.
If a graph contains any cut edges, they must be included in any spanning tree.
1. True
2. False

### Section 12.10 Exercises

For the following exercises, refer to the figure shown.
1 .
Which graphs, if any, are trees?
2 .
Which graphs, if any, are not trees because they are not connected?
3 .
Which graphs, if any, are not trees because they contain a cycle?
For the following exercises, refer to the figure shown. Identify any graphs that fit the given description.
4 .
Tree graph
5 .
Star graph
6 .
Star like graph
7 .
Line graph (or path graph)
8 .
Lobster graph
9 .
Caterpillar graph
10 .
Forest graph
For the following exercises, use the figure shown to answer the questions.
11 .
Determine whether Graph H1 is a spanning tree of Graph H. If not, explain how you know.
12 .
Determine whether Graph H2 is a spanning tree of Graph H. If not, explain how you know.
13 .
Determine whether Graph H3 is a spanning tree of Graph H. If not, explain how you know.
14 .
Determine whether Graph Q1 is a spanning tree of Graph Q. If not, explain how you know.
15 .
Determine whether Graph Q2 is a spanning tree of Graph Q. If not, explain how you know.
16 .
Determine whether Graph Q3 is a spanning tree of Graph Q. If not, explain how you know.
For the following exercises, a student has been asked to construct a spanning tree for Graph O, as shown in the figure. The dashed lines show the first step that the student took, creating a path from vertex h to vertex d.
17 .
How many more edges must be included with the dashed edges to create a spanning tree?
18 .
List three unused (solid) edges from Graph O that cannot be used to complete the spanning tree.
19 .
Give an example of a set of edges that do not have e as an endpoint, which would complete the spanning tree.
20 .
Give an example of a set of edges that do not have f as an endpoint, which would complete the spanning tree.
For the following exercises, a student has been asked to construct a spanning tree for Graph O, as shown in the figure. The dashed lines show the first step that the student took, creating a path from vertex c to vertex h.
21 .
How many more edges must be included with the dashed edges to create a spanning tree?
22 .
List two unused edges from Graph O that cannot be used to complete the spanning tree.
23 .
Give an example of a set of edges that do not have f as an endpoint, which would complete the spanning tree.
24 .
Give an example of a set of edges that have neither c nor e as an endpoint, which would complete the spanning tree.
For the following exercises, use Graphs A, B, and C.
25 .
How many edges must be removed from Graph A to create a spanning tree?
26 .
How many edges must be removed from Graph B to create a spanning tree?
27 .
How many edges must be removed from Graph C to create a spanning tree?
28 .
Identify all the distinct cyclic subgraphs of Graph A.
29 .
Identify all the cyclic subgraphs of Graph B.
30 .
Identify all the cyclic subgraphs of Graph C.
31 .
Draw four spanning trees of Graph A each of which includes edges vs, uv, wz and xy.
32 .
Draw four spanning trees of Graph B which includes edge ut, but not ur.
33 .
Draw four spanning trees of Graph C that each have only one edge with an endpoint at vertex u.
For the following exercises, use the figure shown. Draw a graph that fits the given description.
34 .
S1, S2, S3 and S4 are all spanning trees.
35 .
S1 and S2 are spanning trees, but S4 is not.
36 .
S3 and S4 are spanning trees but S1 is not.
37 .
S2 and S3 are spanning trees but S1 is not.
38 .
S2 and S3 are spanning trees but S4 is not.
39 .
S1, S2, and S3 are spanning trees but S4 is not.
40 .
S2, S3, and S4 are spanning trees but S1 is not.
41 .
S1 and S4 are spanning trees but S2 and S3 are not.
For the following exercises, use the figure shown to find the weight of the given spanning tree.
42 .
43 .
44 .
45 .
Use Kruskal’s algorithm to draw a minimum spanning tree for Graph Z in the provided figure. Find its weight.
For the following exercises, draw a minimum spanning tree for the given graph, and calculate its weight.
46 .
Graph A
47 .
Graph C
48 .
Graph B
49 .
Graph D
For the following exercises, draw a weighted graph to represent the given information. Then use the graph to find a minimum spanning tree and give its weight. Explain what the weight represents in the given scenario.
50 .
City planners are tasked with building roadways to connect locations A, B, C, and D. The cost to build the roadways between any given pair of locations is given in the table.

A B C D
A - 125 320 275
B 125 - 110 540
C 320 110 - 1,010
D 275 540 1,010 -
Construction Costs in Thousands between Locations
51 .
In a video game, the goal is to visit five different lands, V, W, X, Y and Z, without losing all your lives. The paths between the lands are rated for danger, 1 being lowest and 10 being highest. Once a path has been traversed successfully, it is free from danger. The ratings are given in the table.

V W X Y Z
V - 2 4 9 10
W 2 - 6 8 No Path
X 4 6 - 7 No Path
Y 9 8 7 - 5
Z 10 No Path No Path 5 -
Danger Ratings between Lands
Order a print copy

As an Amazon Associate we earn from qualifying purchases.