Skip to main content
ExamExplained
NSW · Maths Standard 2
Maths Standard 2 study scene
§-Syllabus dot point
NSWMaths Standard 2Syllabus dot point

What is a minimum spanning tree, and how is it found using Prim's or Kruskal's algorithm?

Find a minimum spanning tree for a weighted graph using Prim's or Kruskal's algorithm

A focused answer to the HSC Maths Standard 2 dot point on minimum spanning trees. Definition of a spanning tree and minimum spanning tree, step-by-step Prim's and Kruskal's algorithms, and worked examples for utility networks and rural Australian infrastructure planning.

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

What this dot point is asking

NESA wants you to find a minimum spanning tree of a weighted graph using either Prim's or Kruskal's algorithm, and to show each step clearly. The MST is the most common network optimisation question in the HSC, where you cut the total cost of a network down to the smallest it can be.

The answer

Spanning tree

A spanning tree of a connected graph is a subgraph that:

  • includes every vertex of the original graph,
  • is connected (every pair of vertices linked by a path),
  • has no cycles.

A spanning tree on nn vertices always has exactly n1n - 1 edges.

Minimum spanning tree (MST)

A minimum spanning tree is a spanning tree with the smallest total edge weight among all possible spanning trees of the graph.

For a weighted graph (where each edge has a cost, distance or time), the MST connects all vertices using the least total weight.

Applications: laying the shortest total length of pipe, cable, fibre, or road to connect a set of locations.

Prim's algorithm

Weighted graph with its minimum spanning tree highlighted A weighted graph with five vertices A, B, C, D, E and seven edges. The minimum spanning tree is drawn in the heavier accent colour and contains AC 2, CD 3, AB 4 and DE 6, total 15. The non-tree edges BC 5, BD 10 and CE 7 are drawn muted. 2 3 4 6 5 10 7 A B C D E MST = AC 2 + CD 3 + AB 4 + DE 6 = 15 (accent); muted edges are not used.

Prim's algorithm builds the MST one vertex at a time, growing outward from a chosen starting vertex:

  1. Pick any starting vertex; this is the initial tree.
  2. From all edges that connect a tree vertex to a non-tree vertex, choose the one with the smallest weight.
  3. Add that edge and the new vertex to the tree.
  4. Repeat until all vertices are in the tree.

Prim's adds n1n - 1 edges in total (one per added vertex after the first).

Watch Prim's build the tree, stage by stage

The diagram above shows the finished minimum spanning tree. Here is the same graph with Prim's algorithm run one edge at a time. This lets you watch the tree grow and follow the reasoning at each step. Tree edges are heavy and in colour, and vertices already in the tree are ringed.

Stage 1, start the tree. Pick any starting vertex, say AA. The edges leaving AA are ABAB (44) and ACAC (22); the cheaper is ACAC, so the tree grows to take in CC.

Prim's algorithm: start the treePrim's tree after one edge: starting at A, the cheapest edge AC of weight 2 is added, so A and C are in the tree.23465107ABCDEStep 1Start at A. Cheapest edge from A is AC (2). A and C are now in the tree.

Stage 2, add the cheapest edge to a new vertex. Look at every edge from the tree {A,C}\{A, C\} to a vertex not yet in it: ABAB (44), BCBC (55), CDCD (33), CECE (77). The cheapest is CDCD (33), so DD joins.

Prim's algorithm: add CDPrim's tree after two edges: from A and C the cheapest edge to a new vertex is CD of weight 3, so D joins.23465107ABCDEStep 2From {A, C}, the cheapest edge to a new vertex is CD (3). D joins.

Stage 3, keep growing. From {A,C,D}\{A, C, D\} the candidates are ABAB (44), BCBC (55), CECE (77), DEDE (66), BDBD (1010). The cheapest is ABAB (44), so BB joins. The expensive edges BCBC and BDBD are never the cheapest option, so they are never used.

Prim's algorithm: add ABPrim's tree after three edges: from A, C and D the cheapest edge to a new vertex is AB of weight 4, so B joins.23465107ABCDEStep 3From {A, C, D}, the cheapest edge to a new vertex is AB (4). B joins.

Stage 4, connect the last vertex. Only EE remains. The edges reaching it are DEDE (66) and CECE (77); take the cheaper, DEDE. Every vertex is now connected, so the tree is finished: AC+CD+AB+DE=2+3+4+6=15AC + CD + AB + DE = 2 + 3 + 4 + 6 = 15.

Prim's algorithm: the finished treeThe completed minimum spanning tree AC, CD, AB, DE of total weight 15, with all five vertices connected.23465107ABCDEStep 4Only E left: add DE (6). Tree complete: 2 + 3 + 4 + 6 = 15.

Kruskal's algorithm

Kruskal's algorithm sorts all edges and adds them in order, skipping any that create a cycle:

  1. List all edges in order of increasing weight.
  2. Take the cheapest unused edge; if it does not create a cycle with edges already chosen, add it.
  3. Repeat until n1n - 1 edges are added.

Both algorithms always produce a minimum spanning tree, though the exact edges may differ if there are ties in weight.

Which to use

  • Prim's is easier when there are many edges (you only consider edges from the current tree).
  • Kruskal's is easier when edges are pre-sorted (just go down the list, checking for cycles).

The HSC accepts either; show your working clearly so the marker can follow which algorithm you used.

Is the minimum spanning tree unique?

The total weight of the MST is always unique. Every minimum spanning tree of a graph adds up to the same total. The exact set of edges is also unique when all the edge weights are different. If two or more edges share a weight, there can be more than one MST. This happens because a tie can be broken in different ways, picking different edges, but each tree still has the same minimum total. So if you and a classmate pick different equal-weight edges, you can both be correct, as long as the totals match and each tree is valid.

Cycle check (Kruskal's)

An edge creates a cycle if both of its endpoints are already linked, either directly or through edges you have already chosen. For small graphs you can usually see this by eye. For larger graphs, keep track of which vertices sit in which connected piece (called a component) as you add edges.

Exam-style practice questions

Practice questions written in the style of NESA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

2022 HSC-style5 marksA network has 66 vertices and weighted edges connecting them. Use Prim's algorithm starting from vertex AA to find a minimum spanning tree. Show your work. (Weights given in the question.)
Show worked answer →

Prim's algorithm steps:

Step 1: Start with AA. Add the cheapest edge from AA to any other vertex, say AA-CC with weight 33.

Step 2: From the current tree {A,C}\{A, C\}, find the cheapest edge connecting to a vertex not yet in the tree. Say CC-DD with weight 44.

Step 3: Continue. From {A,C,D}\{A, C, D\}, the cheapest external edge might be DD-BB with weight 55.

Step 4: From {A,B,C,D}\{A, B, C, D\}, the cheapest external edge might be BB-EE with weight 66.

Step 5: From {A,B,C,D,E}\{A, B, C, D, E\}, the cheapest external edge might be EE-FF with weight 77.

Final MST: edges AC,CD,DB,BE,EFAC, CD, DB, BE, EF, total weight 3+4+5+6+7=253 + 4 + 5 + 6 + 7 = 25.

Markers reward a clear step-by-step working, the edges in order added, no edges that form cycles, and the final total weight. The exact edges depend on the network in the question.

2023 HSC-style4 marksA water utility wants to connect 55 towns with the minimum total length of pipeline. The possible pipeline routes and lengths (in km) form a weighted graph. Find the minimum spanning tree and its total length.
Show worked answer →

Sort all edges by weight (Kruskal's algorithm). Add them in order from smallest to largest, but skip any edge that would create a cycle.

For 55 towns, the MST has 51=45 - 1 = 4 edges.

Worked example with hypothetical weights: edges sorted AB(8),CD(10),AC(12),BD(15),DE(18),AB(8), CD(10), AC(12), BD(15), DE(18), \ldots.

Add AB(8)AB(8): tree {AB}\{AB\}.

Add CD(10)CD(10): tree {AB,CD}\{AB, CD\}. Disconnected, but no cycle yet.

Add AC(12)AC(12): tree {AB,CD,AC}\{AB, CD, AC\}. Now connects the two components.

Skip BD(15)BD(15) if it would create a cycle in {ABCD}\{ABCD\}. (It does: AA-BB-DD and AA-CC-DD both exist.) Skip.

Add DE(18)DE(18): tree {AB,AC,CD,DE}\{AB, AC, CD, DE\}. All 55 vertices connected.

Total: 8+10+12+18=488 + 10 + 12 + 18 = 48 km.

Markers reward sorting, the cycle-check at each step, and the total weight with units.

Practice questions

Original practice questions graded from foundation to exam level, each with a full worked solution. Try them before revealing the solution.

foundation2 marksThree towns AA, BB and CC can be joined by direct cable along three possible routes with lengths (in km) AB=5AB = 5, BC=8BC = 8 and AC=12AC = 12. Find the minimum spanning tree and state its total length.
Show worked solution →

List the edges. There are three possible cables: AB=5AB = 5, BC=8BC = 8, AC=12AC = 12. With 33 towns the spanning tree needs 31=23 - 1 = 2 edges.

Add the cheapest edges that do not form a cycle (Kruskal's). Sorted by length: AB(5)AB(5), BC(8)BC(8), AC(12)AC(12).

  • Add ABAB (55): the tree is {AB}\{AB\}.
  • Add BCBC (88): this brings in CC, so all three towns are joined.
  • The edge ACAC (1212) would now close the triangle AA-BB-CC, making a cycle, so it is skipped.

State the result. The minimum spanning tree uses ABAB and BCBC.

Total=5+8=13 km.\text{Total} = 5 + 8 = 13 \text{ km}.

Check. Two edges join all 33 towns with no cycle, and 1313 km is cheaper than any tree using the 1212 km route. The MST length is 1313 km.

foundation3 marksA weighted network has four vertices PP, QQ, RR, SS joined in a square by the edges PQ=4PQ = 4, QR=6QR = 6, RS=3RS = 3 and PS=9PS = 9. Use Kruskal's algorithm to find the minimum spanning tree and its total weight.
Show worked solution →

Sort the edges by weight. The four edges in increasing order are RS(3)RS(3), PQ(4)PQ(4), QR(6)QR(6), PS(9)PS(9). A tree on 44 vertices has 41=34 - 1 = 3 edges.

Add edges in order, skipping any that make a cycle (Kruskal's).

  • Add RSRS (33): tree {RS}\{RS\}.
  • Add PQPQ (44): tree {RS,PQ}\{RS, PQ\}, two separate pieces but no cycle.
  • Add QRQR (66): this links the two pieces, so all four vertices are connected.
  • Stop: 33 edges are in, so PSPS (99) is not needed (it would form a cycle).

Total weight.

Total=3+4+6=13.\text{Total} = 3 + 4 + 6 = 13.

Check. Three edges connect all 44 vertices with no cycle. Leaving out the most expensive edge PSPS (99) is what makes the tree minimal, so the MST weight is 1313.

foundation3 marksA network on vertices AA, BB, CC, DD has edges AB=6AB = 6, AC=5AC = 5, AD=7AD = 7, CD=4CD = 4 and BC=9BC = 9. Find a minimum spanning tree and its total weight.
Show worked solution →

Count the edges needed. With 44 vertices the spanning tree has 41=34 - 1 = 3 edges. Sort the five edges: CD(4)CD(4), AC(5)AC(5), AB(6)AB(6), AD(7)AD(7), BC(9)BC(9).

Apply Kruskal's algorithm.

  • Add CDCD (44): tree {CD}\{CD\}.
  • Add ACAC (55): brings in AA, joining it to CC and DD.
  • Add ABAB (66): brings in BB, so all four vertices are connected.
  • The next edge ADAD (77) would close a cycle AA-CC-DD, so skip it; BCBC (99) is also not needed.

Total weight.

Total=4+5+6=15.\text{Total} = 4 + 5 + 6 = 15.

Check. Three edges, all vertices joined, no cycle. The two unused edges (77 and 99) are both heavier than every chosen edge, confirming the tree is minimal. The MST weight is 1515.

foundation4 marksFour water tanks AA, BB, CC, DD can be joined by pipe along any of the six possible routes, with lengths (in metres) AB=7AB = 7, AC=5AC = 5, AD=12AD = 12, BC=9BC = 9, BD=8BD = 8 and CD=6CD = 6. Find the minimum spanning tree and the least total length of pipe needed to connect all four tanks.
Show worked solution →

Set up. Every pair of tanks can be joined, so there are 66 possible pipes. A spanning tree on 44 tanks needs 41=34 - 1 = 3 pipes. Sort by length: AC(5)AC(5), CD(6)CD(6), AB(7)AB(7), BD(8)BD(8), BC(9)BC(9), AD(12)AD(12).

Apply Kruskal's algorithm.

  • Add ACAC (55): tree {AC}\{AC\}.
  • Add CDCD (66): brings in DD.
  • Add ABAB (77): brings in BB, so all four tanks are joined.
  • Stop: 33 pipes are in. The edges BDBD (88), BCBC (99) and ADAD (1212) would each close a cycle, so they are skipped.

Least total length.

Total=5+6+7=18 m.\text{Total} = 5 + 6 + 7 = 18 \text{ m}.

Check. Three pipes connect all four tanks with no loop, and the three cheapest usable pipes were taken. The minimum length of pipe is 1818 m.

core4 marksA network has five vertices with edges AB=3AB = 3, BC=7BC = 7, CD=5CD = 5, DE=4DE = 4, AE=9AE = 9 and BD=6BD = 6. Use Prim's algorithm starting from vertex AA to find the minimum spanning tree. List the edges in the order they are added and give the total weight.
Show worked solution →
Start the tree at AA (Prim's)
The tree begins as {A}\{A\}. At each stage take the cheapest edge from a tree vertex to a vertex not yet included.
Stage 1
Edges leaving AA are ABAB (33) and AEAE (99). Cheapest is ABAB (33); BB joins. Tree {A,B}\{A, B\}.
Stage 2
Crossing edges from {A,B}\{A, B\} are AEAE (99), BCBC (77), BDBD (66). Cheapest is BDBD (66); DD joins. Tree {A,B,D}\{A, B, D\}.
Stage 3
Crossing edges are AEAE (99), BCBC (77), CDCD (55), DEDE (44). Cheapest is DEDE (44); EE joins. Tree {A,B,D,E}\{A, B, D, E\}.
Stage 4
Only CC remains. Crossing edges are BCBC (77) and CDCD (55). Cheaper is CDCD (55); CC joins. All five vertices are now connected.
Result
Edges added in order: ABAB, BDBD, DEDE, CDCD.

Total=3+6+4+5=18.\text{Total} = 3 + 6 + 4 + 5 = 18.

Check. Four edges join all 55 vertices with no cycle. The expensive edge AEAE (99) was never the cheapest crossing edge, so it is left out, confirming the MST weight is 1818.

core4 marksA council plans to lay fibre to five towns AA, BB, CC, DD, EE. The possible cable routes have lengths (in km) AB=8AB = 8, AC=5AC = 5, BC=10BC = 10, BD=9BD = 9, CD=7CD = 7, CE=6CE = 6 and DE=4DE = 4. Using Prim's algorithm starting from town AA, find the minimum spanning tree and the least total length of cable.
Show worked solution →
Begin at AA (Prim's)
Tree {A}\{A\}. Each stage adds the cheapest cable from a connected town to an unconnected town.
Stage 1
From AA: ABAB (88), ACAC (55). Cheapest is ACAC (55); CC joins. Tree {A,C}\{A, C\}.
Stage 2
Crossing cables: ABAB (88), BCBC (1010), CDCD (77), CECE (66). Cheapest is CECE (66); EE joins. Tree {A,C,E}\{A, C, E\}.
Stage 3
Crossing cables: ABAB (88), BCBC (1010), CDCD (77), DEDE (44). Cheapest is DEDE (44); DD joins. Tree {A,C,D,E}\{A, C, D, E\}.
Stage 4
Only BB remains. Crossing cables: ABAB (88), BCBC (1010), BDBD (99). Cheapest is ABAB (88); BB joins.
Result
Cables laid: ACAC, CECE, DEDE, ABAB.

Total=5+6+4+8=23 km.\text{Total} = 5 + 6 + 4 + 8 = 23 \text{ km}.

Check. Four cables connect all 55 towns with no loop. The most expensive route BCBC (1010) is never used. The least total length of cable is 2323 km.

core5 marksSix pumping stations AA, BB, CC, DD, EE, FF are linked by pipes with lengths AB=4AB = 4, AC=6AC = 6, BC=2BC = 2, BD=5BD = 5, CD=8CD = 8, CE=7CE = 7, DE=3DE = 3, DF=9DF = 9 and EF=6EF = 6. Use Kruskal's algorithm to find the minimum spanning tree. Show which edges are added and which are skipped, then state the total length.
Show worked solution →

Sort all pipes by length. BC(2)BC(2), DE(3)DE(3), AB(4)AB(4), BD(5)BD(5), AC(6)AC(6), EF(6)EF(6), CE(7)CE(7), CD(8)CD(8), DF(9)DF(9). A tree on 66 stations needs 61=56 - 1 = 5 pipes.

Apply Kruskal's, checking each edge for a cycle.

  • Add BCBC (22): tree {BC}\{BC\}.
  • Add DEDE (33): tree {BC,DE}\{BC, DE\}.
  • Add ABAB (44): brings in AA.
  • Add BDBD (55): links the {A,B,C}\{A, B, C\} piece to the {D,E}\{D, E\} piece.
  • Skip ACAC (66): both AA and CC are already connected, so this makes a cycle.
  • Add EFEF (66): brings in FF, the last station. Five pipes are now placed.
  • Remaining CECE (77), CDCD (88), DFDF (99) would all make cycles, so skip them.

Total length.

Total=2+3+4+5+6=20.\text{Total} = 2 + 3 + 4 + 5 + 6 = 20.

Check. Five pipes connect all 66 stations with no cycle. Where two edges tied at 66, ACAC made a cycle and EFEF did not, so EFEF was the correct choice. The MST length is 2020.

core5 marksA weighted network on five vertices has edges AB=6AB = 6, AC=9AC = 9, AD=11AD = 11, BC=8BC = 8, BD=9BD = 9, CD=7CD = 7, CE=10CE = 10 and DE=5DE = 5. Find a minimum spanning tree using Kruskal's algorithm and state its total weight.
Show worked solution →

Sort the edges. DE(5)DE(5), AB(6)AB(6), CD(7)CD(7), BC(8)BC(8), AC(9)AC(9), BD(9)BD(9), CE(10)CE(10), AD(11)AD(11). A tree on 55 vertices needs 51=45 - 1 = 4 edges.

Apply Kruskal's algorithm.

  • Add DEDE (55): tree {DE}\{DE\}.
  • Add ABAB (66): tree {DE,AB}\{DE, AB\}, two separate pieces.
  • Add CDCD (77): brings CC in with DD and EE.
  • Add BCBC (88): links the {A,B}\{A, B\} piece to the {C,D,E}\{C, D, E\} piece, so all five vertices are joined.
  • Stop: 44 edges are in. The edges ACAC (99), BDBD (99), CECE (1010) and ADAD (1111) would each form a cycle, so they are skipped.

Total weight.

Total=5+6+7+8=26.\text{Total} = 5 + 6 + 7 + 8 = 26.

Check. Four edges connect all 55 vertices with no cycle, and the algorithm stopped before reaching the tied 99 edges, so neither was needed. The MST weight is 2626.

exam6 marksA telecommunications company will lay cable to connect seven towns AA, BB, CC, DD, EE, FF, GG. The possible routes (in km) are AB=12AB = 12, AC=7AC = 7, BC=9BC = 9, BD=10BD = 10, CD=6CD = 6, CE=8CE = 8, DE=5DE = 5, DF=11DF = 11, EF=4EF = 4, EG=13EG = 13 and FG=9FG = 9. (a) Use Kruskal's algorithm to find a minimum spanning tree, listing the edges added in order. (b) State the least total length of cable. (c) Explain why your answer is the minimum even though two different edges share the weight 99.
Show worked solution →

(a) Sort the routes (Kruskal's). EF(4)EF(4), DE(5)DE(5), CD(6)CD(6), AC(7)AC(7), CE(8)CE(8), BC(9)BC(9), FG(9)FG(9), BD(10)BD(10), DF(11)DF(11), AB(12)AB(12), EG(13)EG(13). A tree on 77 towns needs 71=67 - 1 = 6 cables.

Add the cheapest route each time, skipping any that closes a cycle:

  • Add EFEF (44); add DEDE (55); add CDCD (66); add ACAC (77).
  • Skip CECE (88): CC and EE are already joined, so it makes a cycle.
  • Add BCBC (99): brings in BB.
  • Add FGFG (99): brings in GG, the last town. Six cables are now placed.

Edges added in order: EFEF, DEDE, CDCD, ACAC, BCBC, FGFG.

(b) Least total length.

Total=4+5+6+7+9+9=40 km.\text{Total} = 4 + 5 + 6 + 7 + 9 + 9 = 40 \text{ km}.

(c) Why it is the minimum. The two edges of weight 99, BCBC and FGFG, connect different new towns (BB and GG), so both are needed and neither makes a cycle. There is no tie-break to resolve here, and the heavier routes BDBD (1010), DFDF (1111), ABAB (1212) and EGEG (1313) all close cycles, so the total cannot be reduced.

Check. Six cables join all 77 towns with no loop. The least total length of cable is 4040 km.

exam6 marksA power network connects eight substations AA, BB, CC, DD, EE, FF, GG, HH with lines of length AB=6AB = 6, AC=9AC = 9, BC=4BC = 4, BD=8BD = 8, CD=7CD = 7, CE=12CE = 12, DE=5DE = 5, DF=10DF = 10, EF=3EF = 3, EG=14EG = 14, FG=8FG = 8, FH=11FH = 11 and GH=6GH = 6. (a) Find the minimum spanning tree using Kruskal's algorithm. (b) State the total length. (c) The edges ABAB and GHGH both have weight 66, and BDBD and FGFG both have weight 88. Does the choice between tied edges change the total length? Explain.
Show worked solution →

(a) Sort and apply Kruskal's. EF(3)EF(3), BC(4)BC(4), DE(5)DE(5), AB(6)AB(6), GH(6)GH(6), CD(7)CD(7), BD(8)BD(8), FG(8)FG(8), AC(9)AC(9), DF(10)DF(10), FH(11)FH(11), CE(12)CE(12), EG(14)EG(14). A tree on 88 substations needs 81=78 - 1 = 7 lines.

  • Add EFEF (33); add BCBC (44); add DEDE (55).
  • Add ABAB (66): brings in AA. Add GHGH (66): starts a separate {G,H}\{G, H\} piece.
  • Add CDCD (77): links the {A,B,C}\{A, B, C\} piece to the {D,E,F}\{D, E, F\} piece.
  • Skip BDBD (88): BB and DD are now in the same piece, so it makes a cycle.
  • Add FGFG (88): links in the {G,H}\{G, H\} piece, so all eight substations are joined. Seven lines placed; the rest close cycles and are skipped.

Edges used: EFEF, BCBC, DEDE, ABAB, GHGH, CDCD, FGFG.

(b) Total length.

Total=3+4+5+6+6+7+8=39.\text{Total} = 3 + 4 + 5 + 6 + 6 + 7 + 8 = 39.

(c) Effect of the ties. For the pair ABAB and GHGH (both 66), each joins a different part of the network, so both are needed. For the pair BDBD and FGFG (both 88), BDBD closes a cycle while FGFG does not, so FGFG must be chosen. In every case the total is fixed: the MST total weight is always unique, only the exact edges can differ when a tie genuinely offers two cycle-free choices.

Check. Seven lines connect all 88 substations with no cycle. The total length is 3939.

exam7 marksAn engineer connects six sites AA, BB, CC, DD, EE, FF with cable. The available routes (in km) are AB=7AB = 7, AC=9AC = 9, AF=14AF = 14, BC=10BC = 10, BD=15BD = 15, CD=11CD = 11, CF=2CF = 2, DE=6DE = 6 and EF=9EF = 9. (a) Find the minimum spanning tree and its total length. (b) A contractor proposes instead to use the routes ABAB, BCBC, CFCF, DEDE and EFEF. Show that this is a valid spanning tree, find its total length, and state how much cable the minimum spanning tree saves.
Show worked solution →

(a) Apply Kruskal's algorithm. Sort the routes: CF(2)CF(2), DE(6)DE(6), AB(7)AB(7), AC(9)AC(9), EF(9)EF(9), BC(10)BC(10), CD(11)CD(11), AF(14)AF(14), BD(15)BD(15). A tree on 66 sites needs 61=56 - 1 = 5 cables.

  • Add CFCF (22); add DEDE (66); add ABAB (77).
  • Add ACAC (99): links the {A,B}\{A, B\} piece to the {C,F}\{C, F\} piece.
  • Add EFEF (99): links the {D,E}\{D, E\} piece in, so all six sites are connected. Five cables placed.
  • Skip BCBC (1010), CDCD (1111), AFAF (1414), BDBD (1515): each would close a cycle.

Minimum spanning tree: CFCF, DEDE, ABAB, ACAC, EFEF.

Total=2+6+7+9+9=33 km.\text{Total} = 2 + 6 + 7 + 9 + 9 = 33 \text{ km}.

(b) Test the proposed tree. The proposed routes are ABAB, BCBC, CFCF, DEDE, EFEF. Trace the connections: AA-BB-CC-FF-EE-DD links all six sites in a single chain, using 55 edges with no repeated site, so it is a valid spanning tree (connected, 61=56 - 1 = 5 edges, no cycle).

Proposed=AB+BC+CF+DE+EF=7+10+2+6+9=34 km.\text{Proposed} = AB + BC + CF + DE + EF = 7 + 10 + 2 + 6 + 9 = 34 \text{ km}.

Compare. The proposed tree uses BCBC (1010) where the MST uses the cheaper ACAC (99), so it is 11 km longer.

Saving=3433=1 km.\text{Saving} = 34 - 33 = 1 \text{ km}.

Check. Both networks connect all 66 sites with 55 cables. The MST total is 3333 km, which is 11 km less than the proposed 3434 km, so the minimum spanning tree saves 11 km.

ExamExplained