This week we wrote the script for Prim’s Algorithm and applied it to the interface we created last week.

Below are screenshots that display the action of the buttons:

1. Draw points:

2.Draw lines:

The length δ of a longest edge in a MST (S) is the minimum d for which Gd (S) is connected. Since we want G1 (S) to be connected, we scale the weights of all edges by a factor of 1 , so that the longest edge in MST (S) has unit length. Then G1 (S) is simply the graph that contains all edges of weight no greater than 1 (after scaling).

3. Draw Prim’s Algorithm

For a ﬁxed real value d ≥ 1, Gd (S) is the graph that contains all edges of weight no greater than d (again, after scaling).