17-Jun-15 Searching in BeeperHunt (Mostly minor variations on old slides)

Slides:



Advertisements
Similar presentations
CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.
Advertisements

Analysis of Algorithms Depth First Search. Graph A representation of set of objects Pairs of objects are connected Interconnected objects are called “vertices.
CSE 373, Copyright S. Tanimoto, 2001 Graphs Graphs 2 Incidence and Adjacency Representing a graph with an adjacency matrix, an incidence matrix,
PSU CS Algorithms Analysis and Design Graphs.
CSE 373 Graphs 1: Concepts, Depth/Breadth-First Search
Graphs - II CS 2110, Spring Where did I leave that book?
1 Dijkstra’s Minimum-Path Algorithm Minimum Spanning Tree CSE Lectures 20 – Intro to Graphs.
Tree Searching. Tree searches A tree search starts at the root and explores nodes from there, looking for a goal node (a node that satisfies certain conditions,
Graph Searching CSE 373 Data Structures Lecture 20.
Graph Search Methods A vertex u is reachable from vertex v iff there is a path from v to u
Graph Search Methods A vertex u is reachable from vertex v iff there is a path from v to u
Breadth-First and Depth-First Search
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 excerpts Graphs (breadth-first-search)
Artificial Intelligence (CS 461D)
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
ALG0183 Algorithms & Data Structures Lecture 20 u unweighted breadth-first search 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks Chapter.
CSE332: Data Abstractions Lecture 16: Topological Sort / Graph Traversals Tyler Robison Summer
CSE332: Data Abstractions Lecture 16: Topological Sort / Graph Traversals Dan Grossman Spring 2010.
State-Space Searches. State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
Spanning Trees.
Spanning Trees. 2 Spanning trees Suppose you have a connected undirected graph Connected: every node is reachable from every other node Undirected: edges.
Graphs.
Graphs. Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Using Search in Problem Solving
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
Alyce Brady CS 510: Computer Algorithms Depth-First Graph Traversal Algorithm.
Using Search in Problem Solving
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CISC220 Fall 2009 James Atlas Nov 13: Graphs, Line Intersections.
Solving problems by searching
Spanning Trees. Spanning trees Suppose you have a connected undirected graph –Connected: every node is reachable from every other node –Undirected: edges.
Depth-First Search Lecture 24 COMP171 Fall Graph / Slide 2 Depth-First Search (DFS) * DFS is another popular graph search strategy n Idea is similar.
State-Space Searches. 2 State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
State-Space Searches.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Tree Searching Breadth First Search Dept First Search.
COSC 2007 Data Structures II Chapter 14 Graphs III.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
A RTIFICIAL I NTELLIGENCE UNIT : 2 Search Techniques.
Graphs. 2 Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
CSE 2331 / 5331 Topic 12: Shortest Path Basics Dijkstra Algorithm Relaxation Bellman-Ford Alg.
COMP261 Lecture 6 Dijkstra’s Algorithm. Connectedness Is this graph connected or not? A Z FF C M N B Y BB S P DDGG AA R F G J L EE CC Q O V D T H W E.
Lecture 3: Uninformed Search
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
1 Directed Graphs Chapter 8. 2 Objectives You will be able to: Say what a directed graph is. Describe two ways to represent a directed graph: Adjacency.
COSC 2007 Data Structures II
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight)
Chapter 05 Introduction to Graph And Search Algorithms.
Source: David Lee Matuszek
Graph Searching CSIT 402 Data Structures II. 2 Graph Searching Methodology Depth-First Search (DFS) Depth-First Search (DFS) ›Searches down one path as.
Brute Force and Exhaustive Search Brute Force and Exhaustive Search Traveling Salesman Problem Knapsack Problem Assignment Problem Selection Sort and Bubble.
Graphs - II CS 2110, Spring Where did David leave that book? 2.
© 2006 Pearson Addison-Wesley. All rights reserved14 B-1 Chapter 14 (continued) Graphs.
Brute Force and Exhaustive Search Brute Force and Exhaustive Search Traveling Salesman Problem Knapsack Problem Assignment Problem Selection Sort and Bubble.
Review Graph Directed Graph Undirected Graph Sub-Graph Spanning Sub-Graph Degree of a Vertex Weighted Graph Elementary and Simple Path Link List Representation.
Spanning Trees.
Graphs.
Tree Searching.
Tree Searching.
Tree Searching.
Tree Searching.
Graphs.
Graphs.
State-Space Searches.
Graphs.
State-Space Searches.
Graphs.
State-Space Searches.
Presentation transcript:

17-Jun-15 Searching in BeeperHunt (Mostly minor variations on old slides)

Shortest path? In the BeeperHunt assignment, there are two “beepers” at all times Your robot has to choose which beeper to go after This may or may not be the closest beeper In any case, once your robot has chosen a beeper, it probably wants to find the shortest path to that beeper The maze is multiply-connected, that is, it’s a graph We have discussed two ways of finding a shortest path in a graph Breadth-first search Dijkstra’s algorithm

Breadth-first searching (in a tree) A breadth-first search (BFS) explores nodes nearest the root before exploring nodes further away For example, after searching A, then B, then C, the search proceeds with D, E, F, G Node are explored in the order A B C D E F G H I J K L M N O P Q J will be found before N LM N OP G Q H J IK FED BC A

How to do breadth-first searching Put the root node on a queue; while (queue is not empty) { remove a node from the queue; if (node is a goal node) return success; put all children of node onto the queue; } return failure; Just before starting to explore level n, the queue holds all the nodes at level n-1 In a typical tree, the number of nodes at each level increases exponentially with the depth In BeeperHunt, however, it will always be less than the number of cells in the maze—so this will not be a problem Breadth-first search does not automatically give the path to the goal—but that can be fixed

Searching a graph With certain modifications, any tree search technique can be applied to a graph This includes depth-first, breadth-first, depth-first iterative deepening, and other types of searches The difference is that a graph may have cycles We don’t want to search around and around in a cycle To avoid getting caught in a cycle, we must keep track of which nodes we have already explored There are two basic techniques for this: Keep a set of already explored nodes, or Mark the node itself as having been explored Either approach would work fine for BeeperHunt

Dijkstra’s algorithm Dijkstra’s algorithm is designed to find the shortest path in a graph when the edges have unequal costs In a maze, an “edge” is a single step between adjacent maze locations Every step has the same cost Dijkstra’s algorithm would work, but it’s more complicated than we need However, there is one idea in Dijkstra’s algorithm that we can use: Each time we find a (new shortest) path to a node, we set that node to point to it’s predecessor (where we just came from) This trick allows us to reconstruct our path

The End