Shortest Path Problems

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Shortest Paths Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 9.6 Based on slides from Chuck Allison, Michael T.
Breadth-First Search Seminar – Networking Algorithms CS and EE Dept. Lulea University of Technology 27 Jan Mohammad Reza Akhavan.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
1 Chapter 15.3 Hamilton Paths and Hamilton Circuits Objectives 1.Understand the definitions of Hamilton paths & Hamilton circuits. 2.Find the number of.
Management Science 461 Lecture 2b – Shortest Paths September 16, 2008.
Applied Discrete Mathematics Week 12: Trees
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
CSC 213 Lecture 23: Shortest Path Algorithms. Weighted Graphs Each edge in weighted graph has numerical weight Weights can be distances, building costs,
Let us switch to a new topic:
TECH Computer Science Graph Optimization Problems and Greedy Algorithms Greedy Algorithms  // Make the best choice now! Optimization Problems  Minimizing.
Ch. 11: Optimization and Search Stephen Marsland, Machine Learning: An Algorithmic Perspective. CRC 2009 some slides from Stephen Marsland, some images.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The distance.
Shortest Path Problems Dijkstra’s Algorithm TAT ’01 Michelle Wang.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
Copyright © Cengage Learning. All rights reserved.
SPANNING TREES Lecture 21 CS2110 – Spring
Graph Theory Hamilton Paths and Hamilton Circuits.
May 1, 2002Applied Discrete Mathematics Week 13: Graphs and Trees 1News CSEMS Scholarships for CS and Math students (US citizens only) $3,125 per year.
6.1 Hamilton Circuits and Paths: Hamilton Circuits and Paths: Hamilton Path: Travels to each vertex once and only once… Hamilton Path: Travels to each.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Shortest Path Problems Dijkstra’s Algorithm. Introduction Many problems can be modeled using graphs with weights assigned to their edges: Airline flight.
Graphs Discrete Structure CS203. Adjacency Matrix We already saw a way of representing relations on a set with a Boolean matrix: R digraph(R) M R1234.
Shortest Paths Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 8.6 Based on slides from Chuck Allison, Michael T.
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
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.
Graphs 1 Neil Ghani University of Strathclyde. Where are we …. We studied lists: * Searching and sorting a list Then we studied trees: * Efficient search.
Hamilton Paths and Hamilton Circuits
Weighted Graphs and traveling Salesperson problem
Applied Discrete Mathematics Week 15: Trees
EECS 203 Lecture 19 Graphs.
Minimum Spanning Trees
Let us switch to a new topic:
SULE SOLMAZ BEYZA AYTAR
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Graphs Slides are adopted from “Discrete.
EECS 203 Lecture 20 More Graphs.
Chapter 2: Business Efficiency Lesson Plan
Topological Sort (topological order)
Graphs.
Chapter 2: Business Efficiency Lesson Plan
Graph Algorithm.
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Discrete Mathematics and Its Applications (5th Edition)
Minimum Spanning Trees
Graph Theory.
Graphs Chapter 13.
Genome Assembly.
Foundations of Discrete Mathematics
Shortest Path.
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Chapter 2: Business Efficiency Business Efficiency
Graphs Discrete Structure CS203.
Shortest Path Algorithms
Discrete Mathematics and Its Applications (5th Edition)
Discrete Mathematics Lecture 13_14: Graph Theory and Tree
And the Final Subject is…
Chapter 6 Network Flow Models.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
離散數學 DISCRETE and COMBINATORIAL MATHEMATICS
CS 584 Project Write up Poster session for final Due on day of final
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Weighted Graphs & Shortest Paths
Hamilton Paths and Hamilton Circuits
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Shortest Paths Discrete Mathematics and Its Applications (8th Edition)
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Presentation transcript:

Shortest Path Problems We can assign weights to the edges of graphs, for example to represent the distance between cities in a railway network: Chicago Toronto New York Boston 600 700 200 650 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Shortest Path Problems Such weighted graphs can also be used to model computer networks with response times or costs as weights. One of the most interesting questions that we can investigate with such graphs is: What is the shortest path between two vertices in the graph, that is, the path with the minimal sum of weights along the way? This corresponds to the shortest train connection or the fastest connection in a computer network. May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Dijkstra’s algorithm is an iterative procedure that finds the shortest path between to vertices a and z in a weighted graph. It proceeds by finding the length of the shortest path from a to successive vertices and adding these vertices to a distinguished set of vertices S. The algorithm terminates once it reaches the vertex z. May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices a = v0, v1, …, vn = z and positive weights w(vi, vj), where w(vi, vj) =  if {vi, vj} is not an edge in G) for i := 1 to n L(vi) :=  L(a) := 0 S :=  {the labels are now initialized so that the label of a is zero and all other labels are , and the distinguished set of vertices S is empty} May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm while zS begin u := the vertex not in S with minimal L(u) S := S{u} for all vertices v not in S if L(u) + w(u, v) < L(v) then L(v) := L(u) + w(u, v) {this adds a vertex to S with minimal label and updates the labels of vertices not in S} end {L(z) = length of shortest path from a to z} May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Example: a b d z e c   5 6 4 8 1 2 3  2 10   Step 0 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Example: a b d z e c 4 2 1 5 8 10 6 3  4 (a)   2 (a)   Step 1 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Example: a b d z e c 4 2 1 5 8 10 6 3  4 (a) 3 (a, c)  10 (a, c)  2 (a)  12 (a, c)  Step 2 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Example: a b d z e c 4 2 1 5 8 10 6 3  4 (a) 3 (a, c)  8 (a, c, b) 10 (a, c)   2 (a) 12 (a, c)  Step 3 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Example: a b d z e c 4 2 1 5 8 10 6 3 3 (a, c)  4 (a)  8 (a, c, b) 10 (a, c)  14 (a, c, b, d) 2 (a)   12 (a, c) 10 (a, c, b, d) Step 4 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Example: a b d z e c 4 2 1 5 8 10 6 3 3 (a, c)  4 (a)  8 (a, c, b) 10 (a, c)  14 (a, c, b, d) 13 (a, c, b, d, e)  2 (a)  12 (a, c) 10 (a, c, b, d) Step 5 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

Applied Discrete Mathematics Week 15: Trees Dijkstra’s Algorithm Example: a b d z e c 4 2 1 5 8 10 6 3 3 (a, c)  4 (a)  8 (a, c, b) 10 (a, c)  14 (a, c, b, d) 13 (a, c, b, d, e)  2 (a)  12 (a, c) 10 (a, c, b, d) Step 6 May 2, 2017 Applied Discrete Mathematics Week 15: Trees

The Traveling Salesman Problem The traveling salesman problem is one of the classical problems in computer science. A traveling salesman wants to visit a number of cities and then return to his starting point. Of course he wants to save time and energy, so he wants to determine the shortest path for his trip. We can represent the cities and the distances between them by a weighted, complete, undirected graph. The problem then is to find the circuit of minimum total weight that visits each vertex exactly once. May 2, 2017 Applied Discrete Mathematics Week 15: Trees

The Traveling Salesman Problem Example: What path would the traveling salesman take to visit the following cities? Chicago Toronto New York Boston 600 700 200 650 550 Solution: The shortest path is Boston, New York, Chicago, Toronto, Boston (2,000 miles). May 2, 2017 Applied Discrete Mathematics Week 15: Trees

The Traveling Salesman Problem Question: Given n vertices, how many different cycles Cn can we form by connecting these vertices with edges? Solution: We first choose a starting point. Then we have (n – 1) choices for the second vertex in the cycle, (n – 2) for the third one, and so on, so there are (n – 1)! choices for the whole cycle. However, this number includes identical cycles that were constructed in opposite directions. Therefore, the actual number of different cycles Cn is (n – 1)!/2. May 2, 2017 Applied Discrete Mathematics Week 15: Trees

The Traveling Salesman Problem Unfortunately, no algorithm solving the traveling salesman problem with polynomial worst-case time complexity has been devised yet. This means that for large numbers of vertices, solving the traveling salesman problem is impractical. In these cases, we can use approximation algorithms that determine a path whose length may be slightly larger than the traveling salesman’s path, but can be computed with polynomial time complexity. For example, artificial neural networks can do such an efficient approximation task. May 2, 2017 Applied Discrete Mathematics Week 15: Trees