Tutorial 8 An optional eighth tutorial will be held the week of March 6. This tutorial will give you practice with and feedback on oral presentation and.

Slides:



Advertisements
Similar presentations
Problem solving with graph search
Advertisements

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.
CSE 380 – Computer Game Programming Pathfinding AI
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.
Breadth-First Search Graph Algorithm Type #3. Depth-First Search.
Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.
B.A. (Mahayana Studies) Introduction to Computer Science November March What is a Computer? An overview of what a computer is, the.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
Route Planning Vehicle navigation systems, Dijkstra’s algorithm, bidirectional search, transit-node routing.
Administrative Stuff ECE 297. Administration Milestone 0: –Submit by Friday at 5 pm –Demo in lab this week –Write your name on the board when ready to.
Chocolate Bar! luqili. Milestone 3 Speed 11% of final mark 7%: path quality and speed –Some cleverness required for full marks –Implement some A* techniques.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Milestone 3: Finding Routes ECE 297. Directions: How?
Fundamentals, Terminology, Traversal, Algorithms Graph Algorithms Telerik Algo Academy
Representing and Using Graphs
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
CSE 486/586 CSE 486/586 Distributed Systems Graph Processing Steve Ko Computer Sciences and Engineering University at Buffalo.
Mapping City Wide Travel Times Andrew Hardin. Project Goal Encouraging alternate transportation – NYC- Bike Share – Boulder’s Transportation Management.
Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.
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.
Fundamental Data Structures and Algorithms (Spring ’05) Recitation Notes: Graphs Slides prepared by Uri Dekel, Based on recitation.
Another dynamic program %...*..*..*% % % %*..*******% %*.*.***.*.% Q: What is the shortest path that delivers papers.
Week 8 - Wednesday.  What did we talk about last time?  Level order traversal  BST delete  2-3 trees.
Graphs, Continued ECE 297.
NETWORK FLOWS Shruti Aggrawal Preeti Palkar. Requirements 1.Implement the Ford-Fulkerson algorithm for computing network flow in bipartite graphs. 2.For.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: Graphs Data Structures.
INTRO2CS Tirgul 13 – More GUI and Optimization. Today:  GUI  Packing  Events  Canvas  OptionMenu  Optimization  Traveling Sales Man  Questions.
Graphs. What is a graph? In simple words, A graph is a set of vertices and edges which connect them. A node (or vertex) is a discrete position in the.
More Graphics. Hit Testing Mouse clicked here What did I click on?
Graphs ORD SFO LAX DFW Graphs 1 Graphs Graphs
Breadth-First Search Graph Algorithm Type #3.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
COMP 261 Lecture 2 Graphs 1 of 3.
Graphs Chapter 15 introduces graphs which are probably the most general and commonly-used data structure. This lecture introduces heaps, which are used.
Measuring Where CPU Time Goes
Graphs Representation, BFS, DFS
Depth First Seach: Output Fix
CS1022 Computer Programming & Principles
Week 6 - Wednesday CS 113.
Breadth-First Search: Complexity
Ch 13 WAN Technologies and Routing
Algorithms Detour - Shortest Path
Administrative Items ECE 297.
Lesson Objectives Aims Understand the following “standard algorithms”:
CPU Efficiency Issues.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Data Structures and Algorithms for Information Processing
Graph Theory.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Search Related Algorithms
Loops CIS 40 – Introduction to Programming in Python
Selection Insertion and Merge
Chapter 11 Graphs.
CMSC201 Computer Science I for Majors Lecture 25 – Final Exam Review
CSE 421: Introduction to Algorithms
Milestone 3: Finding Routes
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
Mental Health and Wellness Resources
Breadth-First Search Graph Algorithm #2.
Min Heap Update E.g. remove smallest item 1. Pop off top (smallest) 3
Trevor Brown DC 2338, Office hour M3-4pm
Efficiently Estimating Travel Time
BFS: Min. Path Issues What happened? Node 1 was re-expanded
Graphs: Shortest path and mst
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
Presentation transcript:

Tutorial 8 An optional eighth tutorial will be held the week of March 6. This tutorial will give you practice with and feedback on oral presentation and slide design. If possible, bring your laptop with any slides you are developing for your presentation. Monday, March 6: 1-2pm; 2-3pm (GB304) Wednesday, March 8: 9-10am; 10-11am (BA1180) Thursday, March 9: 3-4pm; 4-5pm (GB304)

Milestone 3: Finding Routes ECE 297

Milestone 3 Overview Find shortest travel time routes Between two intersections From intersection to point of interest e.g. Tim Horton’s with minimum travel time 13% of final mark 8% algorithm (automarked) Find some path? Find shortest travel time path? Find it with low CPU time? 4% user interface (TA demo) 1% code style

Milestone 3 UI User Interface: 4% Requirements Can click on two intersections  find path Can enter intersection/POI names  find path Visualize path in UI Print or draw travel directions Have help button or command Optional Bonus: up to +1%: Support partial name matches E.g. Yong  might complete as Yonge Street

Milestone 3 UI Usability matters Travel directions: Try it on a friend or family member! Can he/she enter intersections without lots of pain? Can he/she follow the travel directions and path display? Travel directions: Directions give info you need from start to finish? Take street segment #21 then street segment #10 … Unbelievably Bad! Take Yonge Street Then Yonge Street Then Bloor Street Still bad!

Planning Most teams find milestone 3 hardest Make plan to divide work Start early! Make plan to divide work Too big for complete pair/triplet programming Separate pieces for parallel development? UI: input (text & mouse) UI: output (directions & drawing) Hard code path to test before algorithm working Algorithm Two path searches, quite related Can split code & test Or split some helper functions (needs close comm.)

Algorithmic Approaches

Directions: How?

Model as Graph Problem (Node) (Edge) Bathurst dest source Path: sequence of connected nodes from a source to a dest

Now sequence of nodes doesn’t uniquely describe path Model as Graph Problem Bathurst back lane Now sequence of nodes doesn’t uniquely describe path dest source Path: store as sequence of nodes?

Model as Graph Problem Bathurst dest source Better: sequence of connected edges from a source to a dest

Finding Routes Find path from source to dest Any path? Fewest nodes? Is there only one path? Any path? Fewest nodes? Fewest edges? Minimum travel time! Graph texts: minimum weight path or shortest path dest source

Minimum Travel Time Definition Distance / speed limit + turn_penalty per street change Blue path: 200 m / 40 kmh + 300 m / 50 kmh + 1 turn  18 s + 21.6 s + 15 s = 54.6 s 300 m dest Red path: 100 m / 40 kmh + 200 m / 40 kmh + 200 m / 50 kmh + 2 turns  9 s + 18 s + 14.4 s + 2*15 s = 71.4 s 200 m source 100 m Which is better if turn_penalty = 15s?

Minimum Travel Time Definition Don’t left turns take longer than right turns? Yes, we’re ignoring to keep simple Street change with no turn? Still 15 s No penalty Yonge St. Bloor St. West Bloor St. East 15 s penalty Yonge St.

Other Shortest Path Applications Any Ideas?

Internet Routing Nodes: computers and switches Edges: cables source dest Nodes: computers and switches Edges: cables Find a path to connect computers Typical minimum weight path definition: Fewest routers Or least congested

Circuit Board Design Nodes: small square for metal Edges: squares we can connect Find paths to connect chip I/Os

Integrated Circuits Nodes: small grid squares for metal Edges: squares we can connect Find paths to connect gates Huge graph (tens of millions of nodes)  need fast algorithms

Facebook Entire social network is stored as > billion-node graph Shortest path: how close to knowing someone? Algorithms built on shortest path: social marketing

Shortest Path Algorithm #1 Depth First Search Shortest Path Algorithm #1

Recursion? source dest int main () { Node *sourceNode = getNodebyID (sourceID); bool found = findPath (sourceNode, destID); . . . } bool findPath (Node* currNode, int destID) { ...

Recursion? bool findPath (Node* currNode, int destID) { if (currNode->id == destID) return (true); for each (outEdge of currNode) { Node *toNode = outEdge.toNode; bool found = findPath (toNode, destID); if (found) } return (false); 1 source dest 2 3 4 3

Recursion? Infinite Loop! bool findPath (Node* currNode, int destID) { if (currNode->id == destID) return (true); for each (outEdge of currNode) { Node *toNode = outEdge.toNode; bool found = findPath (toNode, destID); if (found) } return (false); Infinite Loop! source dest

How to Fix? bool findPath (Node* currNode, int destID) { if (currNode->id == destID) return (true); currNode->visited = true; for each (outEdge of currNode) { Node *toNode = outEdge.toNode; if (!toNode->visited) { bool found = findPath (toNode, destID); if (found) } return (false); toNode visited dest source

Output? Says whether or not a path was found But not what the path is! bool findPath (Node* currNode, int destID) { . . . return (true); } Says whether or not a path was found But not what the path is! Worst directions ever: yes, a path exists! How to fix? dest source