A faster algorithm for the single source shortest path problem with few distinct positive lengths

Similar documents
Design and Analysis of Algorithms

CS 4407 Algorithms Lecture: Shortest Path Algorithms

Single Source Shortest Paths

Single Source Shortest Paths

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro.

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

Design and Analysis of Algorithms

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees

Shortest Path Algorithms

CS 253: Algorithms. Chapter 24. Shortest Paths. Credit: Dr. George Bebis

6.889 Lecture 4: Single-Source Shortest Paths

Introduction to Algorithms

Introduction to Algorithms

Algorithm Design and Analysis

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Introduction to Algorithms

Introduction to Algorithms

Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Shortest Paths. CS 320, Fall Dr. Geri Georg, Instructor 320 ShortestPaths 3

ne a priority queue for the nodes of G; ile (! PQ.is empty( )) select u PQ with d(u) minimal and remove it; I Informatik 1 Kurt Mehlhorn

INVERSE SPANNING TREE PROBLEMS: FORMULATIONS AND ALGORITHMS

Discrete Optimization 2010 Lecture 3 Maximum Flows

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn

CS781 Lecture 3 January 27, 2011

Internet Routing Example

CPSC 320 (Intermediate Algorithm Design and Analysis). Summer Instructor: Dr. Lior Malka Final Examination, July 24th, 2009

A FAST MAX FLOW ALGORITHM

Lecture 11. Single-Source Shortest Paths All-Pairs Shortest Paths

CS 161: Design and Analysis of Algorithms

Contents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression

Breadth-First Search of Graphs

BFS Dijkstra. Oct abhi shelat

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

1 Introduction A priority queue is a data structure that maintains a set of elements and supports operations insert, decrease-key, and extract-min. Pr

Lecture 7: Shortest Paths in Graphs with Negative Arc Lengths. Reading: AM&O Chapter 5

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Algorithms: Lecture 12. Chalmers University of Technology

FIBONACCI HEAPS. preliminaries insert extract the minimum decrease key bounding the rank meld and delete. Copyright 2013 Kevin Wayne

On the Exponent of the All Pairs Shortest Path Problem

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

Algorithm Design and Analysis

15.082J and 6.855J and ESD.78J October 21, Max Flows 4

Algorithms Booklet. 1 Graph Searching. 1.1 Breadth First Search

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures

Lecture Notes for Chapter 25: All-Pairs Shortest Paths

Examination paper for TDT4120 Algorithms and Data Structures

Shortest Paths in Directed Planar Graphs with Negative Lengths: a Linear-Space O(n log 2 n)-time Algorithm

arxiv: v2 [cs.ds] 15 Jul 2016

Shortest paths: label setting

25. Minimum Spanning Trees

COMP251: Bipartite graphs

25. Minimum Spanning Trees

All-Pairs Shortest Paths

CS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT UNIT V GRAPHS

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

CS 580: Algorithm Design and Analysis

Shortest paths with negative lengths

Lecture 3. 1 Polynomial-time algorithms for the maximum flow problem

Another way of saying this is that amortized analysis guarantees the average case performance of each operation in the worst case.

A greedy, graph-based algorithm for the alignment of multiple homologous gene lists

Myriad of applications

arxiv: v1 [cs.ds] 23 Feb 2016

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.

CS 5321: Advanced Algorithms Amortized Analysis of Data Structures. Motivations. Motivation cont d

Part V. Matchings. Matching. 19 Augmenting Paths for Matchings. 18 Bipartite Matching via Flows

Committee Selection with a Weight Constraint Based on Lexicographic Rankings of Individuals

MA015: Graph Algorithms

A Faster Strongly Polynomial Time Algorithm for Submodular Function Minimization

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

CS 410/584, Algorithm Design & Analysis, Lecture Notes 4

Cache-Oblivious Computations: Algorithms and Experimental Evaluation

CS60007 Algorithm Design and Analysis 2018 Assignment 1

Directed Graphs (Digraphs) and Graphs

Data Structures and and Algorithm Xiaoqing Zheng

CS 161: Design and Analysis of Algorithms

Priority queues implemented via heaps

COMP251: Bipartite graphs

Maintaining Consistency of Dynamic Cardinality Constraints with Costs

iretilp : An efficient incremental algorithm for min-period retiming under general delay model

Query Processing in Spatial Network Databases

Incremental Path Planning

Ngày 20 tháng 7 năm Discrete Optimization Graphs

Lecture 21 November 11, 2014

CS 138b Computer Algorithm Homework #14. Ling Li, February 23, Construct the level graph

Divide-and-Conquer Algorithms Part Two

CSCI Honor seminar in algorithms Homework 2 Solution

A walk over the shortest path: Dijkstra s Algorithm viewed as fixed-point computation

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2006

Optimal Color Range Reporting in One Dimension

Fundamental Algorithms 11

Computational Geometry

Transcription:

A faster algorithm for the single source shortest path problem with few distinct positive lengths J. B. Orlin, K. Madduri, K. Subramani, and M. Williamson Journal of Discrete Algorithms 8 (2010) 189 198. Speaker: Joseph, Chuang-Chieh Lin Supervisor: Professor Maw-Shang Chang Computation Theory Laboratory Department of Computer Science and Information Engineering National Chung Cheng University, Taiwan January 31, 2010 1/30

Outline 1 Introduction 2 Basic terminology 3 Reviewing Dijkstra s algorithm for SSSPP 4 An O(m + nk) implementation of Dijkstra s algorithm 5 A faster algorithm if K is permitted to grow with the problem size 2/30

Outline 1 Introduction 2 Basic terminology 3 Reviewing Dijkstra s algorithm for SSSPP 4 An O(m + nk) implementation of Dijkstra s algorithm 5 A faster algorithm if K is permitted to grow with the problem size 3/30

Introduction The single source shortest path problem (SSSPP) Given a graph G = (V,E) and s V designated as the source, where each edge (u, v) E has a positive length c uv, determine the shortest path from s to each v V in G. Assume that V = n and E = m. 4/30

Previous results O(m + n log n) time by Fibonacci Heap implementation. Fredman and Tarjan (1987); J. ACM. O(m + n log n log log n ) time by the Atomic Heap implementation (in a slightly different model of computation). Fredman and Willard (1994); J. Comput. Sys. Sci. 5/30

The contributions of this paper Input: a graph G = (V,E) with V = n, E = m, and K distinct edge lengths. Efficient methods for implementing Dijkstra s algorithm for SSSPP parameterized by K. An O(m + nk) algorithm (O(m) if nk 2m); An O(m log nk m ) algorithm for the case that nk > 2m. Experimental results. Demonstration of the superiority of their approach when K is small (except for dense graphs). 6/30

Motivation The gossip problem for social networks. For example, consider a social network composed of clusters of participants. We model the intra-cluster distance by 1 and the inter-cluster distance by p > 1. Goal: determine a faster manner where gossip originating in a cluster can reach all the participants in the social network. 7/30

Outline 1 Introduction 2 Basic terminology 3 Reviewing Dijkstra s algorithm for SSSPP 4 An O(m + nk) implementation of Dijkstra s algorithm 5 A faster algorithm if K is permitted to grow with the problem size 8/30

Preliminaries & notations : empty set; : nothing. E out (v): the set of edges directed out of v. δ(v): the length of the shortest path in G from s to v. δ(v) = if there is no path from s to v. 9/30

Preliminaries & notations (contd.) L = {l 1, l 2,...,l K }: the set of distinct nonnegative edge lengths in increasing order (stored in an array). (i,j) E, (i,j) has an edge length c ij L. Assumption: (i, j) t ij. c ij = l tij (i.e., t : E {1,2,...,K}). This can be done in O(m + K log K) time. 10/30

Outline 1 Introduction 2 Basic terminology 3 Reviewing Dijkstra s algorithm for SSSPP 4 An O(m + nk) implementation of Dijkstra s algorithm 5 A faster algorithm if K is permitted to grow with the problem size 11/30

Dijkstra s algorithm for SSSPP Dijkstra(G, w, s) 1: for each v V(G) do 2: d[v] ; pred[v] ; 3: end for 4: d[s] 0; 5: Q V(G); S ; 6: while (Q ) do 7: u argmin{d[v] : v Q} 8: if d[u] = then 9: break; 10: end if 11: remove u from Q; S S {u}; 12: for each v Adj[u] do 13: temp d[u] + c uv; 14: if temp < d[v] then 15: d[v] temp; 16: pred[v] u; 17: end if 18: end for 19: end while 12/30

Dijkstra s algorithm for SSSPP (modularized) RELAX(u, v, c) 1: temp d[u] + c uv; 2: if temp < d[v] then 3: d[v] temp; 4: pred[v] u; 5: end if INITIALIZE(G, s) 1: for each v V(G) do 2: d[v] ; 3: pred[v] ; 4: end for 5: d[s] 0; Dijkstra(G, c,s) 1: INITIALIZE(G, s); 2: S ; 3: Q V(G); 4: while (Q ) do 5: u EXTRACT-MIN(Q); 6: if d[u] = then 7: break; 8: end if 9: S S {u}; 10: for each v Adj[u] do 11: RELAX(u, v, c); 12: end for 13: end while 13/30

Improvements by implementing priority queues A series of EXTRACT-MIN() and DECREASE-KEY() is performed in Dijkstra s algorithm. The running time of Dijkstra s algorithm can be represented as T(n, m) = n EXTRACT-MIN() + m DECREASE-KEY(). EXTRACT MIN() DECREASE-KEY() linked list: O(1) O(n) binary heap: O(log n) O(log n) Fibonacci Heap: O(log n) (amortized) O(1) (amortized) 14/30

Outline 1 Introduction 2 Basic terminology 3 Reviewing Dijkstra s algorithm for SSSPP 4 An O(m + nk) implementation of Dijkstra s algorithm 5 A faster algorithm if K is permitted to grow with the problem size 15/30

Further notations We maintain the following structures: S: the set of permanently labeled vertices; T = V \ S: the set of temporarily labeled vertices. d(j): the distance label of vertex j. If j S, then d(j) = δ(j). d = max{d(j) : j S}: the distance label of the vertex most recently added to S. FIND-MIN(): identifying min{d(v) : v T }. EXTRACT-MIN() = FIND-MIN()+ Deletion of argmin{d(v) : v T } from T. 16/30

Further notations (contd.) Recall that L = {l 1, l 2,...,l K }: the set of K distinct edge lengths. For each 1 t K, E t (S) = {(i, j) E : i S, c ij = l t }. If (i,j) occurs prior to edge (i,j ) on E t (S), then d(i) d(i ). CurrentEdge(t): the first edge (i, j) E t (S) such that j T. CurrentEdge(t) = if no such edge exists. If CurrentEdge(t) = (i,j), then let f (t) = d(i) + l t. f (t): the length of the shortest path from s to i followed by edge (i, j). Note here that NOT NECESSARY that f (t) = d(j). 17/30

Further notations (contd.) UPDATE(t): moving the pointer CurrentEdge(t) so that it points to the first edge whose endpoint is in T (or set CurrentEdge(t) = ). If CurrentEdge(t) = (i,j), then UPDATE(t) sets f (t) = d(i) + c ij. If CurrentEdge(t) =, then UPDATE(t) sets f (t) =. 18/30

An O(m + nk) implementation of Dijkstra s algorithm NEW-DIJKSTRA() 1: INITIALIZE(); 2: while (T ) do 3: r argmin{f (t) : 1 t K}; 4: (i, j) CurrentEdge(r); 5: d(j) d(i) + l r; pred(j) i; 6: S S {j}; T T \ {j}; 7: for (each edge (j, k) E out(j)) do 8: Add (j, k) to the end of E t(s), where l t = c jk ; 9: if (CurrentEdge(t) = ) then 10: CurrentEdge(t) (j, k); 11: end if 12: end for 13: for (t 1 to K) do 14: UPDATE(t); 15: end for 16: end while 19/30

An O(m + nk) implementation of Dijkstra s algorithm INITIALIZE() 1: S {s}; T V \ {s}; 2: d(s) 0; pred(s) ; 3: for (each v T) do 4: d(v) ; pred(v) ; 5: end for 6: for t 1 to K do 7: E t(s) ; 8: CurrentEdge(t) ; 9: end for 10: for each edge (s, j) do 11: Add (s, j) to the end of E t(s), where l t = c sj ; 12: if (CurrentEdge(t) = ) then 13: CurrentEdge(t) (s, j); 14: end if 15: end for 16: for (t 1 to K) do 17: UPDATE(t); 18: end for UPDATE(t) 1: (i, j) CurrentEdge(t); 2: if (j T) then 3: f (t) d(i) + c ij ; 4: return; 5: end if 6: while ((j / T) and (CurrentEdge(t).next )) do 7: (i, j) CurrentEdge(t).next; 8: CurrentEdge(t) (i, j); 9: end while 10: if (j T) then 11: f (t) d(i) + c ij ; 12: else 13: CurrentEdge(t) ; 14: f (t) ; 15: end if 20/30

Time complexity Initialization: O(n) Computing r = argmin{f (t) : 1 t K} over all iterations: O(nK). Total time needed for UPDATE(t): O(m + nk). Suppose that (i, j) CurrentEdge(t). O(nK) if CurrentEdge(t).next is never used. Otherwise, O(m). (i, j) is never scanned again after updating CurrentEdge(t). 21/30

Outline 1 Introduction 2 Basic terminology 3 Reviewing Dijkstra s algorithm for SSSPP 4 An O(m + nk) implementation of Dijkstra s algorithm 5 A faster algorithm if K is permitted to grow with the problem size 22/30

When K is not a constant... Let q = nk m. If q < 2, previous algorithm runs in O(m) time. Assume that q 2. To simplify the discussion, let h = K q. Goal: compute r = argmin{f (t) : 1 t K} more efficiently and call UPDATE(t) less frequently. 23/30

Revision of the previous algorithm Store the values f () in a collection of h different binary heaps H 1, H 2,...,H h. H 1 stores f (j) for 1 j q; H 2 stores f (j) for q + 1 j 2q;. FIND-MIN() in H i : O(1) time. FIND-MIN() takes O(hn) = O(m) time overall. Insert/Delete an element into H i : O(log q) time. Deletions after FIND-MIN() takes O(n log q) time overall. 24/30

Revision of the previous algorithm (contd.) Relax the requirement on CurrentEdge. If (i, j) CurrentEdge(t) we obtain that i, j S: We say that CurrentEdge(t) is invalid. CurrentEdge(t) is permitted to be invalid at some intermediate stages of the algorithm. 25/30

Revision of the previous algorithm (contd.) We modify FIND-MIN() as follows. If the minimum element in heap H i is f (t) for some i and if CurrentEdge(t) is invalid, perform UPDATE(), followed by: Finding the new minimum element in H i until it corresponds to a valid edge. Whenever the algorithm calls UPDATE(), it leads to such a modification of CurrentEdge(). Whenever the algorithm selects the minimum element among the q heaps, the minimum element in each heap corresponds to a valid edge. Since there are m modifications of CurrentEdge(), the total running time for UPDATE() overall is O(m log q). 26/30

Theorem 5.1 The ( binary ) heap implementation of Dijkstra s algorithm with O K q binary heaps of size O(q) with q = nk m determines the shortest path from s to all other vertices in O(m log q) time. 27/30

Interested audience may refer to Chapter 7 of the paper for experimental results. 28/30

My daughter, Sherry 29/30

Thank you! 30/30