|
11 | 11 | #include "gl/types/types.hpp" |
12 | 12 | #include "specialized/adjacency_matrix.hpp" |
13 | 13 |
|
| 14 | +#ifdef GL_TESTING |
| 15 | +namespace gl_testing { |
| 16 | +struct test_adjacency_matrix; |
| 17 | +} // namespace gl_testing |
| 18 | +#endif |
| 19 | + |
| 20 | + |
14 | 21 | namespace gl::impl { |
15 | 22 |
|
16 | 23 | template <type_traits::c_matrix_graph_traits GraphTraits> |
@@ -164,30 +171,39 @@ class adjacency_matrix final { |
164 | 171 |
|
165 | 172 | [[nodiscard]] gl_attr_force_inline auto adjacent_edges(const types::id_type vertex_id) const { |
166 | 173 | return this->_matrix[vertex_id] | std::views::enumerate |
167 | | - | std::views::filter([](const auto target_id, const auto edge_id) { |
| 174 | + | std::views::filter([](const auto& edge_info) { |
| 175 | + const auto& [target_id, edge_id] = edge_info; |
168 | 176 | return edge_id != constants::invalid_id; |
169 | 177 | }) |
170 | | - | std::views::transform([vertex_id](const auto target_id, const auto edge_id) { |
171 | | - return edge_type{edge_id, vertex_id, target_id}; |
| 178 | + | std::views::transform([vertex_id](const auto& edge_info) { |
| 179 | + const auto& [target_id, edge_id] = edge_info; |
| 180 | + return edge_type{edge_id, vertex_id, static_cast<types::id_type>(target_id)}; |
172 | 181 | }); |
173 | 182 | } |
174 | 183 |
|
175 | 184 | [[nodiscard]] gl_attr_force_inline auto adjacent_edges( |
176 | 185 | const types::id_type vertex_id, const auto& edge_properties_map |
177 | 186 | ) const { |
178 | 187 | return this->_matrix[vertex_id] | std::views::enumerate |
179 | | - | std::views::filter([](const auto target_id, const auto edge_id) { |
| 188 | + | std::views::filter([](const auto& edge_info) { |
| 189 | + const auto& [target_id, edge_id] = edge_info; |
180 | 190 | return edge_id != constants::invalid_id; |
181 | 191 | }) |
182 | | - | std::views::transform( |
183 | | - [vertex_id, &edge_properties_map](const auto target_id, const auto edge_id) { |
184 | | - return edge_type{ |
185 | | - edge_id, vertex_id, target_id, edge_properties_map[edge_id] |
186 | | - }; |
187 | | - } |
188 | | - ); |
| 192 | + | std::views::transform([vertex_id, &edge_properties_map](const auto& edge_info) { |
| 193 | + const auto& [target_id, edge_id] = edge_info; |
| 194 | + return edge_type{ |
| 195 | + edge_id, |
| 196 | + vertex_id, |
| 197 | + static_cast<types::id_type>(target_id), |
| 198 | + edge_properties_map[edge_id] |
| 199 | + }; |
| 200 | + }); |
189 | 201 | } |
190 | 202 |
|
| 203 | +#ifdef GL_TESTING |
| 204 | + friend struct gl_testing::test_adjacency_matrix; |
| 205 | +#endif |
| 206 | + |
191 | 207 | private: |
192 | 208 | using specialized_impl = typename specialized::matrix_impl_traits<adjacency_matrix>::type; |
193 | 209 | friend specialized_impl; |
|
0 commit comments