Skip to content

Commit 5d27f69

Browse files
committed
removed graph.at
1 parent 7b2a2f6 commit 5d27f69

5 files changed

Lines changed: 5 additions & 124 deletions

File tree

include/gl/graph.hpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class graph final {
392392
);
393393
}
394394

395-
gl_attr_force_inline void add_edges_from(
395+
void add_edges_from(
396396
const vertex_type& source, const traits::c_sized_range_of<vertex_type> auto& target_rng
397397
) {
398398
this->_verify_vertex_id(source.id());
@@ -473,9 +473,7 @@ class graph final {
473473
return this->out_edges(vertex.id());
474474
}
475475

476-
[[nodiscard]] gl_attr_force_inline bool has_edge(
477-
const id_type source_id, const id_type target_id
478-
) const {
476+
[[nodiscard]] bool has_edge(const id_type source_id, const id_type target_id) const {
479477
this->_verify_vertex_id(source_id);
480478
this->_verify_vertex_id(target_id);
481479
return this->_impl.has_edge(source_id, target_id);
@@ -491,7 +489,7 @@ class graph final {
491489
return this->_impl.has_edge(edge);
492490
}
493491

494-
[[nodiscard]] gl_attr_force_inline std::optional<edge_type> get_edge(
492+
[[nodiscard]] std::optional<edge_type> get_edge(
495493
const id_type source_id, const id_type target_id
496494
) const {
497495
this->_verify_vertex_id(source_id);
@@ -597,20 +595,6 @@ class graph final {
597595
return *this->_edge_properties[id];
598596
}
599597

600-
// --- access operators ---
601-
602-
[[nodiscard]] inline auto at(const id_type vertex_id) const {
603-
this->_verify_vertex_id(vertex_id);
604-
if constexpr (traits::c_non_empty_properties<edge_properties_type>)
605-
return this->_impl.at(vertex_id, this->_edge_properties);
606-
else
607-
return this->_impl.at(vertex_id);
608-
}
609-
610-
[[nodiscard]] gl_attr_force_inline auto at(const vertex_type& vertex) const {
611-
return this->at(vertex.id());
612-
}
613-
614598
// --- comparison ---
615599

616600
[[nodiscard]] friend bool operator==(const graph& lhs, const graph& rhs) noexcept {

include/gl/impl/adjacency_list.hpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class adjacency_list final {
121121
specialized_impl::add_edges_from(*this, edge_ids, source_id, target_ids);
122122
}
123123

124-
gl_attr_force_inline void remove_edge(const edge_type& edge) {
124+
void remove_edge(const edge_type& edge) {
125125
specialized_impl::remove_edge(*this, edge);
126126
for (auto&& inc : this->_list)
127127
for (auto& item : inc)
@@ -270,21 +270,6 @@ class adjacency_list final {
270270
});
271271
}
272272

273-
// --- access operators ---
274-
275-
[[nodiscard]] gl_attr_force_inline auto at(id_type vertex_id) const
276-
requires(traits::c_has_empty_properties<edge_type>)
277-
{
278-
return this->out_edges(vertex_id);
279-
}
280-
281-
[[nodiscard]] gl_attr_force_inline auto at(id_type vertex_id, const auto& edge_properties_map)
282-
const
283-
requires(traits::c_has_non_empty_properties<edge_type>)
284-
{
285-
return this->out_edges(vertex_id, edge_properties_map);
286-
}
287-
288273
// --- comparison ---
289274

290275
[[nodiscard]] friend bool operator==(const adjacency_list&, const adjacency_list&) = default;

include/gl/impl/adjacency_matrix.hpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class adjacency_matrix final {
123123
specialized_impl::add_edges_from(*this, edge_ids, source_id, target_ids);
124124
}
125125

126-
gl_attr_force_inline void remove_edge(const edge_type& edge) {
126+
void remove_edge(const edge_type& edge) {
127127
specialized_impl::remove_edge(*this, edge);
128128
for (auto&& row : this->_matrix)
129129
for (auto& edge_id : row)
@@ -279,38 +279,6 @@ class adjacency_matrix final {
279279
});
280280
}
281281

282-
// --- access operators ---
283-
284-
[[nodiscard]] gl_attr_force_inline auto at(id_type vertex_id) const
285-
requires(traits::c_has_empty_properties<edge_type>)
286-
{
287-
return this->_matrix[to_idx(vertex_id)] | std::views::enumerate
288-
| std::views::transform([vertex_id](const auto& edge_info) {
289-
const auto& [target_id, edge_id] = edge_info;
290-
return edge_id == invalid_id
291-
? edge_type::invalid()
292-
: edge_type{edge_id, vertex_id, static_cast<id_type>(target_id)};
293-
});
294-
}
295-
296-
[[nodiscard]] gl_attr_force_inline auto at(id_type vertex_id, const auto& edge_properties_map)
297-
const
298-
requires(traits::c_has_non_empty_properties<edge_type>)
299-
{
300-
return this->_matrix[to_idx(vertex_id)] | std::views::enumerate
301-
| std::views::transform([vertex_id, &edge_properties_map](const auto& edge_info) {
302-
const auto& [target_id, edge_id] = edge_info;
303-
return edge_id == invalid_id
304-
? edge_type::invalid()
305-
: edge_type{
306-
edge_id,
307-
vertex_id,
308-
static_cast<id_type>(target_id),
309-
*edge_properties_map[to_idx(edge_id)]
310-
};
311-
});
312-
}
313-
314282
// --- comparison ---
315283

316284
[[nodiscard]] friend bool operator==(const adjacency_matrix&, const adjacency_matrix&) =

tests/source/gl/test_adjacency_list.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,6 @@ TEST_CASE_TEMPLATE_DEFINE("directed adjacency list tests", SutType, directed_adj
459459
CHECK(std::ranges::contains(out_edges, edge1));
460460
CHECK(std::ranges::contains(out_edges, edge2));
461461
}
462-
463-
// --- access operators ---
464-
465-
SUBCASE("at should return the incident edges of a vertex") {
466-
init_complete_graph();
467-
for (const auto vertex_id : std::views::iota(constants::v1_id, constants::n_elements))
468-
CHECK(std::ranges::equal(sut.at(vertex_id), sut.out_edges(vertex_id)));
469-
}
470462
}
471463

472464
TEST_CASE_TEMPLATE_INSTANTIATE(
@@ -791,14 +783,6 @@ TEST_CASE_TEMPLATE_DEFINE("undirected adjacency list tests", SutType, undirected
791783
CHECK(std::ranges::equal(sut.in_edges(constants::v1_id), expected_edges));
792784
CHECK(std::ranges::equal(sut.out_edges(constants::v1_id), expected_edges));
793785
}
794-
795-
// --- access operators ---
796-
797-
SUBCASE("at should return the incident edges of a vertex") {
798-
init_complete_graph();
799-
for (const auto vertex_id : std::views::iota(constants::v1_id, constants::n_elements))
800-
CHECK(std::ranges::equal(sut.at(vertex_id), sut.incident_edges(vertex_id)));
801-
}
802786
}
803787

804788
TEST_CASE_TEMPLATE_INSTANTIATE(

tests/source/gl/test_adjacency_matrix.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -477,23 +477,6 @@ TEST_CASE_TEMPLATE_DEFINE("directed adjacency matrix tests", SutType, directed_a
477477
CHECK(std::ranges::contains(out_edges, edge1));
478478
CHECK(std::ranges::contains(out_edges, edge2));
479479
}
480-
481-
// --- access operators ---
482-
483-
SUBCASE("at should return a view equivalent to the matrix row of the given vertex") {
484-
for (const auto vertex_id : std::views::iota(constants::v1_id, constants::n_elements)) {
485-
const auto target_id =
486-
static_cast<gl::default_id_type>((vertex_id + 1u) % constants::n_elements);
487-
const auto edge = add_edge(vertex_id, target_id);
488-
auto row_view = sut.at(vertex_id);
489-
490-
REQUIRE_EQ(std::ranges::count_if(row_view, &edge_type::is_valid), 1uz);
491-
492-
const auto edge_it = std::ranges::find_if(row_view, &edge_type::is_valid);
493-
REQUIRE_NE(edge_it, row_view.end());
494-
REQUIRE_EQ(*edge_it, edge);
495-
}
496-
}
497480
}
498481

499482
TEST_CASE_TEMPLATE_INSTANTIATE(
@@ -814,29 +797,6 @@ TEST_CASE_TEMPLATE_DEFINE(
814797
CHECK(std::ranges::equal(sut.in_edges(constants::v1_id), expected_edges));
815798
CHECK(std::ranges::equal(sut.out_edges(constants::v1_id), expected_edges));
816799
}
817-
818-
// --- access operators ---
819-
820-
SUBCASE("at should return a view equivalent to the matrix row of the given vertex") {
821-
const auto edge1 = add_edge(constants::v1_id, constants::v2_id);
822-
const auto edge2 = add_edge(constants::v2_id, constants::v3_id);
823-
const auto edge3 = add_edge(constants::v3_id, constants::v1_id);
824-
825-
auto v1_row_view = sut.at(constants::v1_id);
826-
REQUIRE_EQ(std::ranges::count_if(v1_row_view, &edge_type::is_valid), 2uz);
827-
CHECK_EQ(v1_row_view[constants::v2_id], edge1);
828-
CHECK_EQ(v1_row_view[constants::v3_id], edge3);
829-
830-
auto v2_row_view = sut.at(constants::v2_id);
831-
REQUIRE_EQ(std::ranges::count_if(v2_row_view, &edge_type::is_valid), 2uz);
832-
CHECK_EQ(v2_row_view[constants::v1_id], edge1);
833-
CHECK_EQ(v2_row_view[constants::v3_id], edge2);
834-
835-
auto v3_row_view = sut.at(constants::v3_id);
836-
REQUIRE_EQ(std::ranges::count_if(v3_row_view, &edge_type::is_valid), 2uz);
837-
CHECK_EQ(v3_row_view[constants::v1_id], edge3);
838-
CHECK_EQ(v3_row_view[constants::v2_id], edge2);
839-
}
840800
}
841801

842802
TEST_CASE_TEMPLATE_INSTANTIATE(

0 commit comments

Comments
 (0)