Spanning trees are special subgraphs of a graph that have several important properties. First, if T is a spanning tree of graph G, then T must span G, meaning T must contain every vertex in G. Second, T must be a subgraph of G. In other words, every edge that is in T must also appear in G. Third, if every edge in T also exists in G, then G is identical to T.
Spanning trees are important in path-finding algorithms such as Dijkstra's shortest path algorithm and A* search algorithm. Spanning trees are calculated as sub-parts in those algorithms. It is also used in network routing protocols. The spanning tree protocol is one example.
There are a few general properties of spanning trees.
- A connected graph can have more than one spanning tree. They can have as many as where is the number of vertices in the graph.
- All possible spanning trees for a graph G have the same number of edges and vertices.
- Spanning trees do not have any cycles.
- Spanning trees are all minimally connected. That is, if any one edge is removed, the spanning tree will no longer be connected.
- Adding any edge to the spanning tree will create a cycle. So, a spanning tree is maximally acyclic.
- Spanning trees have edges, where is the number of vertices.
Different types of graphs have different numbers of spanning trees. Here are a few examples.
1) Complete Graphs
A complete graph is a graph where every vertex is connected to every other vertex. The number of spanning trees for a graph G with vertices is defined by the following equation: .
2) Connected Graphs
For connected graphs, spanning trees can be defined either as the minimal set of edges that connect all vertices or as the maximal set of edges that contains no cycle.
A connected graph is simply a graph that necessarily has a number of edges that is less than or equal to the number of edges in a complete graph with the same number of vertices. Therefore, the number of spanning trees for a connected graph is .
If a graph G is itself a tree, the only spanning tree of G is itself. So a tree with vertices is defined as .
4) Complete Bipartite Graph
A bipartite graph is a graph where every node can either be associated with one of two sets, or . Vertices within these sets only connect to vertices in the other. There are no intra-set edges. A complete bipartite graph then is a bipartite graph where every vertex in set is connected to every vertex in set , and vice versa.
The number of spanning trees for a bipartite graph is defined by .
5) General Graph
To calculate the number of spanning trees for a general graph, a popular theorem is Kirchhoff's theorem.
To perform this theorem, a two-dimensional matrix must be constructed that can be indexed via both row and column by the graphs' vertices. The cell in the row and column has a value that is determined by three things. If , then the value in the cell will be equal to the degree of . If and are adjacent, then the value will be . Otherwise, the value will be .
From here, an arbitrary vertex is chosen and its corresponding row and column is removed from the matrix. The determinant of this new matrix is a spanning tree .
Spanning trees can be found in linear time by simply performing breadth-first search or depth-first search. These graph search algorithms are only dependent on the number of vertices in the graph, so they are quite fast.
Breadth-first search will use a queue to hold vertices to explore later, and depth-first search will use a stack. In either case, a spanning tree can be constructed by connecting each vertex with the vertex that was used to discover it.
Unfortunately, these search algorithms are not well suited for parallel or distributed computing, an area in which spanning trees are popular. There are, however, algorithms that are designed to find spanning trees in a parallel setting.
For complete graphs, there is an exact number of edges that must be removed to create a spanning tree. For a complete graph G, a spanning tree can be calculated by removing edges. In this equation, is the number of edges, and is the number of vertices.
Minimum spanning trees are a variant of the spanning tree.
A minimum spanning tree for an unweighted graph G is a spanning tree that minimizes the number of edges or edge weights.
A minimum spanning tree for a weighted graph G is a spanning tree that minimizes the weights of the edges in the tree.
These two images show the difference between a spanning tree and minimum spanning tree. The edges that are grayed out are left out of their respective trees, but they're left in the images to show their weights.
Minimum spanning trees are very helpful in many applications and algorithms. They are often used in water networks, electrical grids, and computer networks. They are also used in graph problems like the traveling salesperson problem, and they are used in important algorithms such as the min-cut max-flow algorithm.
There are many ways to find the minimum spanning trees, but Kruskal's algorithm is probably the fastest and easiest to do by hand.
1. Find the minimum spanning tree for the graph below. What is its total weight?
The minimum spanning tree is shown below. Its total weight is 31.
- Eppstein, D. Spanning Trees. Retrieved April 10, 2016, from https://en.wikipedia.org/wiki/Spanning_tree
- Benbennick, D. Wikipedia Complete Graph. Retrieved May 21, 2016, from https://en.wikipedia.org/wiki/Complete_graph
- A, L. Wikipedia Connected Graph. Retrieved May 21, 2016, from https://en.wikipedia.org/wiki/Connectivity_(graph_theory)
- A, L. Wikipedia Tree. Retrieved May 21, 2016, from https://en.wikipedia.org/wiki/Tree_(graph_theory)
- A, K. Wikipedia Complete Bipartite Graph. Retrieved May 21, 2016, from https://en.wikipedia.org/wiki/Complete_bipartite_graph