Simple Implementation

All the work done in CONNECTED. Can use depth-first-search to test connectivity. Basically, if we start at u and can reach v, they are connected. If not, not.

That gives us: tex2html_wrap_inline209 for the inner loop. This dominates that tex2html_wrap_inline211 for sorting the edges.

Explanation: for each edge that we consider adding, we do a depth-first search over edges to see if the endpoints are already connected.


next up previous
Next: Better Implementation Up: KRUSKAL'S ALGORITHM Previous: Implementation