Skip to content

Commit 53a0a9a

Browse files
Add get_parent() method to a_star class for parent node retrieval
1 parent 905d024 commit 53a0a9a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/a_star.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ namespace utils
179179
return true;
180180
}
181181

182+
[[nodiscard]] const node<Tp> *get_parent(const node<Tp> &n) const noexcept
183+
{
184+
if (auto it = came_from.find(&n); it != came_from.end())
185+
return it->second;
186+
return nullptr;
187+
}
188+
182189
[[nodiscard]] std::vector<std::shared_ptr<node<Tp>>> get_path() const noexcept
183190
{
184191
std::vector<std::shared_ptr<node<Tp>>> path;

0 commit comments

Comments
 (0)