This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Lecture 13 Graph Algorithms II 13.1 Overview In this lecture we begin with one more algorithm for the shortest path problem, Dijkstra’s algorithm . We then will see how the basic approach of this algorithm can be used to solve other problems including finding maximum bottleneck paths and the minimum spanning tree (MST) problem. We will then expand on the minimum spanning tree problem, giving one more algorithm, Kruskal’s algorithm , which to implement efficiently requires an good data structure for something called the unionfind problem . Topics in this lecture include: • Dijkstra’s algorithm for shortest paths when no edges have negative weight. • The Maximum Bottleneck Path problem. • Minimum Spanning Trees: Prim’s algorithm and Kruskal’s algorithm. 13.2 Shortest paths revisited: Dijkstra’s algorithm Recall the singlesource shortest path problem: given a graph G , and a start node s , we want to find the shortest path from s to all other nodes in G . These shortest paths can all be described by a tree called the shortest path tree from start node s . Definition 13.1 A Shortest Path Tree in G from start node s is a tree (directed outward from s if G is a directed graph) such that the shortest path in G from s to any destination vertex t is the path from s to t in the tree. Why must such a tree exist? The reason is that if the shortest path from s to t goes through some intermediate vertex v , then it must use a shortest path from s to v . Thus, every vertex t negationslash = s can be assigned a “parent”, namely the secondtolast vertex in this path (if there are multiple equally short paths, pick one arbitrarily), creating a tree. In fact, the BellmanFord DynamicProgramming algorithm from the last class was based on this “optimal subproblem” property. The first algorithm for today, Dijkstra’s algorithm , builds the tree outward from s in a greedy fashion. Dijkstra’s algorithm is faster than BellmanFord. However, it requires that all edge 72 13.2. SHORTEST PATHS REVISITED: DIJKSTRA’S ALGORITHM 73 lengths be nonnegative. See if you can figure out where the proof of correctness of this algorithm requires nonnegativity. We will describe the algorithm the way one views it conceptually, rather than the way one would code it up (we will discuss that after proving correctness). Dijkstra’s Algorithm: Input: Graph G , with each edge e having a length len ( e ), and a start node s . Initialize: tree = { s } , no edges. Label s as having distance 0 to itself. Invariant: nodes in the tree are labeled with the correct distance to s . Repeat: 1. For each neighbor x of the tree, compute an (over)estimate of its distance to s : distance( x ) = min e =( v,x ): v ∈ tree [distance( v ) + len ( e )] (13.1) In other words, by our invariant, this is the length of the shortest path to x whose only edge not in the tree is the very last edge....
View
Full Document
 Spring '10
 JoeWhite
 Algorithms, Graph Theory, Shortest path problem, Dijkstra

Click to edit the document details