Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Multi-Source Shortest Paths T. Patrick Bailey CSC 5408 Graph Theory 4/28/2008."— Presentation transcript:

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

2 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.

3 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.

4 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.

5 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.

6 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.

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

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

9 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 30 45 15 30 15 75

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

11 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

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

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

14 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.

15 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.

16 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

17 Djikstra spanning Tree S

18 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.

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

20 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.

21 “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.

22 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)

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

24 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

25

26 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)

27 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.

28 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.

29

30 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)

31 Questions?

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


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

Similar presentations


Ads by Google