Prim_Algorithm - Lecture 13 Graph Algorithms II 13.1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 union-find 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 single-source 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 second-to-last vertex in this path (if there are multiple equally- short paths, pick one arbitrarily), creating a tree. In fact, the Bellman-Ford Dynamic-Programming 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 Bellman-Ford. However, it requires that all edge 72 13.2. SHORTEST PATHS REVISITED: DIJKSTRA’S ALGORITHM 73 lengths be non-negative. See if you can figure out where the proof of correctness of this algorithm requires non-negativity. 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

This note was uploaded on 06/05/2010 for the course COMPUTER S 700 taught by Professor Joewhite during the Spring '10 term at Universidad San Martín de Porres.

Page1 / 6

Prim_Algorithm - Lecture 13 Graph Algorithms II 13.1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online