Fork me on GitHub

Welcome to

A* Search Visualization


Algorithm Details:

  • The A* search algorithm uses a heuristic function h that estimates the distance between vi and t such that:
    1. underestimates the cost: h(vi) < d(vi,t) where d(i,j) is the smallest distance between i and j
    2. Is monotonic: h(vi) < h(vj) => d(vi,t) < d(vj,t)
    Such heuristics are said to be admissible and guarantee that A* will give a correct optimal solution.
    Note: We have used the Manhattan distance (= |x2-x1| + |y2-y1|) as the heuristic because our graph is of the form of a grid where each vertex represents a x,y coordinate.
  • The A* algorithm expands node n with min f(n) + h(n) every iteration, where f(n) is the currently known distance of n from s. This is an optimistic choice as the f(n) + h(n) gives a lower bound on the length of the current path to t.
  • This continues until the algorithm selects n = t, when it terminates and an optimal path is found. Note that this path has to be optimal since, all the other paths had larger optimistic estimates f(v)+h(v).

Legend:
  •   Red - Expanded Nodes
  •   Blue - Frontier Nodes (Unexpanded)
  •   White - Unseen Nodes
  •   Green - Found Path Nodes

Djikstra Search





Explanation: In each iteration, it finds the currently seen but untraversed vertex that minimizes, f(n) where f(n) gives the distance of n from source vertex

A* Search





Explanation: In each iteration, it finds the currently seen but untraversed vertex that minimizes, f(n) + h(n) where f(n) and h(n) give the distance of n from source vertex and estimated distance of n to terminal vertex

Greedy BFS





Explanation: In each iteration, it finds the currently seen but untraversed vertex that minimizes, h(n) where h(n) gives the estimated distance of n to terminal vertex