Shortest paths and spanning trees
Identify trees and spanning trees in a network; find the minimum spanning tree and the shortest path between two vertices and explain why these may differ.
Worked examples
Identifying trees and counting edges in a spanning tree
Straightforward
Problem
A connected network has vertices. (a) How many edges must a spanning tree of this network have? (b) A connected subgraph of this network has vertices and edges. Is this subgraph a spanning tree? Give a reason.
1
Apply the formula for the number of edges in a spanning tree.
A spanning tree on vertices has exactly edges. Here , so a spanning tree has edges.
2
Compare the number of edges in the subgraph with the number required for a spanning tree.
The subgraph has edges but a spanning tree on vertices must have exactly edges. The subgraph has one edge too many.
3
State the conclusion using the definition of a tree.
A tree is connected and contains no cycles. Having edges on vertices means the subgraph contains at least one cycle, so it is not a spanning tree.
Answer
(a) A spanning tree of this network has edges. (b) No — the subgraph has edges, but a spanning tree on vertices must have exactly ; the extra edge creates a cycle.
Finding the minimum spanning tree using Kruskal's algorithm
Moderate
Problem
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). Find the minimum spanning tree and state its total weight.
1
List all edges in ascending order of weight.
(1), (2), (3), (4), (4), (5)
2
Add the smallest edge. It connects two separate vertices, so no cycle is formed.
Add (weight ). Connected components: – and the isolated vertices , , .
3
Continue adding edges in order, skipping any that would create a cycle.
Add (weight ): connects to the – component. Components: ––, , .
Add (weight ): connects . Components: –––, .
Skip (weight ): both and are already in the same component — adding this edge would create a cycle.
Add (weight ): connects . All vertices are now connected — stop.
Add (weight ): connects . Components: –––, .
Skip (weight ): both and are already in the same component — adding this edge would create a cycle.
Add (weight ): connects . All vertices are now connected — stop.
4
Calculate the total weight of the minimum spanning tree.
MST edges: (1), (2), (3), (4).
Answer
The minimum spanning tree uses edges , , and with total weight .
Finding the minimum spanning tree and shortest path
Challenging
Problem
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). (a) Find the minimum spanning tree and state its total weight. (b) Find the shortest path from to and state its length. (c) Explain in one sentence why the path from to through the MST may differ from the shortest path.
1
Sort all edges by weight to prepare for Kruskal's algorithm.
(2), (3), (4), (5), (6), (7), (8)
2
Build the MST by adding edges one at a time, skipping any that create a cycle.
Add (2): connects and .
Add (3): connects to the – component.
Add (4): connects .
Add (5): connects . All vertices are now connected — stop.
MST edges: , , , .
Add (3): connects to the – component.
Add (4): connects .
Add (5): connects . All vertices are now connected — stop.
MST edges: , , , .
3
Find the shortest path from to by evaluating all simple paths.
––––:
–––:
–––:
––:
–––:
Shortest path: ––– with length .
–––:
–––:
––:
–––:
Shortest path: ––– with length .
4
Explain why the MST path and shortest path may differ.
The MST excluded edge (weight ) in favour of (weight ) to keep the overall tree weight as low as possible. However, for travelling from to specifically, using produces a shorter route. The MST optimises across the whole network; the shortest path optimises between two specific vertices.
Answer
(a) MST edges: , , , ; total weight . (b) Shortest path: ––– with length . (c) The MST minimises the total weight of edges connecting all vertices, not the distance between any specific pair, so an edge excluded from the MST may still lie on the shortest path between two vertices.
Practise
Q1·Straightforward
A connected network has vertices. How many edges must a spanning tree of this network contain?
Explanation
A spanning tree on vertices has exactly edges. Here , so a spanning tree contains edges.
Q2·Straightforward
A connected subgraph has vertices and edges. Is this subgraph a spanning tree?
Explanation
A spanning tree on vertices must have exactly edges. This subgraph has edges, which is one more than required. The extra edge creates a cycle, so the subgraph is not a tree.
Q3·Straightforward
Which statement correctly describes a tree in the context of networks?
Explanation
A tree is a connected graph that contains no cycles. These two properties together mean a tree on vertices has exactly edges.
Q4·Straightforward
A connected network has vertices. A spanning tree of this network is formed by removing edges until no cycles remain and all vertices are still connected. How many edges does this spanning tree have?
Explanation
A spanning tree on vertices has exactly edges. Here , so the spanning tree has edges.
Q5·Moderate
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). Find the total weight of the minimum spanning tree.
Explanation
Sorting edges by weight: (1), (2), (3), (4), (4), (5).
Add (1): connects and .
Add (2): connects to the – component.
Add (3): connects to the –– component.
Skip (4): and are already connected — adding this edge would create a cycle.
Add (4): connects . All vertices are now connected.
Add (1): connects and .
Add (2): connects to the – component.
Add (3): connects to the –– component.
Skip (4): and are already connected — adding this edge would create a cycle.
Add (4): connects . All vertices are now connected.
Q6·Moderate
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). Find the total weight of the minimum spanning tree.
Explanation
Sorting edges by weight: (2), (3), (4), (5), (6), (7), (8).
Add (2): connects and .
Add (3): connects and .
Add (4): connects the component with the component.
Skip (5): and are already in the same component.
Skip (6): and are already in the same component.
Add (7): connects . All vertices are now connected.
Add (2): connects and .
Add (3): connects and .
Add (4): connects the component with the component.
Skip (5): and are already in the same component.
Skip (6): and are already in the same component.
Add (7): connects . All vertices are now connected.
Q7·Moderate
A network has vertices , , , with edges (weight ), (weight ), (weight ), (weight ) and (weight ). Find the total weight of the minimum spanning tree.
Explanation
Sorting edges by weight: (3), (4), (5), (6), (7).
Add (3): connects and .
Add (4): connects and .
Add (5): connects the component with the component. All vertices are now connected — stop.
Add (3): connects and .
Add (4): connects and .
Add (5): connects the component with the component. All vertices are now connected — stop.
Q8·Moderate
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). Find the total weight of the minimum spanning tree.
Explanation
Sorting edges by weight: (3), (4), (5), (6), (7), (8), (9).
Add (3): connects and .
Add (4): connects to the – component.
Add (5): connects to the –– component.
Add (6): connects . All vertices are now connected.
Add (3): connects and .
Add (4): connects to the – component.
Add (5): connects to the –– component.
Add (6): connects . All vertices are now connected.
Q9·Challenging
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). Find the total weight of the minimum spanning tree.
Explanation
Sorting edges by weight: (2), (3), (4), (5), (6), (7), (8).
Add (2): connects and .
Add (3): connects to the – component.
Add (4): connects .
Add (5): connects . All vertices are now connected.
Skip , , — all would create cycles or are not needed.
Add (2): connects and .
Add (3): connects to the – component.
Add (4): connects .
Add (5): connects . All vertices are now connected.
Skip , , — all would create cycles or are not needed.
Q10·Challenging
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). Find the length of the shortest path from to .
Explanation
Checking all simple paths from to :
––––:
–––: (shortest)
–––:
––:
–––:
The shortest path from to is ––– with length .
––––:
–––: (shortest)
–––:
––:
–––:
The shortest path from to is ––– with length .
Q11·Challenging
A network has vertices , , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). Find the total weight of the minimum spanning tree.
Explanation
Sorting edges by weight: (2), (3), (3), (4), (5), (6), (7), (8), (9).
Add (2): connects and .
Add (3): connects and .
Add (3): connects to the – component.
Add (4): connects to the – component.
Add (5): connects the component with the component. All vertices are now connected.
Add (2): connects and .
Add (3): connects and .
Add (3): connects to the – component.
Add (4): connects to the – component.
Add (5): connects the component with the component. All vertices are now connected.
Q12·Challenging
A network has vertices , , , , with edges (weight ), (weight ), (weight ), (weight ), (weight ) and (weight ). The minimum spanning tree uses edges , , , and has total weight . The path from to through the MST is –––– with length . The shortest path from to in the full network is ––– with length . Which statement best explains why the shortest path is shorter than the MST path?
Explanation
The MST finds the set of edges with minimum total weight that connects all vertices. It excluded (weight ) because (weight ) was cheaper for completing the tree. However, the shortest path from to only cares about the route between those two specific vertices — using gives –––, which is shorter than the MST route ––––.