Next: Maximum Flow
Up: A Tutorial on Network
Previous: Shortest Paths
This problem has a number of important practical applications. For example, it can sometimes be helpful in planning transportation networks that will not be used much. There, the primary consideration is to provide some link between all pairs of nodes in the most economical way. Other examples include the planning of large-scale communication models and distribution networks.
The minimum spanning tree problem can be solved in a very straightforward way because it is one of the few problems where being greedy at each stage of a solution procedure still results in an optimal solution at the end! The algorithm is as follows:
Greedy algorithm
denote the tree found by the greedy algorithm and suppose some other tree
is shorter. We will show that this leads to a contradiction. Among the
trees which are shorter than the greedy solution
,
denote by T one which has the largest number of common edges with
.
Let a be a shortest edge in
but not in T and let C be the unique cycle formed when edge
a is added to the edges of T. The cycle C contains
at least one edge not in
,
say b, since
contains
no cycle. The length of a is less than or equal to that of b,
since edge a must have been considered before b by the greedy
algorithm. Now the tree
obtained from T by adding edge a and removing edge b
is of the same length as or shorter than T. Therefore
is shorter than
. But it
has one more edge in common with
,
a contradiction. This completes the proof.
Here's a different algorithm for finding a minimum spanning tree: