Prim’s algorithm and the cut rule
Grow a minimum spanning tree with Prim's algorithm. At every step, select the cheapest edge joining the current tree to a new vertex.
Concepts for §10.6
Before you begin
Trees
A tree is a nonempty undirected graph that is connected and has no cycle. It has exactly one simple path between any two vertices, so deleting any edge disconnects it. A finite tree with n vertices has edges.
Weight and distance
An edge weight is the numerical cost of that edge. A route’s cost is the sum of traversed edge weights. A spanning tree’s total weight sums its selected edges. These are different objectives. Here marks a distance for which no route has yet been found.
Definitions and notation for this topic
Spanning tree
A spanning tree of a connected undirected graph uses every vertex of G and a subset of its edges, while remaining connected and without circuits.
A finite spanning tree has edges. A minimum spanning tree minimizes total edge weight among spanning trees; it need not minimize the route from one fixed source to every vertex.
Separate glossary example
In a triangle with edges AB, BC, AC, selecting AB and BC gives a spanning tree of total weight 5.
Weights, distance estimates and infinity
; ; ;is the weight of a named edge; in a simple graph this may be written . sums a tree’s edge weights. During a shortest-path algorithm may denote a tentative distance, and means no finite route has been found yet.
A tentative estimate is not automatically the final shortest distance. Dijkstra’s algorithm requires nonnegative edge weights. is an extended sentinel here, not an ordinary real weight.
Separate glossary example
If and an edge e from u to v has weight 3, relaxation proposes :=min. An old estimate becomes 7.
Worked example
The connected undirected graph has vertices A,B,C,D,E and weighted edges AB, AC, AD, BC, BD, CE, DE, BE, CD. Start Prim's algorithm at A. Give the selected edges in order and the total weight.
Your task
Use Prim's algorithm from P on the graph with vertices P,Q,R,S,T and edges PQ, PR, QR, QS, RS, RT, ST, QT, PT. Write the selected edge order, the total weight, and the visited vertex set after each step. Explain why ST cannot be chosen immediately after the first two selections.
Saved in this browser; not automatically graded.
Review your written reasoning
- I recorded the changing vertex set, not just a sorted list of all weights.
- Every chosen edge had exactly one endpoint inside that set at the time of selection.
- I compared all eligible edges, including those leaving older vertices.
- I explained the ST decision and obtained four edges, five vertices, and total 11.