Graph Traversal

Total Page:16

File Type:pdf, Size:1020Kb

Graph Traversal CSE 373: Graph traversal Michael Lee Friday, Feb 16, 2018 1 Solution: This algorithm is known as the 2-color algorithm. We can solve it by using any graph traversal algorithm, and alternating colors as we go from node to node. Warmup Warmup Given a graph, assign each node one of two colors such that no two adjacent vertices have the same color. (If it’s impossible to color the graph this way, your algorithm should say so). 2 Warmup Warmup Given a graph, assign each node one of two colors such that no two adjacent vertices have the same color. (If it’s impossible to color the graph this way, your algorithm should say so). Solution: This algorithm is known as the 2-color algorithm. We can solve it by using any graph traversal algorithm, and alternating colors as we go from node to node. 2 Problem: What if we want to traverse graphs following the edges? For example, can we... I Traverse a graph to find if there’s a connection from one node to another? I Determine if we can start from our node and touch every other node? I Find the shortest path between two nodes? Solution: Use graph traversal algorithms like breadth-first search and depth-first search Goal: How do we traverse graphs? Today’s goal: how do we traverse graphs? Idea 1: Just get a list of the vertices and loop over them 3 I Determine if we can start from our node and touch every other node? I Find the shortest path between two nodes? Solution: Use graph traversal algorithms like breadth-first search and depth-first search Goal: How do we traverse graphs? Today’s goal: how do we traverse graphs? Idea 1: Just get a list of the vertices and loop over them Problem: What if we want to traverse graphs following the edges? For example, can we... I Traverse a graph to find if there’s a connection from one node to another? 3 I Find the shortest path between two nodes? Solution: Use graph traversal algorithms like breadth-first search and depth-first search Goal: How do we traverse graphs? Today’s goal: how do we traverse graphs? Idea 1: Just get a list of the vertices and loop over them Problem: What if we want to traverse graphs following the edges? For example, can we... I Traverse a graph to find if there’s a connection from one node to another? I Determine if we can start from our node and touch every other node? 3 Solution: Use graph traversal algorithms like breadth-first search and depth-first search Goal: How do we traverse graphs? Today’s goal: how do we traverse graphs? Idea 1: Just get a list of the vertices and loop over them Problem: What if we want to traverse graphs following the edges? For example, can we... I Traverse a graph to find if there’s a connection from one node to another? I Determine if we can start from our node and touch every other node? I Find the shortest path between two nodes? 3 Solution: Use graph traversal algorithms like breadth-first search and depth-first search Goal: How do we traverse graphs? Today’s goal: how do we traverse graphs? Idea 1: Just get a list of the vertices and loop over them Problem: What if we want to traverse graphs following the edges? For example, can we... I Traverse a graph to find if there’s a connection from one node to another? I Determine if we can start from our node and touch every other node? I Find the shortest path between two nodes? 3 Goal: How do we traverse graphs? Today’s goal: how do we traverse graphs? Idea 1: Just get a list of the vertices and loop over them Problem: What if we want to traverse graphs following the edges? For example, can we... I Traverse a graph to find if there’s a connection from one node to another? I Determine if we can start from our node and touch every other node? I Find the shortest path between two nodes? Solution: Use graph traversal algorithms like breadth-first search and depth-first search 3 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: Queue: a, Visited: a, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: a Queue: Visited: a, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: a Queue: b, d, Visited: a, b, d, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: b Queue: d, Visited: a, b, d, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: b Queue: d, c, e, Visited: a, b, d, c, e, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: d Queue: c, e, Visited: a, b, d, c, e, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: d Queue: c, e, f, g, Visited: a, b, d, c, e, f, g, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: c Queue: e, f, g, Visited: a, b, d, c, e, f, g, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: e Queue: f, g, Visited: a, b, d, c, e, f, g, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: e Queue: f, g, h, Visited: a, b, d, c, e, f, g, h, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: f Queue: g, h, Visited: a, b, d, c, e, f, g, h, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: g Queue: h, Visited: a, b, d, c, e, f, g, h, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: g Queue: h, i, Visited: a, b, d, c, e, f, g, h, i, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: h Queue: i, Visited: a, b, d, c, e, f, g, h, i, 4 Breadth-first search (BFS) example search(v): visited = empty set f queue.enqueue(v) visited.add(v) g d a j while (queue is not empty): i curr = queue.dequeue() h for (w : v.neighbors()): e b if (w not in visited): queue.enqueue(w) visited.add(curr) c Current node: i Queue: Visited: a, b, d, c, e, f, g, h, i, 4 2.
Recommended publications
  • Graph Traversals
    Graph Traversals CS200 - Graphs 1 Tree traversal reminder Pre order A A B D G H C E F I In order B C G D H B A E C F I Post order D E F G H D B E I F C A Level order G H I A B C D E F G H I Connected Components n The connected component of a node s is the largest set of nodes reachable from s. A generic algorithm for creating connected component(s): R = {s} while ∃edge(u, v) : u ∈ R∧v ∉ R add v to R n Upon termination, R is the connected component containing s. q Breadth First Search (BFS): explore in order of distance from s. q Depth First Search (DFS): explores edges from the most recently discovered node; backtracks when reaching a dead- end. 3 Graph Traversals – Depth First Search n Depth First Search starting at u DFS(u): mark u as visited and add u to R for each edge (u,v) : if v is not marked visited : DFS(v) CS200 - Graphs 4 Depth First Search A B C D E F G H I J K L M N O P CS200 - Graphs 5 Question n What determines the order in which DFS visits nodes? n The order in which a node picks its outgoing edges CS200 - Graphs 6 DepthGraph Traversalfirst search algorithm Depth First Search (DFS) dfs(in v:Vertex) mark v as visited for (each unvisited vertex u adjacent to v) dfs(u) n Need to track visited nodes n Order of visiting nodes is not completely specified q if nodes have priority, then the order may become deterministic for (each unvisited vertex u adjacent to v in priority order) n DFS applies to both directed and undirected graphs n Which graph implementation is suitable? CS200 - Graphs 7 Iterative DFS: explicit Stack dfs(in v:Vertex) s – stack for keeping track of active vertices s.push(v) mark v as visited while (!s.isEmpty()) { if (no unvisited vertices adjacent to the vertex on top of the stack) { s.pop() //backtrack else { select unvisited vertex u adjacent to vertex on top of the stack s.push(u) mark u as visited } } CS200 - Graphs 8 Breadth First Search (BFS) n Is like level order in trees A B C D n Which is a BFS traversal starting E F G H from A? A.
    [Show full text]
  • Pathfinding in Computer Games
    The ITB Journal Volume 4 Issue 2 Article 6 2003 Pathfinding in Computer Games Ross Graham Hugh McCabe Stephen Sheridan Follow this and additional works at: https://arrow.tudublin.ie/itbj Part of the Computer and Systems Architecture Commons Recommended Citation Graham, Ross; McCabe, Hugh; and Sheridan, Stephen (2003) "Pathfinding in Computer Games," The ITB Journal: Vol. 4: Iss. 2, Article 6. doi:10.21427/D7ZQ9J Available at: https://arrow.tudublin.ie/itbj/vol4/iss2/6 This Article is brought to you for free and open access by the Ceased publication at ARROW@TU Dublin. It has been accepted for inclusion in The ITB Journal by an authorized administrator of ARROW@TU Dublin. For more information, please contact [email protected], [email protected]. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 4.0 License ITB Journal Pathfinding in Computer Games Ross Graham, Hugh McCabe, Stephen Sheridan School of Informatics & Engineering, Institute of Technology Blanchardstown [email protected], [email protected], [email protected] Abstract One of the greatest challenges in the design of realistic Artificial Intelligence (AI) in computer games is agent movement. Pathfinding strategies are usually employed as the core of any AI movement system. This report will highlight pathfinding algorithms used presently in games and their shortcomings especially when dealing with real-time pathfinding. With the advances being made in other components, such as physics engines, it is AI that is impeding the next generation of computer games. This report will focus on how machine learning techniques such as Artificial Neural Networks and Genetic Algorithms can be used to enhance an agents ability to handle pathfinding in real-time.
    [Show full text]
  • Graph Traversal with DFS/BFS
    Graph Traversal Graph Traversal with DFS/BFS One of the most fundamental graph problems is to traverse every Tyler Moore edge and vertex in a graph. For correctness, we must do the traversal in a systematic way so that CS 2123, The University of Tulsa we dont miss anything. For efficiency, we must make sure we visit each edge at most twice. Since a maze is just a graph, such an algorithm must be powerful enough to enable us to get out of an arbitrary maze. Some slides created by or adapted from Dr. Kevin Wayne. For more information see http://www.cs.princeton.edu/~wayne/kleinberg-tardos 2 / 20 Marking Vertices To Do List The key idea is that we must mark each vertex when we first visit it, We must also maintain a structure containing all the vertices we have and keep track of what have not yet completely explored. discovered but not yet completely explored. Each vertex will always be in one of the following three states: Initially, only a single start vertex is considered to be discovered. 1 undiscovered the vertex in its initial, virgin state. To completely explore a vertex, we look at each edge going out of it. 2 discovered the vertex after we have encountered it, but before we have checked out all its incident edges. For each edge which goes to an undiscovered vertex, we mark it 3 processed the vertex after we have visited all its incident edges. discovered and add it to the list of work to do. A vertex cannot be processed before we discover it, so over the course Note that regardless of what order we fetch the next vertex to of the traversal the state of each vertex progresses from undiscovered explore, each edge is considered exactly twice, when each of its to discovered to processed.
    [Show full text]
  • Graph Traversal and Linear Programs October 6, 2016
    CS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016 1 Depth first search 1.1 The Algorithm Besides breadth first search, which we saw in class in relation to Dijkstra's algorithm, there is one other fundamental algorithm for searching a graph: depth first search. To better understand the need for these procedures, let us imagine the computer's view of a graph that has been input into it, in the adjacency list representation. The computer's view is fundamentally local to a specific vertex: it can examine each of the edges adjacent to a vertex in turn, by traversing its adjacency list; it can also mark vertices as visited. One way to think of these operations is to imagine exploring a dark maze with a flashlight and a piece of chalk. You are allowed to illuminate any corridor of the maze emanating from your current position, and you are also allowed to use the chalk to mark your current location in the maze as having been visited. The question is how to find your way around the maze. We now show how the depth first search allows the computer to find its way around the input graph using just these primitives. Depth first search uses a stack as the basic data structure. We start by defining a recursive procedure search (the stack is implicit in the recursive calls of search): search is invoked on a vertex v, and explores all previously unexplored vertices reachable from v. Procedure search(v) vertex v explored(v) := 1 previsit(v) for (v; w) 2 E if explored(w) = 0 then search(w) rof postvisit(v) end search Procedure DFS (G(V; E)) graph G(V; E) for each v 2 V do explored(v) := 0 rof for each v 2 V do if explored(v) = 0 then search(v) rof end DFS By modifying the procedures previsit and postvisit, we can use DFS to solve a number of important problems, as we shall see.
    [Show full text]
  • Graphs, Connectivity, and Traversals
    Graphs, Connectivity, and Traversals Definitions Like trees, graphs represent a fundamental data structure used in computer science. We often hear about cyber space as being a new frontier for mankind, and if we look at the structure of cyberspace, we see that it is structured as a graph; in other words, it consists of places (nodes), and connections between those places. Some applications of graphs include • representing electronic circuits • modeling object interactions (e.g. used in the Unified Modeling Language) • showing ordering relationships between computer programs • modeling networks and network traffic • the fact that trees are a special case of graphs, in that they are acyclic and connected graphs, and that trees are used in many fundamental data structures 1 An undirected graph G = (V; E) is a pair of sets V , E, where • V is a set of vertices, also called nodes. • E is a set of unordered pairs of vertices called edges, and are of the form (u; v), such that u; v 2 V . • if e = (u; v) is an edge, then we say that u is adjacent to v, and that e is incident with u and v. • We assume jV j = n is finite, where n is called the order of G. •j Ej = m is called the size of G. • A path P of length k in a graph is a sequence of vertices v0; v1; : : : ; vk, such that (vi; vi+1) 2 E for every 0 ≤ i ≤ k − 1. { a path is called simple iff the vertices v0; v1; : : : ; vk are all distinct.
    [Show full text]
  • Branch and Bound Algorithm to Determine the Best Route to Get Around Tokyo
    Branch and Bound Algorithm to Determine The Best Route to Get Around Tokyo Muhammad Iqbal Sigid - 13519152 Program Studi Teknik Informatika Sekolah Teknik Elektro dan Informatika Institut Teknologi Bandung, Jalan Ganesha 10 Bandung E-mail: [email protected] Abstract—This paper described using branch and bound Fig. 1. State Space Tree example for Branch and Bound Algorithm (Source: algorithm to determined the best route to get around six selected https://informatika.stei.itb.ac.id/~rinaldi.munir/Stmik/2020-2021/Algoritma- places in Tokyo, modeled after travelling salesman problem. The Branch-and-Bound-2021-Bagian1.pdf accessed May 8, 2021) bound function used is reduced cost matrix using manual calculation and a python program to check the solution. Branch and Bound is an algorithm design which are usually used to solve discrete and combinatorial optimization Keywords—TSP, pathfinding, Tokyo, BnB problems. Branch and bound uses state space tree by expanding its nodes (subset of solution set) based on the minimum or I. INTRODUCTION maximum cost of the active node. There is also a bound which is used to determine if a node can produce a better solution Pathfinding algorithm is used to find the most efficient than the best one so far. If the node cost violates this bound, route between two points. It can be the shortest, the cheapest, then the node will be eliminated and will not be expanded the faster, or other kind. Pathfinding is closely related to the further. shortest path problem, graph theory, or mazes. Pathfinding usually used a graph as a representation. The nodes represent a Branch and bound algorithm is quite similar to Breadth place to visit and the edges represent the nodes connectivity.
    [Show full text]
  • Memory-Constrained Pathfinding Algorithms for Partially-Known Environments
    University of Windsor Scholarship at UWindsor Electronic Theses and Dissertations Theses, Dissertations, and Major Papers 2007 Memory-constrained pathfinding algorithms for partially-known environments Denton Cockburn University of Windsor Follow this and additional works at: https://scholar.uwindsor.ca/etd Recommended Citation Cockburn, Denton, "Memory-constrained pathfinding algorithms for partially-known environments" (2007). Electronic Theses and Dissertations. 4672. https://scholar.uwindsor.ca/etd/4672 This online database contains the full-text of PhD dissertations and Masters’ theses of University of Windsor students from 1954 forward. These documents are made available for personal study and research purposes only, in accordance with the Canadian Copyright Act and the Creative Commons license—CC BY-NC-ND (Attribution, Non-Commercial, No Derivative Works). Under this license, works must always be attributed to the copyright holder (original author), cannot be used for any commercial purposes, and may not be altered. Any other use would require the permission of the copyright holder. Students may inquire about withdrawing their dissertation and/or thesis from this database. For additional inquiries, please contact the repository administrator via email ([email protected]) or by telephone at 519-253-3000ext. 3208. Memory-Constrained Pathfinding Algorithms for Partially-Known Environments by Denton Cockbum A Thesis Submitted to the Faculty of Graduate Studies through The School of Computer Science in Partial Fulfillment of the
    [Show full text]
  • Lecture 16: Dijkstra’S Algorithm (Graphs)
    CSE 373: Data Structures and Algorithms Lecture 16: Dijkstra’s Algorithm (Graphs) Instructor: Lilian de Greef Quarter: Summer 2017 Today • Announcements • Graph Traversals Continued • Remarks on DFS & BFS • Shortest paths for weighted graphs: Dijkstra’s Algorithm! Announcements: Homework 4 is out! • Due next Friday (August 4th) at 5:00pm • May choose to pair-program if you like! • Same cautions as last time apply: choose partners and when to start working wisely! • Can almost entirely complete using material by end of this lecture • Will discuss some software-design concepts next week to help you prevent some (potentially non-obvious) bugs Another midterm correction… ( & ) Bring your midterm to *any* office hours to get your point back. I will have the final exam quadruple-checked to avoid these situations! (I am so sorry) Graphs: Traversals Continued And introducing Dijkstra’s Algorithm for shortest paths! Graph Traversals: Recap & Running Time • Traversals: General Idea • Starting from one vertex, repeatedly explore adjacent vertices • Mark each vertex we visit, so we don’t process each more than once (cycles!) • Important Graph Traversal Algorithms: Depth First Search (DFS) Breadth First Search (BFS) Explore… as far as possible all neighbors first before backtracking before next level of neighbors Choose next vertex using… recursion or a stack a queue • Assuming “choose next vertex” is O(1), entire traversal is • Use graph represented with adjacency Comparison (useful for Design Decisions!) • Which one finds shortest paths? • i.e. which is better for “what is the shortest path from x to y” when there’s more than one possible path? • Which one can use less space in finding a path? • A third approach: • Iterative deepening (IDFS): • Try DFS but disallow recursion more than K levels deep • If that fails, increment K and start the entire search over • Like BFS, finds shortest paths.
    [Show full text]
  • Data Structures and Algorithms Lecture 18: Minimum Spanning Trees (Graphs)
    CSE 373: Data Structures and Algorithms Lecture 18: Minimum Spanning Trees (Graphs) Instructor: Lilian de Greef Quarter: Summer 2017 Today • Spanning Trees • Approach #1: DFS • Approach #2: Add acyclic edges • Minimum Spanning Trees • Prim’s Algorithm • Kruskal’s Algorithm Announcements • Midterms • I brought midterms with me, can get them after class • Next week, will only have them at CSE220 office hours • Reminder: hw4 due on Friday! Spanning Trees & Minimum Spanning Trees For undirected graphs Introductory Example All the roads in Seattle are covered in snow. You were asked to shovel or plow snow from roads so that Seattle drivers can travel. Because you don’t want to shovel/plow that many roads, what is the smallest set of roads to clear in order to reconnect Seattle? Spanning Trees • Goal: Given a connected undirected graph G=(V,E), find a minimal subset of edges such that G is still connected • A graph G2 = (V,E2) such that G2 is connected and removing any edge from E2 makes G2 disconnected Observations 1. Any solution to this problem is a tree • Recall a tree does not need a root; just means acyclic • For any cycle, could remove an edge and still be connected 2. Solution not unique unless original graph was already a tree 3. Problem ill-defined if original graph not connected • So |E| >= |V|-1 4. A tree with |V| nodes has edges • So every solution to the spanning tree problem has edges Two Approaches Different algorithmic approaches to the spanning-tree problem: 1. Do a graph traversal (e.g., depth-first search, but any traversal will do), keeping track of edges that form a tree 2.
    [Show full text]
  • 9 Graph Traversal
    9 Graph Traversal Suppose you are working in the traffic planning department of a town with a nice medieval center.1 An unholy coalition of shop owners, who want more street-side parking, and the Green Party, which wants to discourage car traffic altogether, has decided to turn most streets into one-way streets. You want to avoid the worst by checking whether the current plan maintains the minimum requirement that one can still drive from every point in town to every other point. In the language of graphs (see Sect. 2.12), the question is whether the directed graph formed by the streets is strongly connected. The same problem comes up in other applications. For example, in the case of a communication network with unidirec- tional channels (e.g., radio transmitters), we want to know who can communicate with whom. Bidirectional communication is possible within the strongly connected components of the graph. We shall present a simple, efficient algorithm for computing strongly connected components (SCCs) in Sect. 9.3.2. Computing SCCs and many other fundamental problems on graphs can be reduced to systematic graph exploration, inspecting each edge exactly once. We shall present the two most important exploration strategies: breadth-first search (BFS) in Sect. 9.1 and depth-first search (DFS) in Sect. 9.3. Both strategies construct forests and partition the edges into four classes: Tree edges com- prising the forest, forward edges running parallel to paths of tree edges, backward edges running antiparallel to paths of tree edges, and cross edges. Cross edges are all remaining edges; they connect two different subtrees in the forest.
    [Show full text]
  • 10 Graph Algorithms
    Ghosh: Distributed Systems Chapter 10: Graph Algorithms 10 Graph Algorithms 10.1. Introduction The topology of a distributed system is represented by a graph where the nodes represent processes, and the links represent communication channels. Accordingly, distributed algorithms for various graph theoretic problems have numerous applications in communication and networking. Here are some motivating examples. Our first example deals with routing in a communication network. When a message is sent from node i to a non-neighboring node j, the intermediate nodes route the message based on the information stored in the local routing table, so that eventually the message reaches the destination node. This is called destination-based routing. An important problem is to compute these routing tables and maintain them, so that messages reach their destinations in smallest number of hops or with minimum delay. The minimum hop routing is equivalent to computing the shortest path between a pair of nodes using locally available information. Our second example focuses on the amount of space required to store a routing table in a network. Without any optimization, the space requirement is O(N), where N is the number of nodes. But with the explosive growth of the Internet, N is increasing at a steep rate, and the space requirement of the routing table is a matter of concern. This leads to the question: Can we reduce the size of the routing table? Given the value of N, what is the smallest amount of information that each individual node must store in their routing tables, so that every message eventually reaches its final destination? Our third example visits the problem of broadcasting in a network whose topology is represented by a connected graph.
    [Show full text]
  • Pathfinding in Strategy Games and Maze Solving Using A* Search Algorithm
    Journal of Computer and Communications, 2016, 4, 15-25 http://www.scirp.org/journal/jcc ISSN Online: 2327-5227 ISSN Print: 2327-5219 Pathfinding in Strategy Games and Maze Solving Using A* Search Algorithm Nawaf Hazim Barnouti, Sinan Sameer Mahmood Al-Dabbagh, Mustafa Abdul Sahib Naser Al-Mansour University College, Baghdad, Iraq How to cite this paper: Barnouti, N.H., Abstract Al-Dabbagh, S.S.M. and Naser, M.A.S. (2016) Pathfinding in Strategy Games and Pathfinding algorithm addresses the problem of finding the shortest path from Maze Solving Using A* Search Algorithm. source to destination and avoiding obstacles. One of the greatest challenges in the Journal of Computer and Communications, design of realistic Artificial Intelligence (AI) in computer games is agent movement. 4, 15-25. http://dx.doi.org/10.4236/jcc.2016.411002 Pathfinding strategies are usually employed as the core of any AI movement system. In this work, A* search algorithm is used to find the shortest path between the source Received: July 25, 2016 and destination on image that represents a map or a maze. Finding a path through a Accepted: September 4, 2016 Published: September 8, 2016 maze is a basic computer science problem that can take many forms. The A* algo- rithm is widely used in pathfinding and graph traversal. Different map and maze Copyright © 2016 by authors and images are used to test the system performance (100 images for each map and maze). Scientific Research Publishing Inc. The system overall performance is acceptable and able to find the shortest path be- This work is licensed under the Creative Commons Attribution International tween two points on the images.
    [Show full text]