Download presentation
Presentation is loading. Please wait.
Published byBryan Reed Modified over 9 years ago
1
Michael Walker
2
From Maps to Graphs Make Intersections Vertices Make Roads Edges Result is Weighted Directed Graph Weights: Speed Limit Length Tolls, Number of Lanes, Traffic Information
4
Data Structures Queue Stack Priority Queue
5
Queue First In First Out (FIFO) Think checkout line at a store Efficient Addition and removal are constant time
6
Stack First in Last Out (FILO) Alternatively Last in First out (LIFO) Think stack of plates Also efficient Addition and removal are constant time
7
Priority Queue Each element has priority Highest priority removed first
8
Where to Start? Start with finding ANY path Find a spanning tree Algorithm Idea: From start, create tree going outwards Depth First Search Breadth First Search Shortest Edge First (Prim’s Algorithm)
9
Depth First Search (DFS) Continue down one path until reaching a “dead end” Then backtrack and choose a different path Programmatically: Remove vertex from stack, set as “current vertex” Add current vertex to spanning tree if it not present (if present skip next step) Add adjacent vertices to stack if not in tree
11
Breadth First Search (DFS) Explore all paths in order of # of edges Programmatically: Remove vertex from queue, set as “current vertex” Add current vertex to spanning tree if it not present (if present skip next step) Add adjacent vertices to queue if not in tree
13
Prim’s Algorithm Shortest Edge First Creates Minimal Spanning Tree Spanning tree with the lowest possible sum of the edge weights Uses Priority Queue Instead of highest removed, lowest is removed
14
.4.1.05.1.3.4.2.05.025.1.3.1.2.1
15
Kruskal’s Algorithm Also finds minimum spanning tree Builds a forest that forms a tree Algorithm: Select smallest unprocessed edge If two vertices are not part of the same tree, then add edge to forest Repeat until all vertices are in forest
16
.4.1.05.1.3.4.2.05.025.1.3.1.2.1
17
Dijkstra’s Algorithm Resembles Prim’s Algorithm Total cost is used instead of edge cost Tentative costs are maintained and updated Algorithm Loop: Vertex with next lowest tentative distance is “current” vertex. For vertices adjacent to current vertex ○ Compare tentative distance to current vertex distance + edge ○ If new distance is lower, replace tentative distance Add current vertex to spanning tree.
18
.4.1.05.1.3.4.2.05.025.1.3.1.2.1 Board Example
19
A* Algorithm Improvement to Dijkstra’s Algorithm Roadmaps are not abstract mathematical constructions Possible to add heuristic from real world Heuristic Conditions: Must only underestimate, never overestimate Overestimation runs faster, but produces non optimal paths
20
A* Algorithm Algorithm Loop: Vertex with next lowest tentative distance + heuristic distance is “current” vertex. For vertices adjacent to current vertex ○ Compare tentative distance to current vertex distance + edge ○ If new distance is lower, replace tentative distance Add current vertex to spanning tree.
21
A* Web Examples http://www.vision.ee.ethz.ch/~cvcourse/ast ar/AStar.html http://www.vision.ee.ethz.ch/~cvcourse/ast ar/AStar.html http://cadapplets.lafayette.edu/AStarRouter /AStarRouter.html http://cadapplets.lafayette.edu/AStarRouter /AStarRouter.html http://www.stefan- baur.de/cs.web.mashup.pathfinding.html http://www.stefan- baur.de/cs.web.mashup.pathfinding.html
22
Further Exploration Bi-Directional Search Simultaneously run A* from both start and end Reduce Dataset: Multi-Leveled Maps One graph for large cities One graph for county/city level One graph for town/borough level Google seamlessly does this with shortcuts Multi-point and simultaneous path finding Incomplete data path finding (D*)
23
References Johnsonbaugh, Richard, and Marcus Schaefer. Algorithms. Upper Saddle River, NJ: Pearson Education, 2004. Print. Khuller, Samir, Balaji Raghavachari, and Neal Young. "Balancing Minimum Spanning and Shortest Path Trees." 243-50. Web. 29 Apr. 2011.. Kruskal, Joseph B. "On The Shortest Spanning Subtree Of A Graph And The Traveling Salesman Problem." AMS Journal (1955). Web. 29 Apr. 2011.. Patel, Amit J. "Amit’s Game Programming Information." Amit’s Patel's Personal Website. Stanford, 2010. Web. 29 Apr. 2011.. Prim, R. C. "Shortest Connection Networks And Some Generalizations." (1957): 1389-401. Web. 29 Apr. 2011.. Sanders, Peter. "Fast Route Planning." Google Tech Talk. 23 Mar. 2009. Lecture.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.