Skip to content

Commit 1f2cf4b

Browse files
committed
gl alignment
1 parent 742b5ba commit 1f2cf4b

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

include/gl/impl/adjacency_matrix.hpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ class adjacency_matrix final {
107107
}
108108

109109
[[nodiscard]] gl_attr_force_inline bool has_edge(id_type source_id, id_type target_id) const {
110-
return specialized_impl::get_edge_id(*this, source_id, target_id) != invalid_id;
110+
return specialized_impl::get_entry(*this, source_id, target_id) != invalid_id;
111111
}
112112

113113
[[nodiscard]] bool has_edge(const edge_type& edge) const {
114-
return specialized_impl::get_edge_id(*this, edge.source(), edge.target()) == edge.id();
114+
return specialized_impl::get_entry(*this, edge.source(), edge.target()) == edge.id();
115115
}
116116

117117
[[nodiscard]] std::optional<edge_type> get_edge(id_type source_id, id_type target_id) const
118118
requires(traits::c_has_empty_properties<edge_type>)
119119
{
120-
const auto edge_id = specialized_impl::get_edge_id(*this, source_id, target_id);
120+
const auto edge_id = specialized_impl::get_entry(*this, source_id, target_id);
121121
if (edge_id == invalid_id)
122122
return std::nullopt;
123123
return std::make_optional<edge_type>(edge_id, source_id, target_id);
@@ -128,7 +128,7 @@ class adjacency_matrix final {
128128
) const
129129
requires(traits::c_has_non_empty_properties<edge_type>)
130130
{
131-
const auto edge_id = specialized_impl::get_edge_id(*this, source_id, target_id);
131+
const auto edge_id = specialized_impl::get_entry(*this, source_id, target_id);
132132
if (edge_id == invalid_id)
133133
return std::nullopt;
134134
return std::make_optional<edge_type>(
@@ -139,7 +139,7 @@ class adjacency_matrix final {
139139
[[nodiscard]] std::vector<edge_type> get_edges(id_type source_id, id_type target_id) const
140140
requires(traits::c_has_empty_properties<edge_type>)
141141
{
142-
const auto edge_id = specialized_impl::get_edge_id(*this, source_id, target_id);
142+
const auto edge_id = specialized_impl::get_entry(*this, source_id, target_id);
143143
if (edge_id == invalid_id)
144144
return std::vector<edge_type>();
145145
return std::vector<edge_type>{
@@ -152,7 +152,7 @@ class adjacency_matrix final {
152152
) const
153153
requires(traits::c_has_non_empty_properties<edge_type>)
154154
{
155-
const auto edge_id = specialized_impl::get_edge_id(*this, source_id, target_id);
155+
const auto edge_id = specialized_impl::get_entry(*this, source_id, target_id);
156156
if (edge_id == invalid_id)
157157
return std::vector<edge_type>();
158158
return std::vector<edge_type>{
@@ -197,11 +197,13 @@ class adjacency_matrix final {
197197
{
198198
return std::views::iota(initial_id_v<id_type>, this->_matrix.size())
199199
| std::views::filter([this, vertex_id](const auto source_id) {
200-
return this->_matrix[to_idx(source_id)][to_idx(vertex_id)] != invalid_id;
200+
return specialized_impl::get_entry(*this, source_id, vertex_id) != invalid_id;
201201
})
202202
| std::views::transform([this, vertex_id](const auto source_id) {
203203
return edge_type{
204-
this->_matrix[to_idx(source_id)][to_idx(vertex_id)], source_id, vertex_id
204+
specialized_impl::get_entry(*this, source_id, vertex_id),
205+
source_id,
206+
vertex_id
205207
};
206208
});
207209
}
@@ -213,10 +215,10 @@ class adjacency_matrix final {
213215
{
214216
return std::views::iota(initial_id_v<id_type>, this->_matrix.size())
215217
| std::views::filter([this, vertex_id](const auto source_id) {
216-
return this->_matrix[to_idx(source_id)][to_idx(vertex_id)] != invalid_id;
218+
return specialized_impl::get_entry(*this, source_id, vertex_id) != invalid_id;
217219
})
218220
| std::views::transform([this, vertex_id, &edge_properties_map](const auto source_id) {
219-
const auto edge_id = this->_matrix[to_idx(source_id)][to_idx(vertex_id)];
221+
const auto edge_id = specialized_impl::get_entry(*this, source_id, vertex_id);
220222
return edge_type{
221223
edge_id, source_id, vertex_id, *edge_properties_map[to_idx(edge_id)]
222224
};

include/gl/impl/specialized/adjacency_matrix.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ struct directed_adjacency_matrix {
165165
return removed_edges;
166166
}
167167

168-
static id_type get_edge_id(const impl_type& self, id_type source_id, id_type target_id) {
168+
static id_type get_entry(const impl_type& self, id_type source_id, id_type target_id) {
169169
return self._matrix[to_idx(source_id)][to_idx(target_id)];
170170
}
171171

@@ -289,7 +289,7 @@ struct undirected_adjacency_matrix {
289289
return removed_edges;
290290
}
291291

292-
static id_type get_edge_id(const impl_type& self, id_type source_id, id_type target_id) {
292+
static id_type get_entry(const impl_type& self, id_type source_id, id_type target_id) {
293293
return self._matrix[to_idx(source_id)][to_idx(target_id)];
294294
}
295295

include/gl/impl/specialized/flat_adjacency_matrix.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ struct directed_flat_adjacency_matrix {
9797
const auto row = self._matrix[vertex_idx];
9898
const auto col = self._matrix.col(vertex_idx);
9999

100-
for (auto v_idx = 0uz; v_idx < self._matrix.n_rows(); ++v_idx)
101-
deg += static_cast<size_type>(row[v_idx] != invalid_id)
102-
+ static_cast<size_type>(col[static_cast<std::ptrdiff_t>(v_idx)] != invalid_id);
100+
const auto n_rows_bound = to_diff(self._matrix.n_rows());
101+
for (auto v_pos = 0z; v_pos < n_rows_bound; ++v_pos)
102+
deg += static_cast<size_type>(row[v_pos] != invalid_id)
103+
+ static_cast<size_type>(col[v_pos] != invalid_id);
103104

104105
return deg;
105106
}
@@ -152,7 +153,7 @@ struct directed_flat_adjacency_matrix {
152153
if (r_idx == vertex_idx)
153154
continue;
154155

155-
const auto edge_id = col[static_cast<std::ptrdiff_t>(r_idx)];
156+
const auto edge_id = col[to_diff(r_idx)];
156157
if (edge_id != invalid_id)
157158
removed_edges.push_back(edge_id);
158159
}
@@ -164,7 +165,7 @@ struct directed_flat_adjacency_matrix {
164165
return removed_edges;
165166
}
166167

167-
static id_type get_edge_id(const impl_type& self, id_type source_id, id_type target_id) {
168+
static id_type get_entry(const impl_type& self, id_type source_id, id_type target_id) {
168169
return self._matrix[to_idx(source_id), to_idx(target_id)];
169170
}
170171

@@ -281,7 +282,7 @@ struct undirected_flat_adjacency_matrix {
281282
return removed_edges;
282283
}
283284

284-
static id_type get_edge_id(const impl_type& self, id_type source_id, id_type target_id) {
285+
static id_type get_entry(const impl_type& self, id_type source_id, id_type target_id) {
285286
return self._matrix[to_idx(source_id), to_idx(target_id)];
286287
}
287288

0 commit comments

Comments
 (0)