Evaluation of the Course (Modified)

Slides:



Advertisements
Similar presentations
 Theorem 5.9: Let G be a simple graph with n vertices, where n>2. G has a Hamilton circuit if for any two vertices u and v of G that are not adjacent,
Advertisements

1 Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Single Source Shortest Paths
2015/4/11CS4335 Design and Analysis of Algorithms /Shuai Cheng Li Page 1 Evaluation of the Course (Modified) Course work:30% –Four assignments (25%) 7.5.
October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
CS138A Single Source Shortest Paths Peter Schröder.
chapter Single-Source Shortest Paths Problem Definition Shortest paths and Relaxation Dijkstra’s algorithm (can be viewed as a greedy algorithm)
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
DYNAMIC PROGRAMMING. 2 Algorithmic Paradigms Greedy. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
Shortest Path Problems
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
1 8-ShortestPaths Shortest Paths in a Graph Fundamental Algorithms.
Shortest Paths Definitions Single Source Algorithms
DAST 2005 Tirgul 12 (and more) sample questions. DAST 2005 Q.We’ve seen that solving the shortest paths problem requires O(VE) time using the Belman-Ford.
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 22.
Algorithm Course Dr. Aref Rashad February Algorithms Course..... Dr. Aref Rashad Part: 6 Shortest Path Algorithms.
10/4/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 17 Dynamic.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 17.
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
CS38 Introduction to Algorithms Lecture 10 May 1, 2014.
Single Source Shortest Paths Chapter 24 CSc 4520/6520 Fall 2013 Slides adapted from George Bebis, University of Reno, Nevada.
TIRGUL 10 Dijkstra’s algorithm Bellman-Ford Algorithm 1.
Tirgul 12 Solving T4 Q. 3,4 Rehearsal about MST and Union-Find
Data Structure Lecture 10 Thursday, 28 Aug 2005.
Shortest Paths and Minimum Spanning Trees
Single-Source Shortest Path
Chapter 7: Greedy Algorithms
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Algorithms and Data Structures Lecture XIII
CS330 Discussion 6.
Challenging Problem 2: Challenging problem 2 will be given on the website (week 4) at 9:30 am on Saturday (Oct 1, 2005). 2. The due time is Sunday (Oct.
Shortest Paths with Dynamic Programming
Chapter 6 Dynamic Programming
Shortest Paths C B A E D F Shortest Paths
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Announcement 2: A 2 hour midterm (open book) will be given on March (Tuesday) during the lecture time. 2018/12/4.
Page 620 Single-Source Shortest Paths
Chapter 6 Dynamic Programming
Basic Graph Algorithms
2018/12/27 chapter25.
Advanced Algorithms Analysis and Design
2-optimal Euler path problem Euler circuit in a directed graph:
Algorithms and Data Structures Lecture XIII
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Chapter 6 Dynamic Programming
Shortest Path Algorithms
Dynamic Programming Longest Path in a DAG, Yin Tat Lee
Lecture 13 Algorithm Analysis
Fundamental Data Structures and Algorithms
2019/2/25 chapter25.
Shortest Path Problems
Algorithms (2IL15) – Lecture 7
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
The Bellman-Ford Shortest Path Algorithm Neil Tang 03/27/2008
Chapter 24: Single-Source Shortest Paths
Chapter 24: Single-Source Shortest Paths
CSE 417: Algorithms and Computational Complexity
Negative-Weight edges:
Negative-Weight edges:
Richard Anderson Lecture 20 Shortest Paths and Network Flow
Chapter 24: Single-Source Shortest-Path
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Topological Sorting Minimum Spanning Trees Shortest Path
Advanced Algorithms Analysis and Design
Data Structures and Algorithm Analysis Lecture 8
Presentation transcript:

Evaluation of the Course (Modified) Course work: 30% Four assignments (25%) 7.5 5 points for each of the first two three assignments 10 points for the last assignment One term paper (5%) (week13 Friday) Find an open problem from internet. State the problem definition in English. Write the definition mathematically. Summarize the current status No more than 1 page A final exam: 70% 2019/4/11 CS4335 Design and Analysis of Algorithms /Shuai Cheng Li

Single source shortest path with negative cost edges 2019/4/11 chapter25

Shortest Paths: Dynamic Programming Def. OPT(i, v)=length of shortest s-v path P using at most i edges. Case 1: P uses at most i-1 edges. OPT(i, v) = OPT(i-1, v) Case 2: P uses exactly i edges. If (w, v) is the last edge, then OPT use the best s-w path using at most i-1 edges and edge (w, v). Remark: if no negative cycles, then OPT(n-1, v)=length of shortest s-v path.  Cwv s w v 2019/4/11 chapter25 OPT(0, s)=0.

Shortest Paths: implementation Shortest-Path(G, t) { for each node v  V M[0, v] =  M[0, s] = 0 for i = 1 to n-1 for each node w  V M[i, w] = M[i-1, w] for each edge (w, v)  E M[i, v] = min { M[i, v], M[i-1, w] + cwv } } Analysis. O(mn) time, O(n2) space. m--no. of edges, n—no. of nodes Finding the shortest paths. Maintain a "successor" for each table entry. 2019/4/11 chapter25

Shortest Paths: Practical implementations Practical improvements. Maintain only one array M[v] = shortest v-t path that we have found so far. No need to check edges of the form (w, v) unless M[w] changed in previous iteration. Theorem. Throughout the algorithm, M[v] is the length of some s-v path, and after i rounds of updates, the value M[v]  the length of shortest s-v path using  i edges. Overall impact. Memory: O(m + n). Running time: O(mn) worst case, but substantially faster in practice. 2019/4/11 chapter25

Bellman-Ford: Efficient Implementation Push-Based-Shortest-Path(G, s, t) { for each node v  V { M[v] =  successor[v] = empty } M[s] = 0 for i = 1 to n-1 { for each node w  V { if (M[w] has been updated in previous iteration) { for each node v such that (w, v)  E { if (M[v] > M[w] + cwv) { M[v] = M[w] + cwv successor[v] = w If no M[w] value changed in iteration i, stop. Note: Dijkstra’s Algorithm select a w with the smallest M[w] . Time O(mn), space O(n). 2019/4/11 chapter25

6 7 9 2 5 -2 8 -3 -4 s u v x y (a) 2019/4/11 chapter25

u 5 v 6 8 -2 6 -3 8 7 s -4 2 7 7 8 9 x y (b) 2019/4/11 chapter25

u 5 v 6 4 -2 6 -3 8 7 s -4 2 7 7 2 9 x y (c) 2019/4/11 chapter25

u 5 v 2 4 -2 6 -3 8 7 s -4 2 7 7 2 9 x y (d) 2019/4/11 chapter25

u 5 v 2 4 -2 6 -3 8 7 s -4 2 7 7 -2 y x (e) 9 vertex: s u v x y 7 s -4 2 7 7 -2 y x (e) 9 vertex: s u v x y d: 0 2 4 7 -2 successor: s v x s u 2019/4/11 chapter25

Corollary: If negative-weight circuit exists in the given graph, in the n-th iteration, the cost of a shortest path from s to some node v will be further reduced. Demonstrated by the following example. 2019/4/11 chapter25

An example with negative-weight cycle 5  1 6 -2 8 7 7 9 2 2 5 -8 An example with negative-weight cycle 2019/4/11 chapter25

7 6  8 5 -2 1 2 9 -8 i=1 2019/4/11 chapter25

7 6 16  11 9 8 5 -2 1 2 -8 i=2 2019/4/11 chapter25

7 6 16 12 11 1 9 8 5 -2 2 -8 i=3 2019/4/11 chapter25

6 16 12 11 1 9 7 8 5 -2 2 -8 i=4 2019/4/11 chapter25

5 6 11 1 6 -2 8 7 12 7 9 2 6 15 2 5 -8 8 1 i=5 2019/4/11 chapter25

6 15 12 11 8 7 5 -2 1 2 9 -8 i=6 2019/4/11 chapter25

5 6 11 1 6 -2 8 7 12 7 9 2 5 15 2 5 -8 8 x i=7 2019/4/11 chapter25

5 6 11 1 6 -2 8 7 12 7 9 2 5 15 2 5 -8 7 x i=8 2019/4/11 chapter25

Dijkstra’s Algorithm: (Recall) Dijkstra’s algorithm assumes that w(e)0 for each e in the graph. maintain a set S of vertices such that Every vertex v S, d[v]=(s, v), i.e., the shortest-path from s to v has been found. (Intial values: S=empty, d[s]=0 and d[v]=) (a) select the vertex uV-S such that d[u]=min {d[x]|x V-S}. Set S=S{u} (b) for each node v adjacent to u do RELAX(u, v, w). Repeat step (a) and (b) until S=V. 2019/4/11 chapter25

Continue: DIJKSTRA(G,w,s): INITIALIZE-SINGLE-SOURCE(G,s) S Q V[G] while Q do u EXTRACT -MIN(Q) S S {u} for each vertex v  Adj[u] do RELAX(u,v,w) 2019/4/11 chapter25

u v 10 5 2 1 3 4 6 9 7 8 s Single Source Shortest Path Problem x y (a) 2019/4/11 chapter25

u v 1 10/s 8 10 9 s 2 3 4 6 7 5 5/s 8 2 x y (b) (s,x) is the shortest path using one edge. It is also the shortest path from s to x. 2019/4/11 chapter25

u v 1 8/x 14/x 10 9 s 2 3 4 6 7 5 5/s 7/x 2 x y (c) 2019/4/11 chapter25

u v 1 8/x 13/y 10 9 s 2 3 4 6 7 5 5/s 7/x 2 x y (d) 2019/4/11 chapter25

7/x 9/u 5/s 8/x 10 5 2 1 3 4 6 9 7 s u v x y (e) 2019/4/11 chapter25

Backtracking: v-u-x-s 1 8/x 9/u 10 9 s 2 3 4 6 7 5 5/s 7/x 2 x y (f) Backtracking: v-u-x-s 2019/4/11 chapter25

Proof: We prove it by induction on |S|. Theorem: Consider the set S at any time in the algorithm’s execution. For each vS, the path Pv is a shortest s-v path. Proof: We prove it by induction on |S|. If |S|=1, then the theorem holds. (Because d[s]=0 and S={s}.) Suppose htat the theorem is true for |S|=k for some k>0. Now, we grow S to size k+1 by adding the node v. 2019/4/11 chapter25

Proof: (continue) Now, we grow S to size k+1 by adding the node v. Let (u, v) be the last edge on our s-v path Pv. Consider any other path from P: s,…,x,y, …, v. (red in the Fig.) y is the first node that is not in S and xS. Since we always select the node with the smallest value d[] in the algorithm, we have d[v]d[y]. Moreover, the length of each edge is 0. Thus, the length of Pd[y]d[v]. That is, the length of any path d[v]. Therefore, our path Pv is the shortest. y x s If y does not exist, d[v] is the smallest length for paths from s to v using red nodes only since we did relax.from every red node to v. u v Set S 2019/4/11 chapter25

S->v is shorter than s->u, but it is longer than The algorithm does not work if there are negative weight edges in the graph . u -10 2 v s 1 S->v is shorter than s->u, but it is longer than s->u->v. 2019/4/11 chapter25

0-1 version v/w: 1, 3, 3.6, 3.66, 4. 2019/4/11 chapter25

2019/4/11 chapter25

2019/4/11 chapter25

2019/4/11 chapter25

2019/4/11 chapter25

35 2019/4/11 chapter25