Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALGO] Kosaraju's Algorithm #141

Merged
merged 10 commits into from
Oct 12, 2023
Prev Previous commit
Next Next commit
Adding vertex to stack after visiting its neighbours in Kosaraju.
  • Loading branch information
toadkarter committed Oct 11, 2023
commit 4b53bfc4185744fd5a84c7e197d07b1b51ebc84e
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
std::stack<vertex_id_t>& stack,
std::unordered_set<vertex_id_t>& seen_vertices) {
if (!seen_vertices.contains(vertex_id)) {
stack.push(vertex_id);
seen_vertices.insert(vertex_id);

for (const auto neighbour : graph.get_neighbors(vertex_id)) {
do_visit_vertex(neighbour, graph, stack, seen_vertices);
}
stack.push(vertex_id);
}
}

Expand Down Expand Up @@ -50,7 +49,7 @@
std::vector<std::vector<vertex_id_t>> sccs{};

if (graph.get_vertices().size() == 0) {
return sccs;

Check warning on line 52 in include/graaflib/algorithm/strongly_connected_components/kosaraju.tpp

View check run for this annotation

Codecov / codecov/patch

include/graaflib/algorithm/strongly_connected_components/kosaraju.tpp#L52

Added line #L52 was not covered by tests
}

std::stack<vertex_id_t> stack{};
Expand Down