Skip to content

Commit

Permalink
refactor: Simplify recursive depth_first_search
Browse files Browse the repository at this point in the history
  • Loading branch information
oboukli committed Feb 1, 2025
1 parent 2d79d93 commit 57fc2f1
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions include/forfun/graph/depth_first_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,11 @@ constexpr auto depth_first_search_imp(
vertex_state_list[start] = vertex_visit_state::visited;
preorder_step(start);

auto const adjacencies_iter{
get_adjacencies_iter(vertex_adjacency_list, start)
};
auto const adj_iter{get_adjacencies_iter(vertex_adjacency_list, start)};

auto itr{adjacencies_iter->cbegin()};
auto const end{adjacencies_iter->cend()};

for (; itr != end; ++itr)
for (auto iter{adj_iter->cbegin()}; iter != adj_iter->cend(); ++iter)
{
if (auto const adjacency{*itr};
if (auto const adjacency{*iter};
vertex_state_list[adjacency] == vertex_visit_state::unvisited)
{
depth_first_search_imp(
Expand Down

0 comments on commit 57fc2f1

Please sign in to comment.