Skip to content

Commit 096e690

Browse files
authored
Merge pull request #138 from stdgraph/algorithms/cc
Algorithms/cc
2 parents 8b768da + a79c3e4 commit 096e690

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/graph/algorithm/connected_components.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "graph/views/incidence.hpp"
1919
#include "graph/views/vertexlist.hpp"
2020
#include "graph/views/breadth_first_search.hpp"
21-
#include "graph/views/depth_first_search.hpp"
2221
#include <stack>
2322

2423
#ifndef GRAPH_CC_HPP
@@ -103,6 +102,10 @@ void connected_components(G&& g, // graph
103102
}
104103
visited[uid] = true;
105104
component[uid] = cid;
105+
if (!size(edges(g,u))) {
106+
++cid;
107+
continue;
108+
}
106109
vertices_breadth_first_search_view<G, void> bfs(g, uid);
107110
for (auto&& [vid, v] : bfs) {
108111
component[vid] = cid;

0 commit comments

Comments
 (0)