From 0c5e7a53cf6948759d13cbf66e9c9b37bc7f62ac Mon Sep 17 00:00:00 2001 From: kdeweese Date: Tue, 10 Oct 2023 20:50:42 -0700 Subject: [PATCH 1/3] bug fix to dfs, popping stack too early --- include/graph/views/depth_first_search.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/graph/views/depth_first_search.hpp b/include/graph/views/depth_first_search.hpp index d268f59..f83ae58 100644 --- a/include/graph/views/depth_first_search.hpp +++ b/include/graph/views/depth_first_search.hpp @@ -126,7 +126,6 @@ class dfs_base : public ranges::view_base { // next level in search auto [u_id, uvi] = S_.top(); vertex_id_type v_id = real_target_id(*uvi, u_id); - edge_iterator vwi = ranges::end(edges(graph_, v_id)); switch (cancel_) { case cancel_search::continue_search: @@ -160,7 +159,7 @@ class dfs_base : public ranges::view_base { // we've reached the end of a branch in the DFS tree; start unwinding the stack to find other unvisited branches else { colors_[v_id] = black; // finished with v - S_.pop(); + auto [t1, t2] = S_.top(); while (!S_.empty()) { auto [x_id, xyi] = S_.top(); S_.pop(); From 79f39cb34bb7b47eccc8c38bc5786fd570fc7ec2 Mon Sep 17 00:00:00 2001 From: kdeweese Date: Tue, 10 Oct 2023 20:53:52 -0700 Subject: [PATCH 2/3] clean code --- include/graph/views/depth_first_search.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/graph/views/depth_first_search.hpp b/include/graph/views/depth_first_search.hpp index f83ae58..a5c1eb0 100644 --- a/include/graph/views/depth_first_search.hpp +++ b/include/graph/views/depth_first_search.hpp @@ -127,6 +127,7 @@ class dfs_base : public ranges::view_base { auto [u_id, uvi] = S_.top(); vertex_id_type v_id = real_target_id(*uvi, u_id); edge_iterator vwi = ranges::end(edges(graph_, v_id)); + switch (cancel_) { case cancel_search::continue_search: // find first unvisited edge of v @@ -159,7 +160,6 @@ class dfs_base : public ranges::view_base { // we've reached the end of a branch in the DFS tree; start unwinding the stack to find other unvisited branches else { colors_[v_id] = black; // finished with v - auto [t1, t2] = S_.top(); while (!S_.empty()) { auto [x_id, xyi] = S_.top(); S_.pop(); From b457a208d359937e6b67a8b1d511b443f62eead1 Mon Sep 17 00:00:00 2001 From: kdeweese Date: Tue, 10 Oct 2023 20:56:42 -0700 Subject: [PATCH 3/3] clean code --- include/graph/views/depth_first_search.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/graph/views/depth_first_search.hpp b/include/graph/views/depth_first_search.hpp index a5c1eb0..a132125 100644 --- a/include/graph/views/depth_first_search.hpp +++ b/include/graph/views/depth_first_search.hpp @@ -126,8 +126,8 @@ class dfs_base : public ranges::view_base { // next level in search auto [u_id, uvi] = S_.top(); vertex_id_type v_id = real_target_id(*uvi, u_id); - edge_iterator vwi = ranges::end(edges(graph_, v_id)); + edge_iterator vwi = ranges::end(edges(graph_, v_id)); switch (cancel_) { case cancel_search::continue_search: // find first unvisited edge of v