Single-Source Shortest Paths

Slides:



Advertisements
Similar presentations
More Graph Algorithms Minimum Spanning Trees, Shortest Path Algorithms.
Advertisements

Tirgul 12 Algorithm for Single-Source-Shortest-Paths (s-s-s-p) Problem Application of s-s-s-p for Solving a System of Difference Constraints.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 15 Shortest paths algorithms Properties of shortest paths Bellman-Ford algorithm.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
CSE 780 Algorithms Advanced Algorithms SSSP Dijkstra’s algorithm SSSP in DAGs.
Tirgul 13. Unweighted Graphs Wishful Thinking – you decide to go to work on your sun-tan in ‘ Hatzuk ’ beach in Tel-Aviv. Therefore, you take your swimming.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Dijkstra's algorithm.
Shortest Path Algorithms. Kruskal’s Algorithm We construct a set of edges A satisfying the following invariant:  A is a subset of some MST We start with.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
COSC 2007 Data Structures II Chapter 14 Graphs III.
Minimum Spanning Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
CSE 2331 / 5331 Topic 12: Shortest Path Basics Dijkstra Algorithm Relaxation Bellman-Ford Alg.
Shortest Path Algorithms. Definitions Variants  Single-source shortest-paths problem: Given a graph, finding a shortest path from a given source.
Shortest Paths CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Data Structures & Algorithms Shortest Paths Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Graphs Upon completion you will be able to:
Single Source Shortest Paths Chapter 24 CSc 4520/6520 Fall 2013 Slides adapted from George Bebis, University of Reno, Nevada.
Minimum Spanning Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos and Alexandra Stefan University of Texas at Arlington These slides are.
Minimum Spanning Trees
Minimum Spanning Trees
Data Structures and Algorithms I Day 19, 11/3/11 Edge-Weighted Graphs
Shortest Paths and Minimum Spanning Trees
Minimum Spanning Tree Chapter 13.6.
Minimum Spanning Trees
C.Eng 213 Data Structures Graphs Fall Section 3.
Minimum Spanning Tree Shortest Paths
Introduction to Graphs
Minimum Spanning Trees
Short paths and spanning trees
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Minimum Spanning Tree Neil Tang 3/25/2010
Greedy Algorithms / Dijkstra’s Algorithm Yin Tat Lee
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
SINGLE-SOURCE SHORTEST PATHS
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Minimum-Cost Spanning Tree
Minimum-Cost Spanning Tree
Minimum Spanning Trees
Advanced Algorithms Analysis and Design
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Autumn 2015 Lecture 10 Minimum Spanning Trees
Dijkstra Algorithm.
Shortest Paths and Minimum Spanning Trees
Lecture 13 Algorithm Analysis
Minimum Spanning Tree Neil Tang 4/3/2008
Lecture 13 Algorithm Analysis
Shortest Path Problems
Minimum Spanning Tree.
Algorithms Searching in a Graph.
Single-Source Shortest Paths
Weighted Graphs & Shortest Paths
Autumn 2016 Lecture 10 Minimum Spanning Trees
Dijkstra’s Shortest Path Algorithm
Graph Algorithms: Shortest Path
CSE 417: Algorithms and Computational Complexity
Advanced Algorithms Analysis and Design
Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008
Winter 2019 Lecture 10 Minimum Spanning Trees
Single-Source Shortest Path & Minimum Spanning Trees
Chapter 9 Graph algorithms
Minimum-Cost Spanning Tree
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

Single-Source Shortest Paths CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington

Terminology A network is a directed graph. We will use both terms interchangeably. The weight of a path is the sum of weights of the edges that make up the path. The shortest path between two vertices s and t in a directed graph is a directed path from s to t with the property that no other such path has a lower weight.

Shortest Paths We will consider two problems: Assumptions: Single-source: find the shortest path from the source vertex s to all other vertices in the graph. It turns out that these shortest paths form a tree, with s as the root. All-pairs: find the shortest paths for all pairs of vertices in the graph. Assumptions: Directed graphs Edges cannot have non-negative weights.

Assumptions Allow directed graphs. In all our shortest path algorithms, we will allow graphs to be directed. Obviously, any algorithm that works on directed graphs will also work on undirected graphs. Why? Negative edge weights are not allowed. Why?

Assumptions Negative edge weights are not allowed. Why? Obviously, any algorithm that works on directed graphs will also work on undirected graphs. Why? Undirected graphs are a special case of directed graphs. Negative edge weights are not allowed. Why? With negative weights, "shortest paths" may not be defined. If a cycle has negative weight, then repeating that cycle infinitely on a path make it "shorter" and "shorter" Note that the weight of the whole path needs to be negative (not just an edge) for this to happen. If all weights are nonnegative, a shortest path never needs to include a cycle.

Shortest-Paths Spanning Tree Given a network G and a designated vertex s, a shortest-paths spanning tree (SPST) for s is a tree that contains s and all vertices reachable from s, such that: Vertex s is the root of this tree. Each tree path is a shortest path in G.

Dijkstra’s Algorithm Total distance from s to v (through u). For each vertex, v, record the shortest distance from s to it and the edge that connects it (like Prim). Add the vertex with the shortest distance.

Dijkstra’s Algorithm: Runtime Total distance from s to v (through u). Time complexity: O(E lg V) O(V) O(VlgV + ElgV) = O(ElgV) (if all vertices are reachable from s) O(V) O(lgV) => O(VlgV) O(E) (together with the while loop) O(ElgV) (aggregate from both for loop and while loop), (RELAX has an implicit Decrease-Key operation of O(lgV). )

Dijkstra's Algorithm Computes an SPST for a graph G and a source s. Very similar to Prim's algorithm, but: First vertex to add is the source, s. Works with directed graphs as well, whereas Prim's only works with undirected graphs. Requires edge weights to be non-negative. It looks at the total path weight, not just the weight of the current edge. Time complexity: O(E lg V) using a heap for the priority-queue.

Dijkstra’s Algorithm 6 2 1 7 3 5 4 Find the SPST(G,5). 20 4 20 30 10 9 Show the distance and the parent for each vertex. 1 7 2 5 3 4 6 20 4 20 30 10 18 15 9 11 30 15 25 5 12

Dijkstra’s Algorithm 1 7 2 5 3 4 6 20 4 20 30 10 18 15 9 11 30 15 25 5 12

All-Pairs Shortest Paths Run Dijkstra to compute the Shortest Path Spanning Tree for each vertex used as source. Trick to get the successor (rather than the predecessor/parent) on a path: reverse direction of arrows, solve problem in reversed graph. That solution gives the predecessor in the reversed graph which correspond to successors in the original graph.