@@ -27,18 +27,21 @@ class adjacency_matrix;
2727
2828namespace detail {
2929
30- // TODO: rename to get_edge_id or sth
3130template <traits::c_api_policy_tag ApiPolicyTag>
3231[[nodiscard]] auto & get_edge_entry (auto & id_matrix, const auto & edge) {
3332 // get the edge and validate the address
3433 const auto [source_id, target_id] = edge.incident_vertices ();
3534 auto & edge_id = id_matrix[to_idx (source_id)][to_idx (target_id)];
3635
37- if constexpr (std::same_as<ApiPolicyTag, api::strict_t >)
36+ if constexpr (std::same_as<ApiPolicyTag, api::strict_t >) {
3837 if (edge.id () != edge_id)
3938 throw std::invalid_argument (std::format (
4039 " Got invalid edge [id = {} | vertices = ({}, {})]" , edge.id (), source_id, target_id
4140 ));
41+ }
42+ else {
43+ [[assume(edge.id() == edge_id)]] ;
44+ }
4245
4346 return edge_id;
4447}
@@ -47,7 +50,7 @@ template <traits::c_api_policy_tag ApiPolicyTag, traits::c_id_type IdType>
4750inline void check_edge_override (
4851 const auto & id_matrix, const IdType source_id, const IdType target_id
4952) {
50- if constexpr (std::same_as<ApiPolicyTag, api::strict_t >)
53+ if constexpr (std::same_as<ApiPolicyTag, api::strict_t >) {
5154 if (const auto edge_id = id_matrix[to_idx (source_id)][to_idx (target_id)];
5255 edge_id != invalid_id)
5356 throw std::logic_error (std::format (
@@ -56,6 +59,10 @@ inline void check_edge_override(
5659 source_id,
5760 target_id
5861 ));
62+ }
63+ else {
64+ [[assume (id_matrix[to_idx (source_id)][to_idx (target_id)] == invalid_id)]];
65+ }
5966}
6067
6168} // namespace detail
0 commit comments