From 0c043330b1b6878683540bfc57ac7aaaf716b435 Mon Sep 17 00:00:00 2001 From: Dmitriy Kozenko <8863314@gmail.com> Date: Fri, 20 Jun 2025 14:37:50 +0300 Subject: [PATCH] Added base file structure with cmake. Added CI for building and running tests. Added regular_path_query algorithm. --- .github/workflows/ubuntu.yml | 54 +++++++ .gitignore | 4 + .gitmodules | 9 ++ CMakeLists.txt | 28 ++++ README.md | 16 +++ deps/cuBool | 1 + deps/fast_matrix_market | 1 + deps/googletest | 1 + include/regular_path_query.hpp | 22 +++ src/CMakeLists.txt | 1 + src/regular_path_query.cpp | 193 +++++++++++++++++++++++++ tests/CMakeLists.txt | 13 ++ tests/main.cpp | 6 + tests/rpq_tests.cpp | 195 ++++++++++++++++++++++++++ tests/test_data/rpq/1/a.mtx | 5 + tests/test_data/rpq/1/expected.txt | 6 + tests/test_data/rpq/1/meta.txt | 1 + tests/test_data/rpq/1/sources.txt | 1 + tests/test_data/rpq/2/a.mtx | 4 + tests/test_data/rpq/2/b.mtx | 4 + tests/test_data/rpq/2/expected.txt | 7 + tests/test_data/rpq/2/meta.txt | 1 + tests/test_data/rpq/2/sources.txt | 1 + tests/test_data/rpq/3/a.mtx | 4 + tests/test_data/rpq/3/b.mtx | 4 + tests/test_data/rpq/3/expected.txt | 3 + tests/test_data/rpq/3/meta.txt | 1 + tests/test_data/rpq/3/sources.txt | 1 + tests/test_data/rpq/4/b.mtx | 11 ++ tests/test_data/rpq/4/expected.txt | 16 +++ tests/test_data/rpq/4/meta.txt | 1 + tests/test_data/rpq/4/sources.txt | 1 + tests/test_data/rpq/5/automaton_a.mtx | 4 + tests/test_data/rpq/5/automaton_b.mtx | 5 + tests/test_data/rpq/5/expected.txt | 5 + tests/test_data/rpq/5/graph_a.mtx | 5 + tests/test_data/rpq/5/graph_b.mtx | 6 + tests/test_data/rpq/a.mtx | 9 ++ tests/test_data/rpq/b.mtx | 10 ++ 39 files changed, 660 insertions(+) create mode 100644 .github/workflows/ubuntu.yml create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 deps/cuBool create mode 160000 deps/fast_matrix_market create mode 160000 deps/googletest create mode 100644 include/regular_path_query.hpp create mode 100644 src/CMakeLists.txt create mode 100644 src/regular_path_query.cpp create mode 100644 tests/CMakeLists.txt create mode 100644 tests/main.cpp create mode 100644 tests/rpq_tests.cpp create mode 100644 tests/test_data/rpq/1/a.mtx create mode 100644 tests/test_data/rpq/1/expected.txt create mode 100644 tests/test_data/rpq/1/meta.txt create mode 100644 tests/test_data/rpq/1/sources.txt create mode 100644 tests/test_data/rpq/2/a.mtx create mode 100644 tests/test_data/rpq/2/b.mtx create mode 100644 tests/test_data/rpq/2/expected.txt create mode 100644 tests/test_data/rpq/2/meta.txt create mode 100644 tests/test_data/rpq/2/sources.txt create mode 100644 tests/test_data/rpq/3/a.mtx create mode 100644 tests/test_data/rpq/3/b.mtx create mode 100644 tests/test_data/rpq/3/expected.txt create mode 100644 tests/test_data/rpq/3/meta.txt create mode 100644 tests/test_data/rpq/3/sources.txt create mode 100644 tests/test_data/rpq/4/b.mtx create mode 100644 tests/test_data/rpq/4/expected.txt create mode 100644 tests/test_data/rpq/4/meta.txt create mode 100644 tests/test_data/rpq/4/sources.txt create mode 100644 tests/test_data/rpq/5/automaton_a.mtx create mode 100644 tests/test_data/rpq/5/automaton_b.mtx create mode 100644 tests/test_data/rpq/5/expected.txt create mode 100644 tests/test_data/rpq/5/graph_a.mtx create mode 100644 tests/test_data/rpq/5/graph_b.mtx create mode 100644 tests/test_data/rpq/a.mtx create mode 100644 tests/test_data/rpq/b.mtx diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..0da2f3b --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,54 @@ +name: Compile, run tests and check code style + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + + matrix: + os: [ubuntu-24.04] + c_compiler: [gcc-14] + cpp_compiler: [g++-14] + build_type: [Release, Debug] + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Setup enviroment + run: | + sudo apt update + sudo apt install gcc-14 + sudo apt install g++-14 + sudo apt install cmake + sudo apt install clang-format + + - name: Configure CMake + run: | + cd ${{ github.workspace }} + cmake -B build -S . \ + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCUBOOL_GRAPH_ENABLE_TESTING=ON \ + -DCUBOOL_WITH_CUDA=OFF \ + -DCUBOOL_WITH_SEQUENTIAL=ON + + - name: Build + run: | + cmake --build build -j10 + + - name: Run tests + run: | + ./build/tests/cuboolgraph_tests diff --git a/.gitignore b/.gitignore index 259148f..1a7d549 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ *.exe *.out *.app + +build/* +.cache/* +.vscode/* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8f5326c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "deps/googletest"] + path = deps/googletest + url = https://github.com/google/googletest +[submodule "deps/fast_matrix_market"] + path = deps/fast_matrix_market + url = https://github.com/alugowski/fast_matrix_market +[submodule "deps/cuBool"] + path = deps/cuBool + url = https://github.com/mitya-y/cuBool diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..da5f8a6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.25) + +set(CMAKE_CXX_STANDARD 20) + +set(CUBOOL_GRAPH_LIB_NAME cuboolgraph) +project(${CUBOOL_GRAPH_LIB_NAME} LANGUAGES CXX) + +add_library(${CUBOOL_GRAPH_LIB_NAME} SHARED "") + +set(CUBOOL_COPY_TO_PY_PACKAGE OFF) +set(CUBOOL_BUILD_TESTS OFF) +add_subdirectory(deps/cuBool) + +# cubool is a name of CMakeTarget cmake target +target_link_libraries(${CUBOOL_GRAPH_LIB_NAME} PUBLIC cubool) + +target_include_directories(${CUBOOL_GRAPH_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + +add_subdirectory(src) + +option(CUBOOL_GRAPH_ENABLE_TESTING "Compile tests for algorithms" OFF) + +if(CUBOOL_GRAPH_ENABLE_TESTING) + add_subdirectory(deps/googletest) + add_subdirectory(deps/fast_matrix_market) + add_subdirectory(tests) +endif() + diff --git a/README.md b/README.md index a156d06..5a88526 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ # cuBoolGraph cuBool based graph analysis algorithms + +## List of algorithms + +regular_path_query - Single-Source Regular Path Query Algorithm in Terms of Linear Algebra + +# Run tests +cuBoolGraph supports Linux-based OS (tested on Ubuntu 24.04 and Manjaro 6.19). +For building project are required gcc version 14 and later, CMake with version 3.25 and later, CUDA developing toolkint version 12.0 and later. + +For build and run tests execute commands +``` +git submodule update --init --recursive +cmake -B build -DCUBOOL_GRAPH_ENABLE_TESTING=ON +cmake --build build +./build/tests/cuboolgraph_tests +``` diff --git a/deps/cuBool b/deps/cuBool new file mode 160000 index 0000000..69d38a6 --- /dev/null +++ b/deps/cuBool @@ -0,0 +1 @@ +Subproject commit 69d38a67d74cc032ab9c313721f40cba2f79125c diff --git a/deps/fast_matrix_market b/deps/fast_matrix_market new file mode 160000 index 0000000..b6172c9 --- /dev/null +++ b/deps/fast_matrix_market @@ -0,0 +1 @@ +Subproject commit b6172c96ef73d16b2c10917373bacec1a7583a31 diff --git a/deps/googletest b/deps/googletest new file mode 160000 index 0000000..35b75a2 --- /dev/null +++ b/deps/googletest @@ -0,0 +1 @@ +Subproject commit 35b75a2cba6ef72b7ce2b6b94b05c54ca07df866 diff --git a/include/regular_path_query.hpp b/include/regular_path_query.hpp new file mode 100644 index 0000000..f870237 --- /dev/null +++ b/include/regular_path_query.hpp @@ -0,0 +1,22 @@ +#include + +#include + +cuBool_Matrix regular_path_query_with_transposed( + // vector of sparse graph matrices for each label + const std::vector &graph, const std::vector &source_vertices, + // vector of sparse automaton matrices for each label + const std::vector &automaton, const std::vector &start_states, + // transposed matrices for graph and automaton + const std::vector &graph_transposed, + const std::vector &automaton_transposed, + + const std::vector &inversed_labels = {}, bool all_labels_are_inversed = false); + +cuBool_Matrix regular_path_query( + // vector of sparse graph matrices for each label + const std::vector &graph, const std::vector &source_vertices, + // vector of sparse automaton matrices for each label + const std::vector &automaton, const std::vector &start_states, + + const std::vector &inversed_labels = {}, bool all_labels_are_inversed = false); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..7dd071c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1 @@ +target_sources(${CUBOOL_GRAPH_LIB_NAME} PRIVATE regular_path_query.cpp) diff --git a/src/regular_path_query.cpp b/src/regular_path_query.cpp new file mode 100644 index 0000000..f26a72c --- /dev/null +++ b/src/regular_path_query.cpp @@ -0,0 +1,193 @@ +#include +#include +#include +#include +#include + +#include "regular_path_query.hpp" + +cuBool_Matrix regular_path_query_with_transposed( + // vector of sparse graph matrices for each label + const std::vector &graph, const std::vector &source_vertices, + // vector of sparse automaton matrices for each label + const std::vector &automaton, const std::vector &start_states, + // transposed matrices for graph and automaton + const std::vector &graph_transposed, + const std::vector &automaton_transposed, + + const std::vector &inversed_labels_input, bool all_labels_are_inversed) { + cuBool_Status status; + + auto inversed_labels = inversed_labels_input; + inversed_labels.resize(std::max(graph.size(), automaton.size())); + + for (uint32_t i = 0; i < inversed_labels.size(); i++) { + bool is_inverse = inversed_labels[i]; + is_inverse ^= all_labels_are_inversed; + inversed_labels[i] = is_inverse; + } + + cuBool_Index graph_nodes_number = 0; + cuBool_Index automaton_nodes_number = 0; + + // get number of graph nodes + for (auto label_matrix : graph) { + if (label_matrix != nullptr) { + cuBool_Matrix_Nrows(label_matrix, &graph_nodes_number); + break; + } + } + + // get number of automaton nodes + for (auto label_matrix : automaton) { + if (label_matrix != nullptr) { + cuBool_Matrix_Nrows(label_matrix, &automaton_nodes_number); + break; + } + } + + // this will be answer + cuBool_Matrix reacheble {}; + status = cuBool_Matrix_New(&reacheble, automaton_nodes_number, graph_nodes_number); + assert(status == CUBOOL_STATUS_SUCCESS); + + // allocate neccessary for algorithm matrices + cuBool_Matrix frontier {}, symbol_frontier {}, next_frontier {}; + status = cuBool_Matrix_New(&next_frontier, automaton_nodes_number, graph_nodes_number); + assert(status == CUBOOL_STATUS_SUCCESS); + status = cuBool_Matrix_New(&frontier, automaton_nodes_number, graph_nodes_number); + assert(status == CUBOOL_STATUS_SUCCESS); + status = cuBool_Matrix_New(&symbol_frontier, automaton_nodes_number, graph_nodes_number); + assert(status == CUBOOL_STATUS_SUCCESS); + + // init start values of algorithm matricies + for (const auto state : start_states) { + for (const auto vert : source_vertices) { + assert(state < automaton_nodes_number); + assert(vert < graph_nodes_number); + cuBool_Matrix_SetElement(next_frontier, state, vert); + cuBool_Matrix_SetElement(reacheble, state, vert); + } + } + + cuBool_Index states = source_vertices.size(); + + // temporary matrix for write result of cubool functions + cuBool_Matrix result; + status = cuBool_Matrix_New(&result, automaton_nodes_number, graph_nodes_number); + assert(status == CUBOOL_STATUS_SUCCESS); + + const auto label_number = std::min(graph.size(), automaton.size()); + while (states > 0) { + std::swap(frontier, next_frontier); + + // clear next_frontier + status = cuBool_Matrix_Build(next_frontier, nullptr, nullptr, 0, CUBOOL_HINT_NO); + assert(status == CUBOOL_STATUS_SUCCESS); + + for (int i = 0; i < label_number; i++) { + if (graph[i] == nullptr || automaton[i] == nullptr) { + continue; + } + + cuBool_Matrix automaton_matrix = all_labels_are_inversed ? automaton[i] : automaton_transposed[i]; + status = cuBool_MxM(symbol_frontier, automaton_matrix, frontier, CUBOOL_HINT_NO); + assert(status == CUBOOL_STATUS_SUCCESS); + + // next_frontier += (symbol_frontier * graph[i]) & (!reachible) + // multiply 2 matrices + cuBool_Matrix graph_matrix = inversed_labels[i] ? graph_transposed[i] : graph[i]; + status = cuBool_MxM(next_frontier, symbol_frontier, graph_matrix, CUBOOL_HINT_ACCUMULATE); + assert(status == CUBOOL_STATUS_SUCCESS); + // apply invert mask + status = cuBool_Matrix_EWiseMulInverted(result, next_frontier, reacheble, CUBOOL_HINT_NO); + assert(status == CUBOOL_STATUS_SUCCESS); + std::swap(result, next_frontier); + } + + // this must be accumulate with mask and save old value: reacheble += next_frontier & reacheble + status = cuBool_Matrix_EWiseAdd(result, reacheble, next_frontier, CUBOOL_HINT_NO); + assert(status == CUBOOL_STATUS_SUCCESS); + std::swap(result, reacheble); + + cuBool_Matrix_Nvals(next_frontier, &states); + } + + // free matrix necessary for algorithm + cuBool_Matrix_Free(next_frontier); + cuBool_Matrix_Free(frontier); + cuBool_Matrix_Free(symbol_frontier); + cuBool_Matrix_Free(result); + + return reacheble; +} + + +cuBool_Matrix regular_path_query( + // vector of sparse graph matrices for each label + const std::vector &graph, const std::vector &source_vertices, + // vector of sparse automaton matrices for each label + const std::vector &automaton, const std::vector &start_states, + // work with inverted labels + const std::vector &inversed_labels_input, bool all_labels_are_inversed) { + cuBool_Status status; + + // transpose graph matrices + std::vector graph_transposed; + graph_transposed.reserve(graph.size()); + for (uint32_t i = 0; i < graph.size(); i++) { + graph_transposed.emplace_back(); + + auto label_matrix = graph[i]; + if (label_matrix == nullptr) { + continue; + } + + cuBool_Index nrows, ncols; + cuBool_Matrix_Nrows(label_matrix, &nrows); + cuBool_Matrix_Ncols(label_matrix, &ncols); + + status = cuBool_Matrix_New(&graph_transposed.back(), ncols, nrows); + assert(status == CUBOOL_STATUS_SUCCESS); + status = cuBool_Matrix_Transpose(graph_transposed.back(), label_matrix, CUBOOL_HINT_NO); + assert(status == CUBOOL_STATUS_SUCCESS); + } + + // transpose automaton matrices + std::vector automaton_transposed; + automaton_transposed.reserve(automaton.size()); + for (auto label_matrix : automaton) { + automaton_transposed.emplace_back(); + if (label_matrix == nullptr) { + continue; + } + + cuBool_Index nrows, ncols; + cuBool_Matrix_Nrows(label_matrix, &nrows); + cuBool_Matrix_Ncols(label_matrix, &ncols); + + status = cuBool_Matrix_New(&automaton_transposed.back(), ncols, nrows); + assert(status == CUBOOL_STATUS_SUCCESS); + status = cuBool_Matrix_Transpose(automaton_transposed.back(), label_matrix, CUBOOL_HINT_NO); + assert(status == CUBOOL_STATUS_SUCCESS); + } + + auto result = regular_path_query_with_transposed( + graph, source_vertices, + automaton, start_states, + graph_transposed, automaton_transposed, + inversed_labels_input, all_labels_are_inversed); + + for (cuBool_Matrix matrix : graph_transposed) { + if (matrix != nullptr) { + cuBool_Matrix_Free(matrix); + } + } + for (cuBool_Matrix matrix : automaton_transposed) { + if (matrix != nullptr) { + cuBool_Matrix_Free(matrix); + } + } + + return result; +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..9ecd949 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,13 @@ +set(TESTS_TARGET cuboolgraph_tests) + +add_executable(${TESTS_TARGET} "main.cpp") + +target_link_libraries(${TESTS_TARGET} PUBLIC ${CUBOOL_GRAPH_LIB_NAME}) +target_link_libraries(${TESTS_TARGET} PUBLIC gtest) +target_link_libraries(${TESTS_TARGET} PUBLIC fast_matrix_market) + +target_compile_definitions(${TESTS_TARGET} PUBLIC + TESTS_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/test_data/") + +# tests files +target_sources(${TESTS_TARGET} PUBLIC "rpq_tests.cpp") diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000..76f841f --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,6 @@ +#include + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/rpq_tests.cpp b/tests/rpq_tests.cpp new file mode 100644 index 0000000..5e78391 --- /dev/null +++ b/tests/rpq_tests.cpp @@ -0,0 +1,195 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "regular_path_query.hpp" + +struct Config { + std::vector graph_data; + std::vector automaton_data; + std::vector sources; + std::string expexted; + std::string meta_data; + std::string sources_data; +}; + +static bool test_on_config(const Config &config) { + cuBool_Initialize(CUBOOL_HINT_NO); + + std::vector graph; + std::vector source_vertices; + std::vector automaton; + std::vector start_states; + + int64_t nrows = 0, ncols = 0; + std::vector rows, cols; + std::vector vals; + + // load graph + cuBool_Index graph_rows = 0; + graph.reserve(config.graph_data.size()); + for (const auto &data : config.graph_data) { + graph.emplace_back(); + if (data.empty()) { + continue; + } + + std::ifstream file(data); + if (!file) { + std::cout << data << std::endl; + throw std::runtime_error("error open file"); + } + fast_matrix_market::read_matrix_market_triplet(file, nrows, ncols, rows, cols, vals); + + cuBool_Matrix_New(&graph.back(), nrows, ncols); + cuBool_Matrix_Build(graph.back(), rows.data(), cols.data(), vals.size(), CUBOOL_HINT_NO); + + graph_rows = std::max(graph_rows, (cuBool_Index)nrows); + } + + cuBool_Index automaton_rows = 0; + // load automaton + automaton.reserve(config.automaton_data.size()); + for (const auto &data : config.automaton_data) { + automaton.emplace_back(); + if (data.empty()) { + continue; + } + + std::ifstream file(data); + if (!file) { + throw std::runtime_error("error open file"); + } + fast_matrix_market::read_matrix_market_triplet(file, nrows, ncols, rows, cols, vals); + + cuBool_Matrix_New(&automaton.back(), nrows, ncols); + cuBool_Matrix_Build(automaton.back(), rows.data(), cols.data(), vals.size(), CUBOOL_HINT_NO); + + automaton_rows = std::max(automaton_rows, (cuBool_Index)nrows); + } + + // temporary hardcoded + source_vertices = {0}; + start_states = {0}; + + source_vertices = config.sources; + for (cuBool_Index &s : source_vertices) { + s--; + } + + auto answer = regular_path_query(graph, source_vertices, automaton, start_states); + + cuBool_Vector P, F; + cuBool_Vector_New(&P, graph_rows); + cuBool_Vector_New(&F, automaton_rows); + + std::vector final_states(automaton_rows); + std::iota(final_states.begin(), final_states.end(), 0); + + cuBool_Vector_Build(F, final_states.data(), final_states.size(), CUBOOL_HINT_NO); + cuBool_VxM(P, F, answer, CUBOOL_HINT_NO); + uint32_t result = 0; + cuBool_Vector_Nvals(P, &result); + + bool test_result = true; + + // validate answer + cuBool_Index nvals; + cuBool_Matrix_Nvals(answer, &nvals); + rows.resize(nvals); + cols.resize(nvals); + cuBool_Matrix_ExtractPairs(answer, rows.data(), cols.data(), &nvals); + + std::set> indexes {}; + for (int i = 0; i < nvals; i++) { + indexes.insert({rows[i], cols[i]}); + } + + std::ifstream expected_file(config.expexted.data()); + cuBool_Index expected_nvals; + expected_file >> expected_nvals; + + if (expected_nvals != nvals) { + test_result = false; + } else { + for (int k = 0; k < expected_nvals; k++) { + int i, j; + expected_file >> i >> j; + if (!indexes.contains({i, j})) { + test_result = false; + break; + } + } + } + + cuBool_Vector_Free(F); + cuBool_Vector_Free(P); + cuBool_Matrix_Free(answer); + + for (auto matrix : graph) { + if (matrix != nullptr) { + cuBool_Matrix_Free(matrix); + } + } + for (auto matrix : automaton) { + if (matrix != nullptr) { + cuBool_Matrix_Free(matrix); + } + } + + cuBool_Finalize(); + + return test_result; +} + +static std::string get_path(std::string_view file) { + return std::format("{}/rpq/{}", TESTS_DATA_PATH, file); +} + +TEST(RPQ, Tests) { + std::vector configs { + { + .graph_data = {get_path("a.mtx"), get_path("b.mtx")}, + .automaton_data {get_path("1/a.mtx"), ""}, + .sources = {1}, + .expexted = get_path("1/expected.txt"), + }, + { + .graph_data = {get_path("a.mtx"), get_path("b.mtx")}, + .automaton_data {get_path("2/a.mtx"), get_path("2/b.mtx")}, + .sources = {2}, + .expexted = get_path("2/expected.txt"), + }, + { + .graph_data = {get_path("a.mtx"), get_path("b.mtx")}, + .automaton_data {get_path("3/a.mtx"), get_path("3/b.mtx")}, + .sources = {3, 6}, + .expexted = get_path("3/expected.txt"), + }, + { + .graph_data = {get_path("a.mtx"), get_path("b.mtx")}, + .automaton_data {"", get_path("4/b.mtx")}, + .sources = {4}, + .expexted = get_path("4/expected.txt"), + }, + { + .graph_data = {get_path("5/graph_a.mtx"), get_path("5/graph_b.mtx")}, + .automaton_data = {get_path("5/automaton_a.mtx"), get_path("5/automaton_b.mtx")}, + .sources = {1}, + .expexted = get_path("5/expected.txt"), + }, + }; + + for (const auto &config : configs) { + EXPECT_TRUE(test_on_config(config)); + } +} diff --git a/tests/test_data/rpq/1/a.mtx b/tests/test_data/rpq/1/a.mtx new file mode 100644 index 0000000..8380171 --- /dev/null +++ b/tests/test_data/rpq/1/a.mtx @@ -0,0 +1,5 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +2 2 2 +1 2 +2 2 diff --git a/tests/test_data/rpq/1/expected.txt b/tests/test_data/rpq/1/expected.txt new file mode 100644 index 0000000..90ee102 --- /dev/null +++ b/tests/test_data/rpq/1/expected.txt @@ -0,0 +1,6 @@ +5 +0 0 +1 1 +1 3 +1 5 +1 6 diff --git a/tests/test_data/rpq/1/meta.txt b/tests/test_data/rpq/1/meta.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/test_data/rpq/1/meta.txt @@ -0,0 +1 @@ +1 diff --git a/tests/test_data/rpq/1/sources.txt b/tests/test_data/rpq/1/sources.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/test_data/rpq/1/sources.txt @@ -0,0 +1 @@ +1 diff --git a/tests/test_data/rpq/2/a.mtx b/tests/test_data/rpq/2/a.mtx new file mode 100644 index 0000000..f7ac6c7 --- /dev/null +++ b/tests/test_data/rpq/2/a.mtx @@ -0,0 +1,4 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +2 2 1 +2 1 diff --git a/tests/test_data/rpq/2/b.mtx b/tests/test_data/rpq/2/b.mtx new file mode 100644 index 0000000..ed1f348 --- /dev/null +++ b/tests/test_data/rpq/2/b.mtx @@ -0,0 +1,4 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +2 2 1 +1 2 diff --git a/tests/test_data/rpq/2/expected.txt b/tests/test_data/rpq/2/expected.txt new file mode 100644 index 0000000..123ace6 --- /dev/null +++ b/tests/test_data/rpq/2/expected.txt @@ -0,0 +1,7 @@ +6 +0 1 +0 5 +0 7 +1 2 +1 4 +1 6 diff --git a/tests/test_data/rpq/2/meta.txt b/tests/test_data/rpq/2/meta.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/test_data/rpq/2/meta.txt @@ -0,0 +1 @@ +1 diff --git a/tests/test_data/rpq/2/sources.txt b/tests/test_data/rpq/2/sources.txt new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/test_data/rpq/2/sources.txt @@ -0,0 +1 @@ +2 diff --git a/tests/test_data/rpq/3/a.mtx b/tests/test_data/rpq/3/a.mtx new file mode 100644 index 0000000..1c0006d --- /dev/null +++ b/tests/test_data/rpq/3/a.mtx @@ -0,0 +1,4 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +2 2 1 +1 1 diff --git a/tests/test_data/rpq/3/b.mtx b/tests/test_data/rpq/3/b.mtx new file mode 100644 index 0000000..1c0006d --- /dev/null +++ b/tests/test_data/rpq/3/b.mtx @@ -0,0 +1,4 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +2 2 1 +1 1 diff --git a/tests/test_data/rpq/3/expected.txt b/tests/test_data/rpq/3/expected.txt new file mode 100644 index 0000000..99c95bc --- /dev/null +++ b/tests/test_data/rpq/3/expected.txt @@ -0,0 +1,3 @@ +2 +0 2 +0 5 diff --git a/tests/test_data/rpq/3/meta.txt b/tests/test_data/rpq/3/meta.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/test_data/rpq/3/meta.txt @@ -0,0 +1 @@ +1 diff --git a/tests/test_data/rpq/3/sources.txt b/tests/test_data/rpq/3/sources.txt new file mode 100644 index 0000000..677154a --- /dev/null +++ b/tests/test_data/rpq/3/sources.txt @@ -0,0 +1 @@ +3 6 diff --git a/tests/test_data/rpq/4/b.mtx b/tests/test_data/rpq/4/b.mtx new file mode 100644 index 0000000..710a1f6 --- /dev/null +++ b/tests/test_data/rpq/4/b.mtx @@ -0,0 +1,11 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +6 6 8 +1 2 +2 3 +3 4 +3 5 +3 6 +4 5 +4 6 +5 6 diff --git a/tests/test_data/rpq/4/expected.txt b/tests/test_data/rpq/4/expected.txt new file mode 100644 index 0000000..912b22f --- /dev/null +++ b/tests/test_data/rpq/4/expected.txt @@ -0,0 +1,16 @@ +15 +0 3 +1 3 +1 5 +2 2 +2 3 +2 5 +3 2 +3 3 +3 5 +4 2 +4 3 +4 5 +5 2 +5 3 +5 5 diff --git a/tests/test_data/rpq/4/meta.txt b/tests/test_data/rpq/4/meta.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/test_data/rpq/4/meta.txt @@ -0,0 +1 @@ +1 diff --git a/tests/test_data/rpq/4/sources.txt b/tests/test_data/rpq/4/sources.txt new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/tests/test_data/rpq/4/sources.txt @@ -0,0 +1 @@ +4 diff --git a/tests/test_data/rpq/5/automaton_a.mtx b/tests/test_data/rpq/5/automaton_a.mtx new file mode 100644 index 0000000..b8658be --- /dev/null +++ b/tests/test_data/rpq/5/automaton_a.mtx @@ -0,0 +1,4 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +3 3 1 +1 2 diff --git a/tests/test_data/rpq/5/automaton_b.mtx b/tests/test_data/rpq/5/automaton_b.mtx new file mode 100644 index 0000000..e34be5b --- /dev/null +++ b/tests/test_data/rpq/5/automaton_b.mtx @@ -0,0 +1,5 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +3 3 2 +1 1 +2 3 diff --git a/tests/test_data/rpq/5/expected.txt b/tests/test_data/rpq/5/expected.txt new file mode 100644 index 0000000..f611677 --- /dev/null +++ b/tests/test_data/rpq/5/expected.txt @@ -0,0 +1,5 @@ +4 +0 0 +0 3 +1 1 +2 2 diff --git a/tests/test_data/rpq/5/graph_a.mtx b/tests/test_data/rpq/5/graph_a.mtx new file mode 100644 index 0000000..937af5b --- /dev/null +++ b/tests/test_data/rpq/5/graph_a.mtx @@ -0,0 +1,5 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +4 4 2 +1 2 +3 1 diff --git a/tests/test_data/rpq/5/graph_b.mtx b/tests/test_data/rpq/5/graph_b.mtx new file mode 100644 index 0000000..b04a14a --- /dev/null +++ b/tests/test_data/rpq/5/graph_b.mtx @@ -0,0 +1,6 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +4 4 3 +2 3 +1 4 +4 1 diff --git a/tests/test_data/rpq/a.mtx b/tests/test_data/rpq/a.mtx new file mode 100644 index 0000000..e764eca --- /dev/null +++ b/tests/test_data/rpq/a.mtx @@ -0,0 +1,9 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +8 8 6 +1 2 +1 7 +2 4 +3 6 +5 8 +7 6 diff --git a/tests/test_data/rpq/b.mtx b/tests/test_data/rpq/b.mtx new file mode 100644 index 0000000..489de4a --- /dev/null +++ b/tests/test_data/rpq/b.mtx @@ -0,0 +1,10 @@ +%%MatrixMarket matrix coordinate pattern general +%%GraphBLAS type bool +8 8 7 +1 3 +2 5 +2 7 +4 4 +4 6 +5 1 +6 3