The Shortest Path Problem

Slides:



Advertisements
Similar presentations
Decision Maths Dijkstra’s Algorithm.
Advertisements

 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,
CS 206 Introduction to Computer Science II 04 / 01 / 2009 Instructor: Michael Eckmann.
Graph Theory Arnold Mesa. Basic Concepts n A graph G = (V,E) is defined by a set of vertices and edges v3 v1 v2Vertex (v1) Edge (e1) A Graph with 3 vertices.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
DIJKSTRA’s Algorithm. Definition fwd search Find the shortest paths from a given SOURCE node to ALL other nodes, by developing the paths in order of increasing.
The Greedy Approach Chapter 8. The Greedy Approach It’s a design technique for solving optimization problems Based on finding optimal local solutions.
Chapter 4 The Greedy Approach. Minimum Spanning Tree A tree is an acyclic, connected, undirected graph. A spanning tree for a given graph G=, where E.
Design and Analysis of Algorithms Single-source shortest paths, all-pairs shortest paths Haidong Xue Summer 2012, at GSU.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
Breadth-First Search Seminar – Networking Algorithms CS and EE Dept. Lulea University of Technology 27 Jan Mohammad Reza Akhavan.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Management Science 461 Lecture 2b – Shortest Paths September 16, 2008.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
1 Spanning Trees Lecture 20 CS2110 – Spring
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Lecture 19: Shortest Paths Shang-Hua Teng. Weighted Directed Graphs Weight on edges for distance
The Stagecoach Problem
CS 206 Introduction to Computer Science II 11 / 10 / 2008 Instructor: Michael Eckmann.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
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.
Shortest path algorithm. Introduction 4 The graphs we have seen so far have edges that are unweighted. 4 Many graph situations involve weighted edges.
Dijkstra’s Shortest Paths CS 312 Lecture 4. Announcements Project 1 comes out Friday –Min spanning trees and scheduling –due 2 weeks from Friday (1 week.
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.
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
1 Shortest Path Calculations in Graphs Prof. S. M. Lee Department of Computer Science.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Copyright © Cengage Learning. All rights reserved.
Chapter 4: Finding the Shortest Path Lesson 1: Dijkstra’s Algorithm
Shortest Path. Dijkstra’s Algorithm finds the shortest path from the start vertex to every other vertex in the network. We will find the shortest path.
1 Shortest Path Problem Topic 11 ITS033 – Programming & Algorithms C B A E D F Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program,
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
COSC 2007 Data Structures II Chapter 14 Graphs III.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Prims’ spanning tree algorithm Given: connected graph (V, E) (sets of vertices and edges) V1= {an arbitrary node of V}; E1= {}; //inv: (V1, E1) is a tree,
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.
CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is meant by weighted graphs  Where weights placed within Graph  How to use Graph ’s.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Decision Maths 1 Shortest path algorithm Dijkstra’s Algorithm A V Ali :
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
1 Assignment #3 is posted: Due Thursday Nov. 15 at the beginning of class. Make sure you are also working on your projects. Come see me if you are unsure.
CSE 421 Algorithms Richard Anderson Lecture 8 Optimal Caching Dijkstra’s algorithm.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 10.
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.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
CSE 373: Data Structures and Algorithms Lecture 21: Graphs V 1.
Minimum Spanning Trees
Graph Algorithms BFS, DFS, Dijkstra’s.
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Shortest Path Graph represents highway system Edges have weights
Graph Algorithm.
Minimum Spanning Trees
Decision Maths Dijkstra’s Algorithm.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Shortest Path.
Shortest Path.
CSE 373: Data Structures and Algorithms
Shortest Path Algorithms
Chapter 4: Finding the Shortest Path Lesson 1: Dijkstra’s Algorithm
Networks Kruskal’s Algorithm
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Shortest Path.
CSE 373 Data Structures and Algorithms
Graphs.
CSE 417: Algorithms and Computational Complexity
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Minimum Spanning Trees
Presentation transcript:

The Shortest Path Problem Dijkstra’s Algorithm Graph Theory Applications

With each edge e of G let there be associated Foundation With each edge e of G let there be associated a real number w(e), called its weight. Then G, together with these weights on its edges, is called a weighted graph. Weighted graphs occur frequently in applications of graph theory. In the friendship graph, for example, weights might indicate intensity of friendship; in communications graph they could represent the construction or maintenance of the various communications links.

If H is a subgraph of a weighted graph, the weight w(H) of H is the sum of the weights on its edges. Many optimization problems amount to finding, in a weighted graph, a subgraph of a certain type with minimum (or maximum) weight. One such is the shortest path problem: given a railway network connecting various towns, determine a shortest route between two specified towns in the network.

Here we must find, in a weighted graph, a path of minimum weight connecting two specified vertices u0 and v0 ; the weights represent distances by rail between directly- linked towns, and therefore non-negative. The path indicated in the next figure is a (u0 , v0) -path of minimum weight.

1 2 b c d 9 9 7 5 3 2 6 8 1 8 2 a e f g h 4 1 7 2 1 4 1 i j k 9 1 Shortest Path: d(a,h)= 12

For clarity of exposition, we shall refer to the weight of a path in a weighted graphs as its length; similarly the minimum weight of a (u , v)-path will be called the distance between u and v and denoted by d(u , v). We shall assume here that G is simple, and all weights are positive. We adopt the convention that w(uv) =  if uv  E.

The algorithm to be described was discovered by Dijkstra (1959) The algorithm to be described was discovered by Dijkstra (1959). It finds not only the shortest (u0 , v0)-path, but shortest paths from u0 to all other vertices in the graph (G).

Basic Idea The algorithm uses two sets of vertices, S and C. At every moment the set S contains those nodes that have already been chosen; as we shall see, the minimal distance from the source is already known for every node is S. The set C contains all the other nodes, whose minimal distance from the source is not known, and which are candidates to be chosen at some later stage. When the algorithm stops, S contains all the vertices of the graph and our problem is solved. At each step we choose the node in C whose distance to the source is least, and add it to S.

Dijkstra’s Shortest Path Algorithm l(v) - label of the vertex v 1. Set l(u0) = 0, l(v) =  for v  u0, S0 ={u0} and i = 0. 2. For each v not in Si, replace l(v) by min{l(v) , l(ui) + w(ui,v)}. Compute the minimum of the vertices not in Si and let ui+1 denote a vertex for which this minimum is attained. Set Si{ui+1}. 3. If i is one less than the number of vertices in a graph, stop. If i < v -1, replace i by i++ go to step 2.

Example 4 We begin at vertex 0 and modify the labels of the adjacent vertices. 1 1 3 1 2 1 2 3 4 - Ø 2 2 1 2 3 3

1 2 3 4 - Ø 4 1 1 3 1 2 2 2 1 2 3 3

1 2 3 4 - Ø 4 1 1 3 1 2 2 2 1 2 3 3

1 2 3 4 - Ø 4 1 1 3 1 2 2 2 1 2 3 3

1 2 3 4 - Ø 4 1 2 3 Shortest path from d(0,4) = 2 Path is: 0,1,4 1 1 3 1 2 3 4 - Ø 4 1 1 3 1 2 2 2 1 2 3 3 Shortest path from d(0,4) = 2 Path is: 0,1,4