diff --git a/include/graph/algorithm/connected_components.hpp b/include/graph/algorithm/connected_components.hpp index e68f633..f38dd53 100644 --- a/include/graph/algorithm/connected_components.hpp +++ b/include/graph/algorithm/connected_components.hpp @@ -21,6 +21,7 @@ #include "graph/views/breadth_first_search.hpp" #include #include +#include #ifndef GRAPH_CC_HPP # define GRAPH_CC_HPP diff --git a/include/graph/container/compressed_graph.hpp b/include/graph/container/compressed_graph.hpp index 5f18d94..2b9ede8 100644 --- a/include/graph/container/compressed_graph.hpp +++ b/include/graph/container/compressed_graph.hpp @@ -171,8 +171,8 @@ class csr_row_values { //requires views::copyable_vertex>, VId, VV> constexpr void load_row_values(const VRng& vrng, VProj projection, size_type vertex_count) { if constexpr (sized_range) - vertex_count = max(vertex_count, size(vrng)); - resize(size(vrng)); + vertex_count = max(vertex_count, std::ranges::size(vrng)); + resize(std::ranges::size(vrng)); for (auto&& vtx : vrng) { const auto& [id, value] = projection(vtx); @@ -745,14 +745,11 @@ class compressed_graph_base * @param vrng Input vertex range * @param eprojection Edge projection function object * @param vprojection Vertex projection function object - * @param partition_start_ids Range of starting vertex ids for each partition. If empty, all vertices are in partition 0. */ template - requires convertible_to, VId> //requires views::copyable_edge>, VId, EV> && // views::copyable_vertex>, VId, VV> constexpr void load(const ERng& erng, const VRng& vrng, EProj eprojection = {}, VProj vprojection = {}) { diff --git a/include/graph/container/container_utility.hpp b/include/graph/container/container_utility.hpp index 2cac167..493ab89 100644 --- a/include/graph/container/container_utility.hpp +++ b/include/graph/container/container_utility.hpp @@ -82,8 +82,8 @@ constexpr auto push_or_insert(C& container) { template requires has_array_operator constexpr auto assign_or_insert(C& container) { - if constexpr (random_access_range) { - static_assert(sized_range, "random_access container is assumed to have size()"); + if constexpr (::std::ranges::random_access_range) { + static_assert(::std::ranges::sized_range, "random_access container is assumed to have size()"); return [&container](const K& id, typename C::value_type&& value) { typename C::size_type k = static_cast(id); assert(k < container.size()); @@ -99,8 +99,8 @@ constexpr auto assign_or_insert(C& container) { // ERng is a forward_range because it is traversed twice; once to get the max vertex_id // and a second time to load the edges. template -concept edge_value_extractor = forward_range && invocable && - invocable; +concept edge_value_extractor = std::ranges::forward_range && ::std::invocable && + ::std::invocable; namespace detail { //-------------------------------------------------------------------------------------- diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 97f8784..93cb31e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -62,6 +62,7 @@ set(UNITTEST_SOURCES "descriptor_tests.cpp" "tests.cpp" + "compressed_graph_tests.cpp" ) foreach(SOURCE IN LISTS UNITTEST_SOURCES) diff --git a/tests/compressed_graph_tests.cpp b/tests/compressed_graph_tests.cpp new file mode 100644 index 0000000..7025245 --- /dev/null +++ b/tests/compressed_graph_tests.cpp @@ -0,0 +1,38 @@ +// Copyright (C) 2025 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include "graph/container/compressed_graph.hpp" +#include +#include + +// A +// 0.8 / \ 0.4 +// B C +// 0.1 \ / 0.2 +// D + +const std::vector> ve { + {0, 1, 0.8}, {0, 2, 0.4}, {1, 3, 0.1}, {2, 3, 0.2} +}; + +const std::vector> vv { + {0, "A"}, {1, "B"}, {2, "C"}, {3, "D"} +}; + +TEST_CASE("compressed_graph constructor", "[compressed_graph]") { + using graph_t = graph::container::compressed_graph; + const graph_t g(ve, vv); + + std::vector vertex_names; + + for (graph_t::vertex_type const& u : vertices(g)) + vertex_names.push_back(vertex_value(g, u)); + + REQUIRE(vertex_names == std::vector{"A", "B", "C", "D"}); +} +