|
9 | 9 | #include "impl/impl_tags.hpp" |
10 | 10 | #include "io/stream_options_manipulator.hpp" |
11 | 11 | #include "types/iterator_range.hpp" |
| 12 | +#include "views.hpp" |
12 | 13 |
|
13 | 14 | #include <set> |
14 | 15 |
|
@@ -83,10 +84,10 @@ class graph final { |
83 | 84 | [[nodiscard]] gl_attr_force_inline auto vertices() const |
84 | 85 | requires(not type_traits::is_default_properties_type_v<vertex_properties_type>) |
85 | 86 | { |
86 | | - return std::views::enumerate(this->_vertex_properties) |
87 | | - | std::views::transform([](const auto& vertex_data) { |
88 | | - const auto& [id, properties_ptr] = vertex_data; |
89 | | - return vertex_descriptor{static_cast<types::id_type>(id), *properties_ptr}; |
| 87 | + return this->_vertex_properties | std::views::enumerate |
| 88 | + | std::views::transform([](const auto& x) { |
| 89 | + const auto& [id, ptr] = x; |
| 90 | + return vertex_descriptor{static_cast<types::id_type>(id), *ptr}; |
90 | 91 | }); |
91 | 92 | } |
92 | 93 |
|
@@ -123,7 +124,6 @@ class graph final { |
123 | 124 | if constexpr (type_traits::is_default_properties_type_v<vertex_properties_type>) |
124 | 125 | return vertex_descriptor{new_vertex_id}; |
125 | 126 | else { |
126 | | - // ensure a properties object is created for the new vertex |
127 | 127 | this->_vertex_properties.push_back(std::make_unique<vertex_properties_type>()); |
128 | 128 | return vertex_descriptor{new_vertex_id, *this->_vertex_properties.back()}; |
129 | 129 | } |
@@ -259,6 +259,12 @@ class graph final { |
259 | 259 | return this->_impl.degree_map(); |
260 | 260 | } |
261 | 261 |
|
| 262 | + [[nodiscard]] gl_attr_force_inline auto vertex_properties_map() const noexcept |
| 263 | + requires(not type_traits::is_default_properties_type_v<vertex_properties_type>) |
| 264 | + { |
| 265 | + return views::deref(this->_vertex_properties); |
| 266 | + } |
| 267 | + |
262 | 268 | // --- edge methods --- |
263 | 269 |
|
264 | 270 | // clang-format off |
@@ -514,7 +520,6 @@ class graph final { |
514 | 520 | this->_n_vertices--; |
515 | 521 |
|
516 | 522 | // update vertex ids in edges |
517 | | - // TODO: add tests |
518 | 523 | for (auto id : this->vertex_ids()) { |
519 | 524 | for (auto& edge : this->_impl.adjacent_edges(id)) { |
520 | 525 | edge._vertices.first._id -= (edge._vertices.first._id > vertex_id); |
|
0 commit comments