Let’s see what Kruskal’s algorithm does on the weighted graph in
Figure 12.1. It first sorts all of the edges by weight. We won’t reproduce the list here, since we won’t need all of it. The edge of least weight is
\(ck\text{,}\) which has weight
\(23\text{.}\) It continues adding the edge of least weight, adding
\(ag\text{,}\) \(fg\text{,}\) \(fi\text{,}\) \(fj\text{,}\) and
\(bj\text{.}\) However, after doing this, the edge of lowest weight is
\(fb\text{,}\) which has weight
\(38\text{.}\) This edge cannot be added, as doing so would make
\(fjb\) a cycle. Thus, the algorithm bypasses it and adds
\(bc\text{.}\) Edge
\(ai\) is next inspected, but it, too, would create a cycle and is eliminated from consideration. Then
\(em\) is added, followed by
\(dl\text{.}\) There are now
two edges of weight
\(56\) to be considered:
\(al\) and
\(dj\text{.}\) Our sorting algorithm has somehow decided one of them should appear first, so let’s say it’s
\(dj\text{.}\) After adding
\(dj\text{,}\) we cannot add
\(al\text{,}\) as
\(agfjdl\) would form a cycle. Edge
\(dk\) is next considered, but it would also form a cycle. However,
\(ek\) can be added. Edges
\(km\) and
\(dm\) are then bypassed. Finally, edge
\(ch\) is added as the twelfth and final edge for this
\(13\)-vertex spanning tree. The full list of edges added (in order) is shown to the right. The total weight of this spanning tree is
\(504\text{.}\)