Shortest Paths. Nishant Mehta Lectures 10 and 11

Size: px
Start display at page:

Download "Shortest Paths. Nishant Mehta Lectures 10 and 11"

Transcription

1 Shortest Paths Nishant Mehta Lectures 0 and

2 Communication Speeds in a Computer Network Find fastest way to route a data packet between two computers 6 Kbps 4 0 Mbps 6 6 Kbps 6 Kbps Gbps 00 Mbps 8 6 Kbps Gbps 00 Mbps 0 0 Mbps 00 Mbps Gbps 7 00 Mbps 9

3 Shortest Paths in Weighted Graphs Find fastest way to travel across the country using a graph representing roads, with edge weights represented by: distances travel times between cities (might account for speed limits, traffic, etc.) Find a fastest way using flights Flight distances between airports. Might also allow for warps in space-time continuum. Negative travel time

4 Single-Source Shortest Paths If graph is unweighted: Breadth-First Search is a solution More on this soon If graph is weighted Every edge is associated with a number: integers, rational numbers, real numbers (maybe even negative!) An edge weight can represent: Distance, connection cost, affinity

5 Single-Source Shortest Paths Problem Input: A weighted directed graph G = (V, E) and a source vertex s Output: All single-source shortest paths for s in G, i.e. for all other vertices v in G, a shortest path from s to v. A path p =(v 0,v,...,v k ) from s = v 0 to v = v k is shortest if its length w(p) = P k j= w(v j,v j ) is the minimum possible among all paths

6 Dijkstra s Algorithm

7 Dijkstra s algorithm: a greedy algorithm 9 4 7

8 Dijkstra s algorithm: Initializing

9 Dijkstra s algorithm: Initializing Cloud C (consisting of solved subgraph)

10 Dijkstra s algorithm: pull v into C

11 Dijkstra s algorithm: update C s neighborhood

12 Dijkstra s algorithm: pick closest vertex u outside C

13 Dijkstra s algorithm: pull u into C relax 7

14 Dijkstra s algorithm: update C s neighborhood

15 Dijkstra s algorithm: pick closest vertex u outside C

16 Dijkstra s algorithm: pull u into C

17 Dijkstra s algorithm: update C s neighborhood

18 Dijkstra s algorithm: pick closest vertex u outside C

19 Dijkstra s algorithm: pull u into C

20 Dijkstra s algorithm: update C s neighborhood

21 Dijkstra s algorithm: pick closest vertex u outside C

22 Dijkstra s algorithm: pull u into C

23 Dijkstra s algorithm: update C s neighborhood

24 Dijkstra s algorithm: pick closest vertex u outside C

25 Dijkstra s algorithm: pull u into C 0 4 relax

26 Dijkstra s algorithm: update C s neighborhood

27 Dijkstra s algorithm: pick closest vertex u outside C

28 Dijkstra s algorithm: pull u into C

29 Dijkstra s algorithm: update C s neighborhood

30 Dijkstra s algorithm: pick closest vertex u outside C

31 Dijkstra s algorithm: pull u into C

32 Dijkstra s algorithm: update C s neighborhood

33 Dijkstra s algorithm: pick closest vertex u outside C

34 Dijkstra s algorithm: pull u into C

35 Dijkstra s algorithm: update C s neighborhood

36 Dijkstra s algorithm: pick closest vertex u outside C

37 Dijkstra s algorithm: pull u into C

38 Dijkstra s Algorithm Input: A simple directed graph G with nonnegative edge-weights and a source vertex s in G Output: A number d[u] for each vertex u in G such that d[u] is the weight of the shortest path in G from s to u

39 Dijkstra s Algorithm Dijkstra(V,E,s): For v in V d[v] = ; [v] = null; d[s] = 0 S = ; Q = BuildPriorityQueue(V, d) While Q not empty u = ExtractMin(Q) S = S [ u For v in Adj[u] Relax(u,v)

40 Dijkstra vs Prim Dijkstra(V,E,s): For v in V d[v] = ; [v] = null; d[s] = 0 S = ; Q = BuildPriorityQueue(V, d) While Q not empty u = ExtractMin(Q) S = S [ u For v in Adj[u] If d[u] + w(u,v) < d[v] d[v] = d[u] + w(u,v) [v] = u UpdatePQ(v, [v]) Prim(V,E,s): For v in V d[v] = ; [v] = null; d[s] = 0 S = ; Q = BuildPriorityQueue(V, d) While Q not empty u = ExtractMin(Q) S = S [ u For v in Adj[u] If w(u,v) < d[v] d[v] = w(u,v) [v] = u UpdatePQ(v, [v])

41 Dijkstra vs Prim Dijkstra(V,E,s): For v in V d[v] = ; [v] = null; d[s] = 0 S = ; Q = BuildPriorityQueue(V, d) While Q not empty u = ExtractMin(Q) S = S [ u For v in Adj[u] If d[u] + w(u,v) < d[v] d[v] = d[u] + w(u,v) [v] = u UpdatePQ(v, [v]) Prim(V,E,s): For v in V d[v] = ; [v] = null; d[s] = 0 S = ; Q = BuildPriorityQueue(V, d) While Q not empty u = ExtractMin(Q) S = S [ u For v in Adj[u] If w(u,v) < d[v] d[v] = w(u,v) [v] = u UpdatePQ(v, [v])

42 Dijkstra s Algorithm - Runtime Dijkstra(V,E,s): V calls at most E calls For v in V d[v] = ; [v] = null; d[s] = 0 S = ; Q = BuildPriorityQueue(V, d) While Q not empty u = ExtractMin(Q) S = S [ u For v in Adj[u] If d[u] + w(u,v) < d[v] d[v] = d[u] + w(u,v) [v] = u UpdatePQ(v, [v]) O(V) for binary or Fibonacci heap O(log V)/call for binary heap O()/call for Fibonacci heap O(log V)/call for binary or Fibonacci heaps

43 RELAX preserves upper bound property of d[v] Upper bound property: Any sequence of calls to RELAX maintains the invariant that d[v] (s, v) for all v V Proof: simple exercise Important consequence: If no path from s to v, then d[v] = always!

44 Dijkstra s Algorithm - Correctness Claim: for all v in S, the algorithm s path shortest s-v path Proof by induction Base case: S =, with S = {s} P v from s-v is a Clearly, P s = (s) is a shortest s-s path (of length zero!) Inductive step Suppose the claim holds for S = k Prove that it holds for S = k +

45 Dijkstra s Algorithm - Correctness Let S = k and suppose algorithm is about to add v to S, by way of u in S Let P v be the algorithm s s-v path after the addition, with penultimate vertex u in S Consider an arbitrary alternative path P 0 v Pv 0 has a first edge (x,y) that crosses the cut (S, V \ S) w(pv 0 ) (s, x)+w(x, y) = d[x]+w(x, y) S x y d[u]+w(u, v) = (s, u)+w(u, v) s u v

46 Dijkstra s Algorithm - Correctness Consider an arbitrary alternative path Pv 0 has a first edge (x,y) that crosses the cut S x y P 0 v (S, V \ S) s u v P 0 v Path cannot be shorter than P v w(pv 0 ) (s, x)+w(x, y) = d[x]+w(x, y) d[u]+w(u, v) = (s, u)+w(u, v) = P v (inductive hypothesis) (v is next vertex added to S) (inductive hypothesis)

47 Dijkstra s Algorithm - Negative Weights v - u s What would Dijkstra do?

48 Greed is good. -Gordon Gekko

49 Greed is good. -Gordon Gekko ``Greed is not good (when a graph has negative edge weights). ' - Bernie Sanders

50 Bellman-Ford Algorithm

51 Recall: Path Relaxation Property Let p = (v 0, v, v k ) be a shortest path from v 0 to v k Initialize d and with source s Suppose that a sequence of relaxations occurs which includes the subsequence: RELAX(v 0, v ), RELAX(v, v ),, RELAX(v k-, v k ) Then after the last relaxation in this subsequence and for all times thereafter, we have d[v k ]= (s, v k ) (Proved last time)

52 Bellman-Ford Algorithm An Observation: Suppose shortest path from vertex s to vertex t consists of edge: p = (v 0, v ) with s = v 0 and t = v Then after calling RELAX(v 0, v ): d(t) =d(v )= (v 0, v )= (s, t) Shortest path from s to t has been found! How to ensure RELAX(v 0, v ) gets called? Initialize d and with source s For each edge (u,v) E RELAX(u,v)

53 Bellman-Ford Algorithm An Observation: Suppose shortest path from vertex s to vertex t consists of edges: p = (s = v 0, v, v = t) Then after calling RELAX(v 0, v ), RELAX(v, v ): d(t) =d(v )= (v 0, v )= (s, t) Shortest path from s to t has been found! How to ensure RELAX(v 0, v ), RELAX(v, v ) gets called? Initialize d and For j = with source s For each edge (u,v) RELAX(u,v) E

54 Bellman-Ford Algorithm If no negative cycles, shortest path from vertex s to vertex t consists of (at most) n- edges: p = (v 0, v,, v k ) with k apple n- After calling RELAX(v 0, v ), RELAX(v, v ),, RELAX(v k-, v k ): d(t) =d(v k )= (v 0, v k )= (s, t) Shortest path from s to t has been found! How to ensure subsequence of calls to RELAX(v 0, v ) occurs? Initialize d and with source s For j = n- For each edge (u,v) RELAX(u,v) E

55 Bellman-Ford Algorithm BELLMAN-FORD(G, w, s) Initialize d and with source s For j = n- For each edge (u,v) RELAX(u,v) For each edge (u,v) E E RELAX(u,v) If d[u] + w(u,v) < d[v] d[v] = d[u] + w(u,v) If d[v] > d[u] + w(u,v) Return False Return True

56 Bellman-Ford Algorithm - Correctness Claim : (A) If there are no negative cycles, the algorithm correctly finds the shortest paths ( d[v] = (s, v) for all v) and predecessor array is correct. (B) The algorithm returns True. Claim : If there is a negative cycle, the algorithm detects it and returns False

57 Bellman-Ford Algorithm - Correctness Claim : (A) If there are no negative cycles, the algorithm correctly finds the shortest paths ( d[v] = (s, v) for all v) and predecessor array is correct. Proof: This we already showed in the derivation of the algorithm! The desired subsequence of calls to RELAX occurs, which is all that is required.

58 Bellman-Ford Algorithm - Correctness Claim : (B) The algorithm returns True Proof: We only need to verify that d[v] apple d[u]+w(u, v) for all edges (u, v) E From Claim (A), this is equivalent to (s, v) apple (s, u)+w(u, v) for all edges (u, v) E This must be the case. Why? An s-v path that first visits u and then follows edge (u,v) cannot have less weight than the shortest s-v path

59 Bellman-Ford Algorithm - Correctness Claim : Proof: If there is a negative cycle, the algorithm detects it and returns False Suppose (for a contradiction) that the algorithm returns True Then d[v] apple d[u]+w(u, v) for all edges (u, v) E ( ) Let the negative cycle be (v 0, v,..., v k ), where v 0 = v k Summing inequality ( ) over each edge in the cycle yields: kx j= d[v j ] apple kx (d[v j ]+w(v j, v j )) j=

60 Bellman-Ford Algorithm - Correctness (Proof of Claim ) Suppose (for a contradiction) that the algorithm returns True Then d[v] apple d[u]+w(u, v) for all edges (u, v) E ( ) Let the negative cycle be (v 0, v,..., v k ), where v 0 = v k Summing inequality ( ) over each edge in the cycle yields: kx kx d[v j ] apple (d[v j ]+w(v j, v j )) j= j= But since v 0 = v k, it holds that kx d[v j ]= kx d[v j ] j= j= The above implies that 0 apple P k j= w(v j, v j ), a contradiction of the cycle being negative!

61 Bellman-Ford Algorithm - Time Complexity O(V E) (For loop from to n-) * (Nested for loop over edges) Compare to Dijkstra s algorithm O(E log V) Dealing with negative-weight edges has a cost!

62 Single-Source Shortest Paths Algorithms Type of Graph Algorithm Time complexity Unweighted graph BFS O(V + E) Weighted DAG Topological sort/dfs-based O(V + E) Weighted directed graph (nonnegative weights) Weighted directed graph (any weights) Dijkstra s Algorithm O(E log V) Bellman-Ford O(V E)

63 All-Pairs Shortest Paths Problem Input: A weighted directed graph G = (V, E) Output: All shortest paths in G, i.e. for all pairs of vertices s, t in V, a shortest path from s to t

64 All-Pairs Shortest Paths First approach - run single-source shortest paths algorithm n times, once per choice of source vertex Type of Graph Algorithm Time complexity Dense Graph Time complexity Nonnegative weights Dijkstra s - Binary heap O(V E log V) O(V log V) Dijkstra s - Fibonacci heap O(V log V + E V) O(V log V) Any weights Bellman-Ford O(V E) O(V 4 )

65 All-Pairs Shortest Paths Need to store upper bound on shortest paths for every pair of vertices Switch from array d to matrix D of size n n D ij = upper bound on shortest path from i to j Switch from predecessor array to predecessor matrix ij = predecessor of j in some shortest path from source i

66 Floyd-Warshall Algorithm

67 Floyd-Warshall Algorithm Let p be a shortest path from i to j. Clearly, all intermediate vertices in path p are in {,, n} Also, we can break down p into at most paths whose intermediate vertices are in {,, n-} i p j all intermediate vertices in {,, n} Case Case i p j p n p all intermediate vertices in {,, n-} i all intermediate vertices in {,, n-} j

68 Floyd-Warshall Algorithm For k = 0,,, n: Let be the weight of the shortest path from i to j for which all intermediate vertices are in {,, k} D (k) ij p i j all intermediate vertices in {,, n} Case Case i p j p n p all intermediate vertices in {,, n-} i all intermediate vertices in {,, n-} j D (n) ij = D (n ) ij D (n) (n ) ij = D in + D (n ) nj

69 All-Pairs Shortest Paths For k = 0,,, n: Let be the weight of the shortest path from i to j for which all intermediate vertices are in {,, k} D (k) ij p i j all intermediate vertices in {,, k} Case Case i p j p k p all intermediate vertices in {,, k-} i all intermediate vertices in {,, k-} j D (k) ij = D (k ) ij D (k) (k ) ij = D ik + D (k ) kj

70 Floyd-Warshall Algorithm Recurrence: D (k) ij =min n (k ) (k ) D ij, D ik + D (k ) kj o Base case: D (0) ij = w(i, j) Why? Because no intermediate vertices can be used FLOYD-WARSHALL( ) D (0) = W W For k = n For i = n Return For j = n n D (k) (k ) (k ) ij =min D ij, D ik + D D (n) (k ) kj o

71 Floyd-Warshall Algorithm FLOYD-WARSHALL( ) D (0) = W W Time Complexity O(V ) For k = For i = Return n n For j = n n D (k) (k ) (k ) ij =min D ij, D ik + D D (n) (k ) kj o Correctness? ij is weight of shortest path with intermediate vertices in {,, n}. This is shortest path itself! D (n)

72 Floyd-Warshall Algorithm What about that predecessor matrix? How do we print a shortest path? (k ) D Case : ik + D Path will not change (k ) (k ) kj D ij Reuse predecessor from before: (k) ij = (k ) ij (k ) D (k ) (k ) Case : ik + D kj < D ij Path updates to (path from i to k) (path from k to j) (k) (k ) ij = kj Set predecessor of j in shortest path from source i using intermediate vertices in {,, k} to be predecessor of j in shortest path from source k using intermediate vertices in {,, k-}

Shortest Paths. Nishant Mehta Lectures 10 and 11

Shortest Paths. Nishant Mehta Lectures 10 and 11 Shortest Paths Nishant Mehta Lectures 0 and Finding the Fastest Way to Travel between Two Intersections in Vancouver Granville St and W Hastings St Homer St and W Hastings St 6 Granville St and W Pender

More information

Shortest path problems

Shortest path problems Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths

More information

Minimum Spanning Trees

Minimum Spanning Trees Minimum Spanning Trees Problem A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting houses u and v has a repair cost w(u, v). Goal: Repair enough (and no

More information

Shortest Path Problem

Shortest Path Problem Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths

More information

from notes written mostly by Dr. Carla Savage: All Rights Reserved

from notes written mostly by Dr. Carla Savage: All Rights Reserved CSC 505, Fall 2000: Week 9 Objectives: learn about various issues related to finding shortest paths in graphs learn algorithms for the single-source shortest-path problem observe the relationship among

More information

Single Source Shortest Path

Single Source Shortest Path Single Source Shortest Path A directed graph G = (V, E) and a pair of nodes s, d is given. The edges have a real-valued weight W i. This time we are looking for the weight and the shortest path from s

More information

Introduction. I Given a weighted, directed graph G =(V, E) with weight function

Introduction. I Given a weighted, directed graph G =(V, E) with weight function ntroduction Computer Science & Engineering 2/82 Design and Analysis of Algorithms Lecture 06 Single-Source Shortest Paths (Chapter 2) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu

More information

COMP251: Single source shortest paths

COMP251: Single source shortest paths COMP51: Single source shortest paths Jérôme Waldispühl School of Computer Science McGill University Based on (Cormen et al., 00) Problem What is the shortest road to go from one city to another? Eample:

More information

Lecture 11: Analysis of Algorithms (CS ) 1

Lecture 11: Analysis of Algorithms (CS ) 1 Lecture 11: Analysis of Algorithms (CS583-002) 1 Amarda Shehu November 12, 2014 1 Some material adapted from Kevin Wayne s Algorithm Class @ Princeton 1 2 Dynamic Programming Approach Floyd-Warshall Shortest

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 07 Single-Source Shortest Paths (Chapter 24) Stephen Scott and Vinodchandran N. Variyam sscott@cse.unl.edu 1/36 Introduction

More information

Introduction. I Given a weighted, directed graph G =(V, E) with weight function

Introduction. I Given a weighted, directed graph G =(V, E) with weight function ntroduction Computer Science & Engineering 2/82 Design and Analysis of Algorithms Lecture 05 Single-Source Shortest Paths (Chapter 2) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu

More information

Title. Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis. Nesrine Damak. Fakultät für Informatik TU München. 20.

Title. Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis. Nesrine Damak. Fakultät für Informatik TU München. 20. Title Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis Nesrine Damak Fakultät für Informatik TU München 20. September 2010 Nesrine Damak: Classical Shortest-Path Algorithms 1/ 35

More information

5.4 Shortest Paths. Jacobs University Visualization and Computer Graphics Lab. CH : Algorithms and Data Structures 456

5.4 Shortest Paths. Jacobs University Visualization and Computer Graphics Lab. CH : Algorithms and Data Structures 456 5.4 Shortest Paths CH08-320201: Algorithms and Data Structures 456 Definitions: Path Consider a directed graph G=(V,E), where each edge e є E is assigned a non-negative weight w: E -> R +. A path is a

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming and data-structures CS/ENGRD 20 SUMMER 208 Lecture 3: Shortest Path http://courses.cs.cornell.edu/cs20/208su Graph Algorithms Search Depth-first search Breadth-first search

More information

Graphs. Part II: SP and MST. Laura Toma Algorithms (csci2200), Bowdoin College

Graphs. Part II: SP and MST. Laura Toma Algorithms (csci2200), Bowdoin College Laura Toma Algorithms (csci2200), Bowdoin College Topics Weighted graphs each edge (u, v) has a weight denoted w(u, v) or w uv stored in the adjacency list or adjacency matrix The weight of a path p =

More information

Shortest Paths. CSE 373 Data Structures Lecture 21

Shortest Paths. CSE 373 Data Structures Lecture 21 Shortest Paths CSE 7 Data Structures Lecture Readings and References Reading Section 9., Section 0.. Some slides based on: CSE 6 by S. Wolfman, 000 //0 Shortest Paths - Lecture Path A path is a list of

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 20. Example. Shortest Paths Definitions

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 20. Example. Shortest Paths Definitions Taking Stock IE170: Algorithms in Systems Engineering: Lecture 20 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University March 19, 2007 Last Time Minimum Spanning Trees Strongly

More information

Chapter 25: All-Pairs Shortest-Paths

Chapter 25: All-Pairs Shortest-Paths Chapter : All-Pairs Shortest-Paths When no negative edges Some Algorithms Using Dijkstra s algorithm: O(V ) Using Binary heap implementation: O(VE lg V) Using Fibonacci heap: O(VE + V log V) When no negative

More information

Classical Shortest-Path Algorithms

Classical Shortest-Path Algorithms DISTANCE PROBLEMS IN NETWORKS - THEORY AND PRACTICE Classical Shortest-Path Algorithms Nesrine Damak October 10, 2010 Abstract In this work, we present four algorithms for the shortest path problem. The

More information

Single Source Shortest Path (SSSP) Problem

Single Source Shortest Path (SSSP) Problem Single Source Shortest Path (SSSP) Problem Single Source Shortest Path Problem Input: A directed graph G = (V, E); an edge weight function w : E R, and a start vertex s V. Find: for each vertex u V, δ(s,

More information

Artificial Intelligence

Artificial Intelligence Artificial Intelligence Shortest Path Problem G. Guérard Department of Nouvelles Energies Ecole Supérieur d Ingénieurs Léonard de Vinci Lecture 3 GG A.I. 1/42 Outline 1 The Shortest Path Problem Introduction

More information

Outline. (single-source) shortest path. (all-pairs) shortest path. minimum spanning tree. Dijkstra (Section 4.4) Bellman-Ford (Section 4.

Outline. (single-source) shortest path. (all-pairs) shortest path. minimum spanning tree. Dijkstra (Section 4.4) Bellman-Ford (Section 4. Weighted Graphs 1 Outline (single-source) shortest path Dijkstra (Section 4.4) Bellman-Ford (Section 4.6) (all-pairs) shortest path Floyd-Warshall (Section 6.6) minimum spanning tree Kruskal (Section 5.1.3)

More information

Dijkstra s Shortest Path Algorithm

Dijkstra s Shortest Path Algorithm Dijkstra s Shortest Path Algorithm DPV 4.4, CLRS 24.3 Revised, October 23, 2014 Outline of this Lecture Recalling the BFS solution of the shortest path problem for unweighted (di)graphs. The shortest path

More information

1 Dijkstra s Algorithm

1 Dijkstra s Algorithm Lecture 11 Dijkstra s Algorithm Scribes: Himanshu Bhandoh (2015), Virginia Williams, and Date: November 1, 2017 Anthony Kim (2016), G. Valiant (2017), M. Wootters (2017) (Adapted from Virginia Williams

More information

Shortest Path Algorithms

Shortest Path Algorithms Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E

More information

Algorithms on Graphs: Part III. Shortest Path Problems. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

Algorithms on Graphs: Part III. Shortest Path Problems. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. Shortest Path Problems Algorithms on Graphs: Part III Path in a graph. Let G = V,E be a graph. A path p = e 1,...,e k, e i E,

More information

CS420/520 Algorithm Analysis Spring 2009 Lecture 14

CS420/520 Algorithm Analysis Spring 2009 Lecture 14 CS420/520 Algorithm Analysis Spring 2009 Lecture 14 "A Computational Analysis of Alternative Algorithms for Labeling Techniques for Finding Shortest Path Trees", Dial, Glover, Karney, and Klingman, Networks

More information

The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation

The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation The Shortest Path Problem jla,jc@imm.dtu.dk Department of Management Engineering Technical University of Denmark The Shortest Path Problem Given a directed network G = (V,E,w) for which the underlying

More information

Algorithms. All-Pairs Shortest Paths. Dong Kyue Kim Hanyang University

Algorithms. All-Pairs Shortest Paths. Dong Kyue Kim Hanyang University Algorithms All-Pairs Shortest Paths Dong Kyue Kim Hanyang University dqkim@hanyang.ac.kr Contents Using single source shortest path algorithms Presents O(V 4 )-time algorithm, O(V 3 log V)-time algorithm,

More information

Dijkstra s Algorithm

Dijkstra s Algorithm Dijkstra s Algorithm 7 1 3 1 Weighted Graphs In a weighted graph, each edge has an associated numerical value, called the weight of the edge Edge weights may represent, distances, costs, etc. Example:

More information

Unit 2: Algorithmic Graph Theory

Unit 2: Algorithmic Graph Theory Unit 2: Algorithmic Graph Theory Course contents: Introduction to graph theory Basic graph algorithms Reading Chapter 3 Reference: Cormen, Leiserson, and Rivest, Introduction to Algorithms, 2 nd Ed., McGraw

More information

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019 CS 341: Algorithms Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo February 26, 2019 D.R. Stinson (SCS) CS 341 February 26, 2019 1 / 296 1 Course Information 2 Introduction

More information

COT 6405 Introduction to Theory of Algorithms

COT 6405 Introduction to Theory of Algorithms COT 6405 Introduction to Theory of Algorithms Topic 16. Single source shortest path 11/18/2015 1 Problem definition Problem: given a weighted directed graph G, find the minimum-weight path from a given

More information

Week 12: Minimum Spanning trees and Shortest Paths

Week 12: Minimum Spanning trees and Shortest Paths Agenda: Week 12: Minimum Spanning trees and Shortest Paths Kruskal s Algorithm Single-source shortest paths Dijkstra s algorithm for non-negatively weighted case Reading: Textbook : 61-7, 80-87, 9-601

More information

1 The Shortest Path Problem

1 The Shortest Path Problem CS161 Lecture 11 Single Source Shortest Paths Scribed by: Romil Verma (2015), Virginia Date: May 8, 2016 1 The Shortest Path Problem In this lecture, we ll discuss the shortest path problem. Assume we

More information

Theory of Computing. Lecture 7 MAS 714 Hartmut Klauck

Theory of Computing. Lecture 7 MAS 714 Hartmut Klauck Theory of Computing Lecture 7 MAS 714 Hartmut Klauck Shortest paths in weighted graphs We are given a graph G (adjacency list with weights W(u,v)) No edge means W(u,v)=1 We look for shortest paths from

More information

Single Source Shortest Paths

Single Source Shortest Paths Single Source Shortest Paths Given a connected weighted directed graph G(V, E), associated with each edge u, v E, there is a weight w(u, v). The single source shortest paths (SSSP) problem is to find a

More information

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths Part VI Graph algorithms Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths 1 Chapter 22 Elementary Graph Algorithms Representations of graphs

More information

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8 Fundamental Algorithms CSCI-GA.70-00/Summer 206 Solution to Homework 8 Problem (CLRS 23.-6). ( point) Show that a graph has a unique minimum spanning tree if, for every cut of the graph, there is a unique

More information

CHAPTER 13 GRAPH ALGORITHMS

CHAPTER 13 GRAPH ALGORITHMS CHAPTER 13 GRAPH ALGORITHMS SFO LAX ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 00) AND SLIDES FROM NANCY

More information

CS 561, Lecture 10. Jared Saia University of New Mexico

CS 561, Lecture 10. Jared Saia University of New Mexico CS 561, Lecture 10 Jared Saia University of New Mexico Today s Outline The path that can be trodden is not the enduring and unchanging Path. The name that can be named is not the enduring and unchanging

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 6 Greedy Graph Algorithms Shortest paths Adam Smith 9/8/14 The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle Does

More information

COL 702 : Assignment 1 solutions

COL 702 : Assignment 1 solutions COL 70 : Assignment 1 solutions 1(a ( n T (n = T + bn log n ( n = T + b n ( n log + bn log n ( n = T + b n ( n 8 log + b n log ( n + bn log n = bn log n + b n log n + bn log n +... log n terms = nb [(log

More information

Dijkstra s Algorithm. Dijkstra s algorithm is a natural, greedy approach towards

Dijkstra s Algorithm. Dijkstra s algorithm is a natural, greedy approach towards CPSC-320: Intermediate Algorithm Design and Analysis 128 CPSC-320: Intermediate Algorithm Design and Analysis 129 Dijkstra s Algorithm Dijkstra s algorithm is a natural, greedy approach towards solving

More information

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo

More information

Chapter 24. Shortest path problems. Chapter 24. Shortest path problems. 24. Various shortest path problems. Chapter 24. Shortest path problems

Chapter 24. Shortest path problems. Chapter 24. Shortest path problems. 24. Various shortest path problems. Chapter 24. Shortest path problems Chapter 24. Shortest path problems We are given a directed graph G = (V,E) with each directed edge (u,v) E having a weight, also called a length, w(u,v) that may or may not be negative. A shortest path

More information

Data Structures and Algorithms. Werner Nutt

Data Structures and Algorithms. Werner Nutt Data Structures and Algorithms Werner Nutt nutt@inf.unibz.it http://www.inf.unibz/it/~nutt Chapter 10 Academic Year 2012-2013 1 Acknowledgements & Copyright Notice These slides are built on top of slides

More information

Tutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u].

Tutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u]. Tutorial Question 1 A depth-first forest classifies the edges of a graph into tree, back, forward, and cross edges. A breadth-first tree can also be used to classify the edges reachable from the source

More information

Introduction to Algorithms. Lecture 11

Introduction to Algorithms. Lecture 11 Introduction to Algorithms Lecture 11 Last Time Optimization Problems Greedy Algorithms Graph Representation & Algorithms Minimum Spanning Tree Prim s Algorithm Kruskal s Algorithm 2 Today s Topics Shortest

More information

Minimum Spanning Trees Ch 23 Traversing graphs

Minimum Spanning Trees Ch 23 Traversing graphs Next: Graph Algorithms Graphs Ch 22 Graph representations adjacency list adjacency matrix Minimum Spanning Trees Ch 23 Traversing graphs Breadth-First Search Depth-First Search 11/30/17 CSE 3101 1 Graphs

More information

Advanced Algorithm Design and Analysis (Lecture 5) SW5 fall 2007 Simonas Šaltenis

Advanced Algorithm Design and Analysis (Lecture 5) SW5 fall 2007 Simonas Šaltenis Advanced Algorithm Design and Analysis (Lecture 5) SW5 fall 2007 Simonas Šaltenis 3.2.12 simas@cs.aau.dk All-pairs shortest paths Main goals of the lecture: to go through one more example of dynamic programming

More information

Design and Analysis of Algorithms 演算法設計與分析. Lecture 13 December 18, 2013 洪國寶

Design and Analysis of Algorithms 演算法設計與分析. Lecture 13 December 18, 2013 洪國寶 Design and Analysis of Algorithms 演算法設計與分析 Lecture 13 December 18, 2013 洪國寶 1 Homework #10 1. 24.1-1 (p. 591 / p. 654) 2. 24.1-6 (p. 592 / p. 655) 3. 24.3-2 (p. 600 / p. 663) 4. 24.3-8 (p. 601) / 24.3-10

More information

Single Source Shortest Path: The Bellman-Ford Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley

Single Source Shortest Path: The Bellman-Ford Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley Single Source Shortest Path: The Bellman-Ford Algorithm Slides based on Kevin Wayne / Pearson-Addison Wesley Single Source Shortest Path Problem Shortest path network. Directed graph G = (V, E, w). Weight

More information

Week 11: Minimum Spanning trees

Week 11: Minimum Spanning trees Week 11: Minimum Spanning trees Agenda: Minimum Spanning Trees Prim s Algorithm Reading: Textbook : 61-7 1 Week 11: Minimum Spanning trees Minimum spanning tree (MST) problem: Input: edge-weighted (simple,

More information

Taking Stock. Last Time Flows. This Time Review! 1 Characterize the structure of an optimal solution

Taking Stock. Last Time Flows. This Time Review! 1 Characterize the structure of an optimal solution Taking Stock IE170: Algorithms in Systems Engineering: Lecture 26 Jeff Linderoth Last Time Department of Industrial and Systems Engineering Lehigh University April 2, 2007 This Time Review! Jeff Linderoth

More information

CS161 - Minimum Spanning Trees and Single Source Shortest Paths

CS161 - Minimum Spanning Trees and Single Source Shortest Paths CS161 - Minimum Spanning Trees and Single Source Shortest Paths David Kauchak Single Source Shortest Paths Given a graph G and two vertices s, t what is the shortest path from s to t? For an unweighted

More information

Graphs II - Shortest paths

Graphs II - Shortest paths Graphs II - Shortest paths Single Source Shortest Paths All Sources Shortest Paths some drawings and notes from prof. Tom Cormen Single Source SP Context: directed graph G=(V,E,w), weighted edges The shortest

More information

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24 /8/11 Single-Source Shortest Path Chapter 1 Shortest Paths Finding the shortest path between two nodes comes up in many applications o Transportation problems o Motion planning o Communication problems

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

Ma/CS 6a Class 27: Shortest Paths

Ma/CS 6a Class 27: Shortest Paths // Ma/CS a Class 7: Shortest Paths By Adam Sheffer Naïve Path Planning Problem. We are given a map with cities and noncrossing roads between pairs of cities. Describe an algorithm for finding a path between

More information

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker Dijkstra s Single Source Shortest Path Algorithm Andreas Klappenecker Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E -> R. Problem:!!

More information

Dynamic Programming: 1D Optimization. Dynamic Programming: 2D Optimization. Fibonacci Sequence. Crazy 8 s. Edit Distance

Dynamic Programming: 1D Optimization. Dynamic Programming: 2D Optimization. Fibonacci Sequence. Crazy 8 s. Edit Distance Dynamic Programming: 1D Optimization Fibonacci Sequence To efficiently calculate F [x], the xth element of the Fibonacci sequence, we can construct the array F from left to right (or bottom up ). We start

More information

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15 600.363 Introduction to Algorithms / 600.463 Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15 14.1 Introduction Today we re going to talk about algorithms for computing shortest

More information

CS 561, Lecture 10. Jared Saia University of New Mexico

CS 561, Lecture 10. Jared Saia University of New Mexico CS 561, Lecture 10 Jared Saia University of New Mexico Today s Outline The path that can be trodden is not the enduring and unchanging Path. The name that can be named is not the enduring and unchanging

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Topological sort Shortest paths Adam Smith The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle

More information

Directed Graphs. DSA - lecture 5 - T.U.Cluj-Napoca - M. Joldos 1

Directed Graphs. DSA - lecture 5 - T.U.Cluj-Napoca - M. Joldos 1 Directed Graphs Definitions. Representations. ADT s. Single Source Shortest Path Problem (Dijkstra, Bellman-Ford, Floyd-Warshall). Traversals for DGs. Parenthesis Lemma. DAGs. Strong Components. Topological

More information

Analysis of Algorithms, I

Analysis of Algorithms, I Analysis of Algorithms, I CSOR W4231.002 Eleni Drinea Computer Science Department Columbia University Thursday, March 8, 2016 Outline 1 Recap Single-source shortest paths in graphs with real edge weights:

More information

Outline. Computer Science 331. Definitions: Paths and Their Costs. Computation of Minimum Cost Paths

Outline. Computer Science 331. Definitions: Paths and Their Costs. Computation of Minimum Cost Paths Outline Computer Science 33 Computation of Minimum-Cost Paths Dijkstra s Mike Jacobson Department of Computer Science University of Calgary Lecture #34 Dijkstra s to Find Min-Cost Paths 3 Example 4 5 References

More information

MA 252: Data Structures and Algorithms Lecture 36. Partha Sarathi Mandal. Dept. of Mathematics, IIT Guwahati

MA 252: Data Structures and Algorithms Lecture 36. Partha Sarathi Mandal. Dept. of Mathematics, IIT Guwahati MA 252: Data Structures and Algorithms Lecture 36 http://www.iitg.ernet.in/psm/indexing_ma252/y12/index.html Partha Sarathi Mandal Dept. of Mathematics, IIT Guwahati The All-Pairs Shortest Paths Problem

More information

Breadth-First Search, 1. Slides for CIS 675 DPV Chapter 4. Breadth-First Search, 3. Breadth-First Search, 2

Breadth-First Search, 1. Slides for CIS 675 DPV Chapter 4. Breadth-First Search, 3. Breadth-First Search, 2 Breadth-First Search, Slides for CIS DPV Chapter Jim Royer EECS October, 00 Definition In an undirected graph, the distance between two vertices is the length of the shortest path between them. (If there

More information

Graph Algorithms shortest paths, minimum spanning trees, etc.

Graph Algorithms shortest paths, minimum spanning trees, etc. Graph Algorithms shortest paths, minimum spanning trees, etc. SFO ORD LAX DFW Graphs 1 Outline and Reading Graphs ( 1.1) Definition Applications Terminology Properties ADT Data structures for graphs (

More information

Unit 5F: Layout Compaction

Unit 5F: Layout Compaction Course contents Unit 5F: Layout Compaction Design rules Symbolic layout Constraint-graph compaction Readings: Chapter 6 Unit 5F 1 Design rules: restrictions on the mask patterns to increase the probability

More information

Unit 3: Layout Compaction

Unit 3: Layout Compaction Unit 3: Layout Compaction Course contents Design rules Symbolic layout Constraint-graph compaction Readings: Chapter 6 Unit 3 1 Design rules: restrictions on the mask patterns to increase the probability

More information

Algorithms for Data Science

Algorithms for Data Science Algorithms for Data Science CSOR W4246 Eleni Drinea Computer Science Department Columbia University Shortest paths in weighted graphs (Bellman-Ford, Floyd-Warshall) Outline 1 Shortest paths in graphs with

More information

The Shortest Path Problem

The Shortest Path Problem The Shortest Path Problem 1 Shortest-Path Algorithms Find the shortest path from point A to point B Shortest in time, distance, cost, Numerous applications Map navigation Flight itineraries Circuit wiring

More information

(Refer Slide Time: 00:18)

(Refer Slide Time: 00:18) Programming, Data Structures and Algorithms Prof. N. S. Narayanaswamy Department of Computer Science and Engineering Indian Institute of Technology, Madras Module 11 Lecture 58 Problem: single source shortest

More information

Shortest Paths. Shortest Path. Applications. CSE 680 Prof. Roger Crawfis. Given a weighted directed graph, one common problem is finding the shortest

Shortest Paths. Shortest Path. Applications. CSE 680 Prof. Roger Crawfis. Given a weighted directed graph, one common problem is finding the shortest Shortest Path Introduction to Algorithms Shortest Paths CS 60 Prof. Roger Crawfis Given a weighted directed graph, one common problem is finding the shortest path between two given vertices Recall that

More information

Sample Solutions to Homework #4

Sample Solutions to Homework #4 National Taiwan University Handout #25 Department of Electrical Engineering January 02, 207 Algorithms, Fall 206 TA: Zhi-Wen Lin and Yen-Chun Liu Sample Solutions to Homework #4. (0) (a) Both of the answers

More information

Solutions to relevant spring 2000 exam problems

Solutions to relevant spring 2000 exam problems Problem 2, exam Here s Prim s algorithm, modified slightly to use C syntax. MSTPrim (G, w, r): Q = V[G]; for (each u Q) { key[u] = ; key[r] = 0; π[r] = 0; while (Q not empty) { u = ExtractMin (Q); for

More information

Sources for this lecture 2. Shortest paths and minimum spanning trees

Sources for this lecture 2. Shortest paths and minimum spanning trees S-72.2420 / T-79.5203 Shortest paths and minimum spanning trees 1 S-72.2420 / T-79.5203 Shortest paths and minimum spanning trees 3 Sources for this lecture 2. Shortest paths and minimum spanning trees

More information

Lecture #7. 1 Introduction. 2 Dijkstra s Correctness. COMPSCI 330: Design and Analysis of Algorithms 9/16/2014

Lecture #7. 1 Introduction. 2 Dijkstra s Correctness. COMPSCI 330: Design and Analysis of Algorithms 9/16/2014 COMPSCI 330: Design and Analysis of Algorithms 9/16/2014 Lecturer: Debmalya Panigrahi Lecture #7 Scribe: Nat Kell 1 Introduction In this lecture, we will further examine shortest path algorithms. We will

More information

All Shortest Paths. Questions from exercises and exams

All Shortest Paths. Questions from exercises and exams All Shortest Paths Questions from exercises and exams The Problem: G = (V, E, w) is a weighted directed graph. We want to find the shortest path between any pair of vertices in G. Example: find the distance

More information

CSE 502 Class 23. Jeremy Buhler Steve Cole. April BFS solves unweighted shortest path problem. Every edge traversed adds one to path length

CSE 502 Class 23. Jeremy Buhler Steve Cole. April BFS solves unweighted shortest path problem. Every edge traversed adds one to path length CSE 502 Class 23 Jeremy Buhler Steve Cole April 14 2015 1 Weighted Version of Shortest Paths BFS solves unweighted shortest path problem Every edge traversed adds one to path length What if edges have

More information

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018 CS Section # Shortest Paths and MSTs //08 Shortest Paths There are types of shortest paths problems: Single source single destination Single source to all destinations All pairs shortest path In today

More information

Graph Algorithms shortest paths, minimum spanning trees, etc.

Graph Algorithms shortest paths, minimum spanning trees, etc. SFO ORD LAX Graph Algorithms shortest paths, minimum spanning trees, etc. DFW Nancy Amato Parasol Lab, Dept. CSE, Texas A&M University Acknowledgement: These slides are adapted from slides provided with

More information

Introduction Single-source shortest paths All-pairs shortest paths. Shortest paths in graphs

Introduction Single-source shortest paths All-pairs shortest paths. Shortest paths in graphs Shortest paths in graphs Remarks from previous lectures: Path length in unweighted graph equals to edge count on the path Oriented distance (δ(u, v)) between vertices u, v equals to the length of the shortest

More information

Lecture 6 Basic Graph Algorithms

Lecture 6 Basic Graph Algorithms CS 491 CAP Intro to Competitive Algorithmic Programming Lecture 6 Basic Graph Algorithms Uttam Thakore University of Illinois at Urbana-Champaign September 30, 2015 Updates ICPC Regionals teams will be

More information

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Floyd-Warshall algorithm in O(n 3 ) time. Neither of

More information

Minimum Spanning Trees

Minimum Spanning Trees Minimum Spanning Trees 1 Minimum- Spanning Trees 1. Concrete example: computer connection. Definition of a Minimum- Spanning Tree Concrete example Imagine: You wish to connect all the computers in an office

More information

Lecture I: Shortest Path Algorithms

Lecture I: Shortest Path Algorithms Lecture I: Shortest Path Algorithms Dr Kieran T. Herley Department of Computer Science University College Cork October 201 KH (21/10/1) Lecture I: Shortest Path Algorithms October 201 1 / 28 Background

More information

Parallel Graph Algorithms

Parallel Graph Algorithms Parallel Graph Algorithms Design and Analysis of Parallel Algorithms 5DV050/VT3 Part I Introduction Overview Graphs definitions & representations Minimal Spanning Tree (MST) Prim s algorithm Single Source

More information

Shortest Paths: Basics. Algorithms and Networks 2016/2017 Johan M. M. van Rooij Hans L. Bodlaender

Shortest Paths: Basics. Algorithms and Networks 2016/2017 Johan M. M. van Rooij Hans L. Bodlaender Shortest Paths: Basics Algorithms and Networks 2016/2017 Johan M. M. van Rooij Hans L. Bodlaender 1 Shortest path problem(s) Undirected single-pair shortest path problem Given a graph G=(V,E) and a length

More information

Dijkstra s Algorithm. Single source shortest paths for a directed acyclic graph

Dijkstra s Algorithm. Single source shortest paths for a directed acyclic graph Dijkstra s Algorithm Single source shortest paths for a directed acyclic graph Single-Source Shortest Paths We want to find the shortest paths between Binghamton and New York City, Boston, and Washington

More information

Minimum Spanning Tree

Minimum Spanning Tree Minimum Spanning Tree 1 Minimum Spanning Tree G=(V,E) is an undirected graph, where V is a set of nodes and E is a set of possible interconnections between pairs of nodes. For each edge (u,v) in E, we

More information

Scribe from 2014/2015: Jessica Su, Hieu Pham Date: October 6, 2016 Editor: Jimmy Wu

Scribe from 2014/2015: Jessica Su, Hieu Pham Date: October 6, 2016 Editor: Jimmy Wu CS 267 Lecture 3 Shortest paths, graph diameter Scribe from 2014/2015: Jessica Su, Hieu Pham Date: October 6, 2016 Editor: Jimmy Wu Today we will talk about algorithms for finding shortest paths in a graph.

More information

Lecture 5: Graph algorithms 1

Lecture 5: Graph algorithms 1 DD2458, Problem Solving and Programming Under Pressure Lecture 5: Graph algorithms 1 Date: 2008-10-01 Scribe(s): Mikael Auno and Magnus Andermo Lecturer: Douglas Wikström This lecture presents some common

More information

CS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016

CS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016 CS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016 1 Depth first search 1.1 The Algorithm Besides breadth first search, which we saw in class in relation to Dijkstra s algorithm, there

More information

Introductory Computer Programming: Shortest Path Algorithms

Introductory Computer Programming: Shortest Path Algorithms Introductory Computer Programming: 2017-18 Shortest Path Algorithms Soumik Purkayastha MD-1710 Contents 1 Project Proposal 1 2 Report 3 2.1 Introduction........................................ 3 2.2 Basic

More information

Shortest Paths. March 21, CTU in Prague. Z. Hanzálek (CTU) Shortest Paths March 21, / 44

Shortest Paths. March 21, CTU in Prague. Z. Hanzálek (CTU) Shortest Paths March 21, / 44 Shortest Paths Zdeněk Hanzálek hanzalek@fel.cvut.cz CTU in Prague March 21, 2017 Z. Hanzálek (CTU) Shortest Paths March 21, 2017 1 / 44 Table of contents 1 Introduction Problem Statement Negative Weights

More information

Communication Networks I December 4, 2001 Agenda Graph theory notation Trees Shortest path algorithms Distributed, asynchronous algorithms Page 1

Communication Networks I December 4, 2001 Agenda Graph theory notation Trees Shortest path algorithms Distributed, asynchronous algorithms Page 1 Communication Networks I December, Agenda Graph theory notation Trees Shortest path algorithms Distributed, asynchronous algorithms Page Communication Networks I December, Notation G = (V,E) denotes a

More information