diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b575848..21159605 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,6 +189,7 @@ add_test(StingerHitsTest ${CMAKE_BINARY_DIR}/bin/stinger_hits_test) add_test(StingerDiameterTest ${CMAKE_BINARY_DIR}/bin/stinger_diameter_test) add_test(StingerIndependentSetsTest ${CMAKE_BINARY_DIR}/bin/stinger_independent_sets_test) add_test(StingerShortestPathsTest ${CMAKE_BINARY_DIR}/bin/stinger_shortest_paths) +add_test(StingerStreamingConnectedComponentsTest ${CMAKE_BINARY_DIR}/bin/stinger_streaming_connected_components_test) find_program(BASH bash REQUIRED) add_test( @@ -212,4 +213,5 @@ add_custom_target(check stinger_diameter_test stinger_independent_sets_test stinger_shortest_paths + stinger_streaming_connected_components_test ) diff --git a/src/tests/streaming_connected_components_test/scc_test.cpp b/src/tests/streaming_connected_components_test/scc_test.cpp index 55cdb49a..e8881b5c 100644 --- a/src/tests/streaming_connected_components_test/scc_test.cpp +++ b/src/tests/streaming_connected_components_test/scc_test.cpp @@ -1,3 +1,4 @@ +#include #include "scc_test.h" #define restrict @@ -82,37 +83,33 @@ TEST_F(SCCTest, UndirectedGraph) { TEST_F(SCCTest, UndirectedGraphDumbbell) { - stinger_insert_edge_pair(S, 0, 0, 1, 1, 1); - stinger_insert_edge_pair(S, 0, 0, 2, 1, 1); - stinger_insert_edge_pair(S, 0, 0, 3, 1, 1); - stinger_insert_edge_pair(S, 0, 1, 2, 1, 1); - stinger_insert_edge_pair(S, 0, 1, 3, 1, 1); - stinger_insert_edge_pair(S, 0, 2, 3, 1, 1); - - stinger_insert_edge_pair(S, 0, 3, 4, 1, 1); - - stinger_insert_edge_pair(S, 0, 4, 5, 1, 1); - stinger_insert_edge_pair(S, 0, 4, 6, 1, 1); - stinger_insert_edge_pair(S, 0, 4, 7, 1, 1); - stinger_insert_edge_pair(S, 0, 5, 6, 1, 1); - stinger_insert_edge_pair(S, 0, 5, 7, 1, 1); - int64_t nv = stinger_max_nv(S); stinger_scc_internal scc_internal; stinger_scc_initialize_internals(S,nv,&scc_internal,4); stinger_connected_components_stats stats; stinger_scc_reset_stats(&stats); - stinger_edge_update insertion,deletion; - insertion.source = 6; - insertion.destination = 7; - deletion.source = 3; - deletion.destination = 4; - - stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 2); + // Insert (1,2) + stinger_edge_update insertion = {0}; + insertion.source = 1; insertion.destination = 2; + stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 1); + stinger_scc_insertion(S, nv, scc_internal, &stats, &insertion, 1); + + // Insert (2,3) + insertion.source = 2; insertion.destination = 3; + stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 1); + stinger_scc_insertion(S, nv, scc_internal, &stats, &insertion, 1); + + // Insert (3,4) + insertion.source = 3; insertion.destination = 4; + stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 1); + stinger_scc_insertion(S, nv, scc_internal, &stats, &insertion, 1); + + // Now we have a simple chain, 1-2-3-4 + // We delete (2,3) breaking the chain into two components 1-2 3-4 + stinger_edge_update deletion = {0}; + deletion.source = 2; deletion.destination = 3; stinger_remove_edge_pair(S, 0, deletion.source, deletion.destination); - - stinger_scc_insertion(S,nv,scc_internal,&stats,&insertion,1); stinger_scc_deletion(S,nv,scc_internal,&stats,&deletion,1); const int64_t* actual_components = stinger_scc_get_components(scc_internal);