Michael Walker. From Maps to Graphs  Make Intersections Vertices  Make Roads Edges  Result is Weighted Directed Graph  Weights: Speed Limit Length.

Slides:



Advertisements
Similar presentations
Problem solving with graph search
Advertisements

Weighted graphs Example Consider the following graph, where nodes represent cities, and edges show if there is a direct flight between each pair of cities.
10.4 Spanning Trees. Def Def: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every vertex of G See handout.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
3.3 Spanning Trees Tucker, Applied Combinatorics, Section 3.3, by Patti Bodkin and Tamsen Hunter.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
CS171 Introduction to Computer Science II Graphs Strike Back.
Discrete Structures Lecture 13: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Chapter 9: Greedy Algorithms The Design and Analysis of Algorithms.
CS 206 Introduction to Computer Science II 11 / 10 / 2008 Instructor: Michael Eckmann.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 25: Graph Traversal, DAGs, and Weighted Graphs.
Graphs & Graph Algorithms 2 Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Busby, Dodge, Fleming, and Negrusa. Backtracking Algorithm Is used to solve problems for which a sequence of objects is to be selected from a set such.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
© Peter Andreae CS4HS Algorithms Searching for an item in a list Sorting a list Searching for a word in text Analysing Networks.
SPANNING TREES Lecture 21 CS2110 – Spring
Minimum Spanning Trees
COSC 2007 Data Structures II Chapter 14 Graphs III.
Representing and Using Graphs
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Minimum spanning trees Aims: To know the terms: tree, spanning tree, minimum spanning tree. To understand that a minimum spanning tree connects a network.
Graph Traversal BFS & DFS. Review of tree traversal methods Pre-order traversal In-order traversal Post-order traversal Level traversal a bc d e f g hi.
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.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 9 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Fundamental Data Structures and Algorithms (Spring ’05) Recitation Notes: Graphs Slides prepared by Uri Dekel, Based on recitation.
1 Minimum Spanning Trees (some material adapted from slides by Peter Lee, Ananda Guna, Bettina Speckmann)
Minimum Spanning Tree: Prim’s & Kruskal’s Algorithms Presenter: Michal Karpinski.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Lecture 19 Minimal Spanning Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graph Searching CSIT 402 Data Structures II. 2 Graph Searching Methodology Depth-First Search (DFS) Depth-First Search (DFS) ›Searches down one path as.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
The travelling salesman problem Finding an upper bound using minimum spanning trees Find a minimum spanning tree using Prim’s algorithm or Kruskal’s algorithm.
Graphs 1 Neil Ghani University of Strathclyde. Where are we …. We studied lists: * Searching and sorting a list Then we studied trees: * Efficient search.
Graph Search Applications, Minimum Spanning Tree
Shana Norman Dec 11, 2003 Final Project
Shortest Paths and Minimum Spanning Trees
Minimum Spanning Tree Chapter 13.6.
C.Eng 213 Data Structures Graphs Fall Section 3.
Spanning Trees Lecture 21 CS2110 – Fall 2016.
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
Short paths and spanning trees
Minimum Spanning Tree.
Minimum Spanning Tree.
Graphs & Graph Algorithms 2
Shortest Path.
Minimum Spanning Tree Algorithms
Shortest Paths and Minimum Spanning Trees
Chapter 15 Graphs © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Weighted Graphs & Shortest Paths
CSE 417: Algorithms and Computational Complexity
Minimum Spanning Trees (MSTs)
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Prim’s algorithm for minimum spanning trees
Lecture 14 Minimum Spanning Tree (cont’d)
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

Michael Walker

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

Data Structures Queue Stack Priority Queue

Queue  First In First Out (FIFO)  Think checkout line at a store  Efficient Addition and removal are constant time

Stack  First in Last Out (FILO) Alternatively Last in First out (LIFO)  Think stack of plates  Also efficient Addition and removal are constant time

Priority Queue  Each element has priority  Highest priority removed first

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)

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

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

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

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

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.

Board Example

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

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.

A* Web Examples  ar/AStar.html ar/AStar.html  /AStarRouter.html /AStarRouter.html  baur.de/cs.web.mashup.pathfinding.html baur.de/cs.web.mashup.pathfinding.html

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

References  Johnsonbaugh, Richard, and Marcus Schaefer. Algorithms. Upper Saddle River, NJ: Pearson Education, Print.  Khuller, Samir, Balaji Raghavachari, and Neal Young. "Balancing Minimum Spanning and Shortest Path Trees." Web. 29 Apr  Kruskal, Joseph B. "On The Shortest Spanning Subtree Of A Graph And The Traveling Salesman Problem." AMS Journal (1955). Web. 29 Apr  Patel, Amit J. "Amit’s Game Programming Information." Amit’s Patel's Personal Website. Stanford, Web. 29 Apr  Prim, R. C. "Shortest Connection Networks And Some Generalizations." (1957): Web. 29 Apr  Sanders, Peter. "Fast Route Planning." Google Tech Talk. 23 Mar Lecture.