Overview
In this chapter we discuss two fundamental problems for (real) weighted graphs and
digraphs—the minimum spanning tree problem and the shortest path problem. We begin
by discussing Kruskal’s algorithm, which is based on the Greedy method, and involves
growing forests. We then discuss another classical minimum spanning tree algorithm,
Prim’s algorithm, which is also based on the greedy method, but involves growing a
spanning tree from a root vertex.
In the second part of this chapter we discuss three shortest path algorithms. We first
discuss the Bellman-Ford algorithm for computing shortest paths from a given root vertex
to other vertices, or determining the existence of a negative cycle. We then discuss
Dijkstra’s shortest path algorithm, which is based on a Greedy strategy similar to Prim’s.
Dijkstra’s algorithm is more efficient then the Bellman-Ford algorithm, but requires the
precondition that all edge weights are positive. Finally, we discuss Floyd’s algorithm for
computing all-pairs shortest paths, which is based on a dynamic programming strategy
that uses the principle of optimization.
Chapter Objectives
After completing the chapter the student will know:
• The design and analysis of Kruskals’ algorithm using the greedy method
• Efficient implementation of Kruskal’s algorithm using disjoint sets and union and
find algorithms
• The design and analysis of Prim’s algorithm using the greedy method
• The comparison of the computing times of Kruskal’s and Prim’s and for what
input graphs one would be more efficient than the other
• The ad hoc strategy used in the design of the Bellman-Ford algorithm and its
analysis
• The greedy strategy used in the design of Dijkstra’s algorithm and its analysis