Answers.Body: <p>The evaluation function in A* is <span class="math-container">$f(n) = g(n) + h(n)$</span>, where <span class="math-container">$g(n)$</span> is the cost of the path from the starting node to <span class="math-container">$n$</span> and <span class="math-container">$h(n)$</span> is an estimate of the distance from <span class="math-container">$n$</span> to the goal node. To compute <span class="math-container">$g(n)$</span>, you simply do <span class="math-container">$g(n) = g(p) + c(p, n)$</span>, where <span class="math-container">$p$</span> is the parent node, and <span class="math-container">$c(p, n)$</span> is the <span class="math-container">$c$</span>ost of the edge between <span class="math-container">$p$</span> and <span class="math-container">$n$</span>. So, yes, to compute <span class="math-container">$g(n)$</span> you use <span class="math-container">$g(p)$</span>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-25T19:48:40.683Z
Answers.LastActivityDate: 2018-11-26T11:43:13.713Z
Answers.LastEditDate: 2018-11-26T11:43:13.713Z
Answers.UserDisplayName: nbro
Body: <p>How is the cost of the path to each node <span class="math-container">$n$</span> computed in the <a href="https://en.wikipedia.org/wiki/A*_search_algorithm" rel="nofollow noreferrer">A* algorithm</a>? Do we need to add the cost of the path to the parent node <span class="math-container">$p$</span> to the cost of the path of the child node <span class="math-container">$n$</span>?</p>
  
Tags: <search><a-star>
Title: How is the cost of the path to each node computed in A*?
UserDisplayName: Jazba
ThreadText: # How is the cost of the path to each node computed in A*?
  
  (Asked by: username_0 on 2018-11-25)
  
  How is the cost of the path to each node $n$ computed in the [A\* algorithm](https://en.wikipedia.org/wiki/A*_search_algorithm)? Do we need to add the cost of the path to the parent node $p$ to the cost of the path of the child node $n$?
  
  **Tags:** search, a-star
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-25. Score: 3
  
  The evaluation function in A\* is $f(n) = g(n) + h(n)$, where $g(n)$ is the cost of the path from the starting node to $n$ and $h(n)$ is an estimate of the distance from $n$ to the goal node. To compute $g(n)$, you simply do $g(n) = g(p) + c(p, n)$, where $p$ is the parent node, and $c(p, n)$ is the $c$ost of the edge between $p$ and $n$. So, yes, to compute $g(n)$ you use $g(p)$.
  
  
  ---
  
  