Multi-Source Shortest Paths T. Patrick Bailey CSC 5408 Graph Theory 4/28/2008.

Slides:



Advertisements
Similar presentations
1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 19 Prof. Erik Demaine.
Advertisements

Design and Analysis of Algorithms Single-source shortest paths, all-pairs shortest paths Haidong Xue Summer 2012, at GSU.
§2 Topological Sort 〖 Example 〗 Courses needed for a computer science degree at a hypothetical university How shall we convert this list into a graph?
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
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.
Discussion #36 Spanning Trees
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.
Graph Algorithms: Part 1
Graphs & Graph Algorithms 2 Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
1 Advanced Algorithms All-pairs SPs DP algorithm Floyd-Warshall alg.
Shortest path algorithm. Introduction 4 The graphs we have seen so far have edges that are unweighted. 4 Many graph situations involve weighted edges.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Nondecreasing Paths in Weighted Graphs Or: How to optimally read a train schedule Virginia Vassilevska.
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.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
The Shortest Path Problem
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Graphs.
1 Shortest Path Calculations in Graphs Prof. S. M. Lee Department of Computer Science.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Networks and the Shortest Path Problem.  Physical Networks  Road Networks  Railway Networks  Airline traffic Networks  Electrical networks, e.g.,
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Graph Theory Topics to be covered:
COSC 2007 Data Structures II Chapter 14 Graphs III.
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.
Linear Programming Data Structures and Algorithms A.G. Malamos References: Algorithms, 2006, S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani Introduction.
Shortest Path Problem Weight of the graph –Nonnegative real number assigned to the edges connecting to vertices Weighted graphs –When a graph.
Graphs Data Structures and Algorithms A. G. Malamos Reference Algorithms, 2006, S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani Introduction to Algorithms,Third.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Kruskal’s and Dijkstra’s Algorithm.  Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted.
Shortest Path Graph Theory Basics Anil Kishore.
CSE 2331 / 5331 Topic 12: Shortest Path Basics Dijkstra Algorithm Relaxation Bellman-Ford Alg.
Shortest Path Algorithms. Definitions Variants  Single-source shortest-paths problem: Given a graph, finding a shortest path from a given source.
Graph Algorithms. Graph Algorithms: Topics  Introduction to graph algorithms and graph represent ations  Single Source Shortest Path (SSSP) problem.
Shortest Paths CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Spanning Trees. A spanning tree for a connected, undirected graph G is a graph S consisting of the nodes of G together with enough edges of G such that:
The all-pairs shortest path problem (APSP) input: a directed graph G = (V, E) with edge weights goal: find a minimum weight (shortest) path between every.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
Graph Introduction, Searching Graph Theory Basics - Anil Kishore.
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Consultant Presentation Group B5. Presentation Outline Introduction How to design by Group A5 Future Data Structure Interface Future Conclusion.
Introduction to Graph Theory Lecture 17: Graph Searching Algorithms.
DYNAMICALLY COMPUTING FASTEST PATHS FOR INTELLIGENT TRANSPORTATION SYSTEMS MEERA KRISHNAN R.
Introduction to Algorithms All-Pairs Shortest Paths My T. UF.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
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.
DECISION 1. How do you do a Bubble Sort? Bubble Sort:  You compare adjacent items in a list;  If they are in order, leave them.  If they are not in.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
Graphs David Kauchak cs302 Spring Admin HW 12 and 13 (and likely 14) You can submit revised solutions to any problem you missed Also submit your.
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
Minimum Spanning Tree Graph Theory Basics - Anil Kishore.
Randomized Min-Cut Algorithm
Shortest Path from G to C Using Dijkstra’s Algorithm
Spanning Trees.
Refresh and Get Ready for More
Graphs & Graph Algorithms 2
TransCAD Vehicle Routing 2018/11/29.
Graphs Chapter 11 Objectives Upon completion you will be able to:
CSE 373 Data Structures and Algorithms
Graph Searching.
CSE 373: Data Structures and Algorithms
Graphs.
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Presentation transcript:

Multi-Source Shortest Paths T. Patrick Bailey CSC 5408 Graph Theory 4/28/2008

Inspiration Using the public transit system in the Denver metro area (RTD) I discovered a problem. The web based tools put in place to assist patrons in finding the shortest path to their destination is limited. In its current implementation it only can search for a shortest path given a single start time or a single end time.

Inspiration (cont) I and many other professional workers are not bound by a tight work schedule, our work hours can “float”. Given this situation a more ideal search would be to find the shortest path over a given time (from 7:00AM to 9:00 AM) rather then from a fixed time. This search would give us the shortest trip time to our destination.

The Graph To help understand what a shortest path is in a mass Transit Graph we need to understand what a node in such a graph represents and how the entire graph is formed.

First we need to convert routes into individual paths. Here is an example of a route where each node representing a location (a bus stop) A BD E C Here we can see a bus route that goes from location A to B, C, D, and finally E. But this graph represents a route path. What we need is a graph representing each unique bus path over time.

A BD E C 10:00 AM A 10:00 AM B 10:30AM D 11:00 AM E 11:45 AM C 10:45 AM 1:00 PM A 1:00 PM B 1:30PM D 2:00 PM E 2:45 PM C 1:45 PM This Route Path needs to be converted into individual bus paths.

We turn the entire transit system into individual bus paths. The nodes in this graph represent a time and location

Then connect them up (Details Beyond the scope of this talk)

Weights are assigned to each edge (The time difference between nodes) 10:00 AM A 10:00 AM B 10:30AM D 11:00 AM E 11:45 AM C 10:45 AM 11:00 AM A 1:00 PM B 11:30 AM D 12:00 PM E 12:45 PM C 11:45 AM

We now have a graphical representation of the transit system with weights. “ The Transit Graph” Now what do we do with it?

As a commuter we want to find the shortest path (time) over some range of time. First we Find Nodes on the Transit Graph which are near our start location Ex. within 1 mile from 7:00 AM – 9:00 AM These are our Source Nodes To Do This

Next we Find Nodes on the Transit Graph which are near our destination Within 1 mile from 7:00 AM – 11:00 AM

So here is the problem. How do we find the shortest path from multiple Source Nodes to multiple Destination Nodes Source Nodes Destination Nodes

Several Types of Solutions “Single Source Shortest Path” (SSSP) - This type of solution can only find the shortest path from a single source. We can use it though, by simply running it once per source and comparing the results to each other and choosing the best result. “All Pairs Shortest Paths” (APSP)- This type of solution gives us more then what we need. As it gives the shortest path between all pairs of vertices in a graph.

Djikstra’s Algorithm [D59] A SSSP solution Type - “Single Source Shortest Path” Runtime- O (|V| 2 ) (converted to a MSSP O (|V| 3 )) Input- A weighted connected graph G whose edge weights are non-negative. Output- A spanning Tree of G whose root is your source node S. Any path on this tree from S to any other node is a shortest path to that node.

Djikstra’s Algorithm Example Here is our weighted Graph with no negative weight edges First we find all frontier edges Then we select the edge with the smallest overall weight and add that edge and vertice to our spanning Tree Then we again find all frontier edges We keep repeating this process until we have a Spanning Tree S

Djikstra spanning Tree S

An Idea Converting our MSSP to a SSSP In my bus problem all edge weights are > 0. Therefore we can easily convert the “Multi-Source Shortest Path” to a “Single-Source Shortest Path” by linking the all source nodes to a single source node with 0 weight edges. And we can do the same for the destination node.

Turning it into a Single Source Problem ( And saving us O (|V|) in runtime ) Source Nodes Destination Nodes

Advantages- Its faster It gets the fastest path without need for comparing the sets of fastest paths between node Once we find a path to our destination we can stop since we know it’s a fastest path. Disadvantages- We lose information, perhaps we want to know the fastest 10 paths. We lose that information.

“All Pairs Shortest Paths” (APSP) There are many algorithms for solving the APSP. Due to time constraint I will only show Min-Plus Product and if time allows the Technique of Repeated Squaring.

Min-Plus Product Type - “All Pairs Shortest Path” Runtime- Input- A weighted connected graph G which contains now negative weight cycles. Output- A Matrix Showing Weight of shortest path (we can store a path along the way)

Min-Plus Product First create a matrix representing the weights between edges. This graph represents Where m represents the longest path

Min-Plus Product What we need is Since the shortest path between any two vertices on graph is n-1 This runs in Since this equation needs (m-1) the prior matrix. We need each matrix along the way we need 1,2,3… n-1 For an overall runtime of

Technique of Repeated Squaring. Type - “All Pairs Shortest Path” Runtime- Input- A weighted connected graph G which contains now negative weight cycles. Output- A Matrix Showing Weight of shortest path (we can store a path along the way)

Technique of Repeated Squaring. The Min-Plus Product can be altered slightly to make it run faster. First of all all we care about is finding Second anywhere m > n-1 matches n-1.

Technique of Repeated Squaring. As it turns out So we can square it we can get 1, 2, 4, 8 which may in some cases be larger then n-1 but that is fine since any matrix larger then n-1 is identical to n-1.

Chan O (n 3 /logn) Type - “All Pairs Shortest Path” Runtime- O (n 3 /logn) Input- Weighted Directed Graph Output- (Still trying to figure that one out)

Questions?

Bibliography: [D59]E. W. Dijkstra A Note on two Problems in Connection with Graphs. Numerical Mathematics, 1(5): , 1959 [C08] Timothy M. Chan All-Pairs Shortest Paths with Real Weights in O (n 3 /logn) Time. Algorithmica 2(50): , 2008 [CLR07]Thomas H. Cormen, Charles E. Leiserson, Ronald L Rivest, and Clifford Stein. Introduction to Algorithms 2 nd Edition 2007.