2/28/2005Tucker, Sec. 4.11 Applied Combinatorics, 4th ed. Alan Tucker Section 4.1 Shortest Paths Prepared by Sarah Walker.

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

Weighted graphs Example Consider the following graph, where nodes represent cities, and edges show if there is a direct flight between each pair of cities.
3/17/2003Tucker, Applied Combinatorics Section 4.2a 1 Network Flows Michael Duquette & Whitney Sherman Tucker, Applied Combinatorics, Section 4.2a, Group.
The Greedy Approach Chapter 8. The Greedy Approach It’s a design technique for solving optimization problems Based on finding optimal local solutions.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
Applied Combinatorics, 4th Ed. Alan Tucker
4/5/05Tucker, Sec Applied Combinatorics, 4rth Ed. Alan Tucker Section 4.3 Graph Models Prepared by Jo Ellis-Monaghan.
Applied Discrete Mathematics Week 12: Trees
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:
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Section 4.2 Network Flows By Christina Touhey. The flow out of a equals the flow into z. Algorithm 1.Make vertex a: (0, ). 2.Scan the first vertex and.
02/01/05Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 1.3 Edge Counting Prepared by Joshua Schoenly and Kathleen McNamara.
The Theory of NP-Completeness
1/25/2005Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 1.2 Isomorphism Prepared by Jo Ellis-Monaghan.
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.
MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 15, Friday, October 3.
2.2 Hamilton Circuits Hamilton Circuits Hamilton Paths Tucker, Applied Combinatorics, Section 2.2, Tamsen Hunter.
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.
3/29/05Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 4.2 Minimal Spanning Trees Prepared by Amanda Dargie and Michele Fretta.
Discrete Math for CS Chapter 8: Directed Graphs. Discrete Math for CS digraph: A digraph is a graph G = (V,E) where V is a finite set of vertices and.
03/01/2005Tucker, Sec Applied Combinatorics, 4th Ed. Alan Tucker Section 3.1 Properties of Trees Prepared by Joshua Schoenly and Kathleen McNamara.
Chapter 4 Network Algorithms Section 4.1 Shortest Paths Colleen Raimondi.
The Shortest Path Problem
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The distance.
1/22/03Tucker, Applied Combinatorics, Section EDGE COUNTING TUCKER, APPLIED COMBINATORICS, SECTION 1.3, GROUP B Michael Duquette & Amanda Dargie.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Greedy methods Prudence Wong
CS 146: Data Structures and Algorithms July 21 Class Meeting
Copyright © Cengage Learning. All rights reserved.
Chapter 4: Finding the Shortest Path Lesson 1: Dijkstra’s Algorithm
Using Dijkstra’s Algorithm to Find a Shortest Path from a to z 1.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Graph Theory Hamilton Paths and Hamilton Circuits.
Which of these can be drawn without taking your pencil off the paper and without going over the same line twice? If we can find a path that goes over all.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Shortest Path in Weighted Graph : Dijkstra’s Algorithm.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
2/25/2016Tucker, Sec Applied Combinatorics, 4 th Ed. Alan Tucker Section 2.2 Hamilton Circuits Prepared by: Nathan Rounds and David Miller.
Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Shortest Path Problems
COMP108 Algorithmic Foundations Greedy methods
Greedy Technique.
Shortest Path 6/18/2018 4:22 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Ellen Walker CPSC 201 Data Structures Hiram College
Applied Combinatorics, 4th Ed. Alan Tucker
Tucker, Applied Combinatorics, Sec 2.4
Shortest Path Problems
Applied Combinatorics, 4th Ed. Alan Tucker
Applied Combinatorics, 4th Ed. Alan Tucker
Spanning Trees.
Shortest Path.
Shortest Path.
Shortest Path Problems
Applied Combinatorics, 4th Ed. Alan Tucker
Shortest path algorithm
Analysis of Algorithms
Applied Combinatorics, 4th ed. Alan Tucker
Chapter 4: Finding the Shortest Path Lesson 1: Dijkstra’s Algorithm
Activity Networks
EE5900 Advanced Embedded System For Smart Infrastructure
Shortest Path.
Single Source Shortest Paths Dijkstra’s Alg. (no negative lengths!)
Lecture 11 CSE 331 Sep 21, 2017.
GRAPHS.
Analysis of Algorithms
Presentation transcript:

2/28/2005Tucker, Sec Applied Combinatorics, 4th ed. Alan Tucker Section 4.1 Shortest Paths Prepared by Sarah Walker

2/28/2005Tucker, Sec Definition A network is a graph with a positive integer k(e) assigned to each edge e. This integer will typically represent the “length” of an edge, in units such as miles, or represent “capacity” of an edge, in units such as megwatts or gallons per minute. Note: Edge (a,b) has a “length” of 5, so k(a,b)=5. ab cd e

2/28/2005Tucker, Sec Shortest Path It can be helpful to find a shortest path in a network from point a to point z. We do not say the shortest path, because, in general, there may be more than one shortest path from a to z. We will assume that all networks are undirected and connected.

2/28/2005Tucker, Sec Shortest Path Cont. We can eliminate one shortest path algorithm: Determine the lengths of all paths from a to z, and choose the shortest one. Such enumeration is already infeasible for most networks with 20 vertices. We must be able to prove that a path is the shortest path without comparing it to all other possible paths.

2/28/2005Tucker, Sec Dijkstra’s Algorithm Gives shortest paths from a given vertex a to all other vertices. Let k(e) denote the length of edge e. Let the variable m be a “distance counter”, for increasing values of m, the algorithm labels vertices whose minimal distance from a is m.

2/28/2005Tucker, Sec Dijkstra’s Algorithm Cont. Step 1 – set m=1 and label vertex a with (-,0) (the “-” represents a blank a (-,0) b c de f g h

2/28/2005Tucker, Sec Notation A vertex in Dijkstra’s algorithm is labeled as follows: (r, d(p)) Where r is the preceding vertex in the path and d(p) is a distance counter from the initial vertex to the vertex p.

2/28/2005Tucker, Sec Dijkstra’s Algorithm Cont. Step 2 – check each edge e=(p,q) from some labeled vertex p to some unlabeled vertex q. Suppose p’s label are (r, d(p)). If d(p)+k(e)=m, label q with (p,m). Try m=1 d(a) =0 k(a,b)=1 d(a)+k(a,b)= 1 = m so we can label b with (a,1) a (-,0) b c de f g h (a,1) Note: if all sums d(p)+k(e) in Step 2 have values of at least m’>m, then the distance counter m should be increased immediately to m’

2/28/2005Tucker, Sec Dijkstra’s Algorithm Cont. Step 3 – If all vertices are not yet labeled, increment m by 1 and go to Step 2. Otherwise, go to Step 4. If we are only interested in the shortest path to z, then we go to Step 4 when z is labeled.

2/28/2005Tucker, Sec Dijkstra’s Algorithm Cont. For m=2 and m=3, no new labeling can be done. Try m=4 d(b) =1 k(b,c)=3 d(b)+k(b,c)= 4 = m so we can label c with (b,4) a (-,0) b c de f g h (a,1) (b,4)

2/28/2005Tucker, Sec Dijkstra’s Algorithm Cont. m=5 no new labeling can be done m=7 no new labeling can be done m=6 d(c) =4 k(c,d)=2 d(b)+k(b,c)= 6 = m so we can label d with (c,6) m=8 d(d) =6 k(d,h)=2 d(d)+k(d,h)= 8 = m so we can label h with (d,8) m=9 no new labeling can be done m=10 d(a) =0 k(a,f)=10 d(b)+k(b,c)= 10 = m so we can label f with (a,10) a (-,0) b c de f g h (a,1) (b,4) (c,6) (d,8) (a,10)

2/28/2005Tucker, Sec Dijkstra’s Algorithm Cont. m=10 d(d) =6 k(d,e)=10 d(d)+k(d,e)= 10 = m so we can label e with (d,10) m=11 no new labeling can be done m=12 d(h) =8 k(h,g)=4 d(h)+k(h,g)= 12 = m so we can label g with (h,12) a (-,0) b c de f g h (a,1) (b,4) (c,6) (d,8) (a,10) (d,10) (h,12)

2/28/2005Tucker, Sec Dijkstra’s Algorithm Cont. Step 4 – For any vertex y, a shortest path from a to y has length d(y), the second label of y. Such a path may be found by backtracking from y (using the first labels).

2/28/2005Tucker, Sec a (-,0) b c de f g h (a,1) Dijkstra’s Algorithm Cont. A shortest path from a to g is a-b-c-d-h-g and its length is 12 (b,4) (c,6) (d,8) (a,10) (d,10) (h,12)

2/28/2005Tucker, Sec Example for the Class Find the shortest path from a to any other point in this graph: ab cd e

2/28/2005Tucker, Sec Solution ab c d e (-,0) (a,1) (a,5)(d,4) (d,5) a to b = 5 (a-b) a to c = 5 (a-d-c) a to d = 1 (a-d) a to e = 4 (a-d-e)