Skip to content

Commit

Permalink
change TC to only operate on lower or upper triangle, add return to c…
Browse files Browse the repository at this point in the history
…onnected components
  • Loading branch information
kdeweese committed Jan 21, 2025
1 parent fb61ed3 commit 5b97d17
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions data/tc_test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ A,E,1
B,C,1
B,D,1
B,E,1
B,F,1
C,D,1
E,C,1
C,E,1
D,E,1
B,F,1
E,F,1
E,G,1
F,H,1
Expand Down
5 changes: 3 additions & 2 deletions include/graph/algorithm/connected_components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void kosaraju(G&& g, // graph
template <adjacency_list G,
random_access_range Component>
requires random_access_range<vertex_range_t<G>> && integral<vertex_id_t<G>>
void connected_components(G&& g, // graph
Component& component // out: connected component assignment
size_t connected_components(G&& g, // graph
Component& component // out: connected component assignment
) {
size_t N(size(vertices(g)));
std::vector<bool> visited(N, false);
Expand All @@ -114,6 +114,7 @@ void connected_components(G&& g, // graph
}
++cid;
}
return cid;
}

} // namespace graph
Expand Down
4 changes: 0 additions & 4 deletions include/graph/algorithm/tc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ size_t triangle_count(G&& g) {
auto ie = end(edges(g, uid));
while (i != ie) {
auto&& [vid, uv] = *i;
if (vid < uid) {
++i;
continue;
}
graph::incidence_iterator<G> j(g, vid);

auto je = end(edges(g, vid));
Expand Down
4 changes: 2 additions & 2 deletions tests/tc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ TEST_CASE("triangle counting test", "[tc]") {
init_console();

using G = routes_vol_graph_type;
auto&& g = load_ordered_graph<G>(TEST_DATA_ROOT_DIR "tc_test.csv", name_order_policy::alphabetical, true);
auto&& g = load_ordered_graph<G>(TEST_DATA_ROOT_DIR "tc_test.csv", name_order_policy::alphabetical);

size_t triangles = graph::triangle_count(g);
REQUIRE(triangles == 11);
}
}

0 comments on commit 5b97d17

Please sign in to comment.