Skip to content
← All questions

How do you compute the total weight of the MST after running Prim's algorithm?

To compute the total weight of the MST, sum the weights of all edges that were selected and added to the tree during the execution of Prim's algorithm.

Conditions

  • The MST edge set has been fully determined.
  • You have access to the weights of the selected edges.

Reasoning, step by step

  1. Identify all edges included in the final MST.
  2. Retrieve the weight of each selected edge.
  3. Add these weights together to get the total edge weight.

Example

The board shows the calculation: "Total Edge Weight = 2+3+3+1+6+9=242 + 3 + 3 + 1 + 6 + 9 = 24". The narrator says, "You can add the edge weights to get the minimum spanning tree's total edge weight."

Common misconceptions

  • Summing the weights of all edges in the original graph.
  • Including edges that were considered but rejected (e.g., internal edges).
  • Forgetting to include the weight of the last added edge.

Watch the explanation

Connected concepts

Explore next

Related questions

Meet the concept

↗
Meet the concept

↗
Understand why

↗

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.