Skip to content

Commit

Permalink
change cc dfs to bfs for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeweese committed Aug 28, 2024
1 parent 8475532 commit c0ac114
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/graph/algorithm/connected_components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "graph/graph.hpp"
#include "graph/views/incidence.hpp"
#include "graph/views/vertexlist.hpp"
#include "graph/views/depth_first_search.hpp"
#include "graph/views/breadth_first_search.hpp"
#include <stack>

#ifndef GRAPH_CC_HPP
Expand Down Expand Up @@ -102,8 +102,8 @@ void connected_components(G&& g, // graph
}
visited[uid] = true;
component[uid] = cid;
vertices_depth_first_search_view<G, void> dfs(g, uid);
for (auto&& [vid, v] : dfs) {
vertices_breadth_first_search_view<G, void> bfs(g, uid);
for (auto&& [vid, v] : bfs) {
component[vid] = cid;
visited[vid] = true;
}
Expand Down

0 comments on commit c0ac114

Please sign in to comment.