# Is the parent cost in A* added in every extended child?

How do we determine the cost of the parent path to its child in A* ("A star") search?

• Please, edit your post to clarify what you're actually asking. I gave an answer below, but I am not sure if that's what you're asking. – nbro Nov 25 '18 at 19:51
• @nbro retagged and edited the body text. (Feel free to flesh it out as this is a brand new contributor.) – DukeZhou Nov 26 '18 at 2:10

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)$$.