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.

Slides:



Advertisements
Similar presentations
Bellman-Ford algorithm
Advertisements

and 6.855J Cycle Canceling Algorithm. 2 A minimum cost flow problem , $4 20, $1 20, $2 25, $2 25, $5 20, $6 30, $
1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 19 Prof. Erik Demaine.
Introduction to Algorithms 6.046J/18.401J/SMA5503
0 - 0.
Graph Algorithms - 3 Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 13Feb 12, 2014Carnegie Mellon University.
Fibonacci Numbers F n = F n-1 + F n-2 F 0 =0, F 1 =1 – 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 … Straightforward recursive procedure is slow! Why? How slow? Lets.
Greedy Technique Constructs a solution to an optimization problem piece by piece through a sequence of choices that are: feasible, i.e. satisfying the.
ALG0183 Algorithms & Data Structures Lecture 23 a acyclic with neg. weights (topological sort algorithm) 8/25/20091 ALG0183 Algorithms & Data Structures.
COMP 482: Design and Analysis of Algorithms
Two algorithms for checking emptiness. How to check for emptiness? Is L (A) = ; ? Need to check if there exists an accepting computation (passes through.
Advanced Algorithm Design and Analysis Jiaheng Lu Renmin University of China
Epp, section 10.? CS 202 Aaron Bloomfield
 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,
1 Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Single Source Shortest Paths
Advanced Topics in Algorithms and Data Structures
More on Dynamic Programming Bellman-FordFloyd-Warshall Wednesday, July 30 th 1.
* Bellman-Ford: single-source shortest distance * O(VE) for graphs with negative edges * Detects negative weight cycles * Floyd-Warshall: All pairs shortest.
chapter Single-Source Shortest Paths Problem Definition Shortest paths and Relaxation Dijkstra’s algorithm (can be viewed as a greedy algorithm)
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
All Pairs Shortest Paths and Floyd-Warshall Algorithm CLRS 25.2
Chapter 7: Greedy Algorithms 7.4 Finding the Shortest Path Dijkstra’s Algorithm pp
DYNAMIC PROGRAMMING. 2 Algorithmic Paradigms Greedy. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer.
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.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Shortest Path Problems Directed weighted graph. Path length is sum of weights of edges on path. The vertex at which the path begins is the source vertex.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Shortest path algorithm. Introduction 4 The graphs we have seen so far have edges that are unweighted. 4 Many graph situations involve weighted edges.
Shortest Paths Definitions Single Source Algorithms
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.
All-Pairs Shortest Paths
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
Graph (II) Shortest path, Minimum spanning tree GGuy
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.
Dijkstra’s Algorithm Supervisor: Dr.Franek Ritu Kamboj
Shortest Path Algorithms. Definitions Variants  Single-source shortest-paths problem: Given a graph, finding a shortest path from a given source.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight)
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
TIRGUL 10 Dijkstra’s algorithm Bellman-Ford Algorithm 1.
Shortest Paths.
Single-Source Shortest Path
Dijkstra’s shortest path Algorithm
Chapter 7: Greedy Algorithms
All-Pairs Shortest Paths (26.0/25)
More Graph Algorithms.
Graphs & Graph Algorithms 2
Chapter 6 Dynamic Programming
Shortest Paths.
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Chapter 6 Dynamic Programming
2018/12/27 chapter25.
Chapter 6 Dynamic Programming
Shortest Path Algorithms
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Evaluation of the Course (Modified)
Chapter 24: Single-Source Shortest Paths
Shortest Paths.
Chapter 24: Single-Source Shortest Paths
Negative-Weight edges:
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Presentation transcript:

2015/4/11CS4335 Design and Analysis of Algorithms /Shuai Cheng Li Page 1 Evaluation of the Course (Modified) Course work:30% –Four assignments (25%) 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%

chapter252 Single source shortest path with negative cost edges

chapter253 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. s wv  Cwv OPT(0, s)=0.

chapter254 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] + c wv } } Analysis. O(mn) time, O(n 2 ) space. m--no. of edges, n—no. of nodes Finding the shortest paths. Maintain a "successor" for each table entry.

chapter255 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.

chapter256 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. } Time O(mn), space O(n). Note: Dijkstra’s Algorithm select a w with the smallest M[w].

chapter s uv xy (a)

chapter s uv xy (b)

chapter s uv xy (c)

chapter s uv xy (d)

chapter s uv x y (e) vertex: s u v x y d: successor: s v x s u

chapter2512 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.

chapter        An example with negative-weight cycle

chapter      i=1

chapter  11  i=2

chapter i=3

chapter i=4

chapter i=5

chapter i=6

chapter x i=7

chapter x i=8

chapter2522 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.

chapter2523 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)

chapter s uv x y (a)

chapter /s 10/s s uv x y 8 8 (b) (s,x) is the shortest path using one edge. It is also the shortest path from s to x.

chapter /x 14/x 5/s 8/x s uv x y (c)

chapter /x 13/y 5/s 8/x s uv x y (d)

chapter /x 9/u 5/s 8/x s uv x y (e)

chapter /x 9/u 5/s 8/x s uv x y (f) Backtracking: v-u-x-s

chapter2530 The algorithm does not work if there are negative weight edges in the graph s v u S->v is shorter than s->u, but it is longer than s->u->v.