Skip to content

Commit 94ff55c

Browse files
committed
initial renaming
1 parent 9f50cc5 commit 94ff55c

16 files changed

Lines changed: 212 additions & 211 deletions

include/gl/algorithm/spanning_tree/prim_mst.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ template <traits::c_undirected_graph G>
5151
if (root_id == invalid_id)
5252
root_id = initial_id;
5353

54-
for (const auto& edge : graph.adjacent_edges(root_id))
54+
for (const auto& edge : graph.incidenct_edges(root_id))
5555
edge_queue.emplace(edge);
5656

5757
// mark the root vertex as visited
@@ -75,7 +75,7 @@ template <traits::c_undirected_graph G>
7575
++n_vertices_in_mst;
7676

7777
// enqueue all edges adjacent to the `target` vertex if they lead to unvisited verties
78-
for (const auto& edge : graph.adjacent_edges(min_edge.target()))
78+
for (const auto& edge : graph.incidenct_edges(min_edge.target()))
7979
if (not visited[to_idx(edge.incident_vertex(min_edge.target()))])
8080
edge_queue.emplace(edge);
8181
}
@@ -132,7 +132,7 @@ requires traits::c_has_numeric_limits_max<vertex_distance_type<G>>
132132
}
133133

134134
// Update adjacent vertices
135-
for (const auto& edge : graph.adjacent_edges(vertex_id)) {
135+
for (const auto& edge : graph.incidenct_edges(vertex_id)) {
136136
const auto edge_weight = get_weight<G>(edge);
137137
const auto incident_vertex_idx = to_idx(edge.incident_vertex(vertex_id));
138138

include/gl/algorithm/templates/bfs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool bfs(
5555
if (not visit(node.vertex_id, node.pred_id))
5656
return false;
5757

58-
for (const auto& edge : graph.adjacent_edges(node.vertex_id)) {
58+
for (const auto& edge : graph.incidenct_edges(node.vertex_id)) {
5959
const auto incident_vertex_id = edge.incident_vertex(node.vertex_id);
6060

6161
const auto enqueue = enqueue_vertex_pred(incident_vertex_id, edge);

include/gl/algorithm/templates/dfs.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool dfs(
5555
if (not visit(node.vertex_id, node.pred_id))
5656
return false;
5757

58-
for (const auto& edge : graph.adjacent_edges(node.vertex_id)) {
58+
for (const auto& edge : graph.incidenct_edges(node.vertex_id)) {
5959
const auto incident_vertex_id = edge.incident_vertex(node.vertex_id);
6060
if (enqueue_vertex_pred(incident_vertex_id, edge))
6161
s.emplace(incident_vertex_id, node.vertex_id);
@@ -96,7 +96,7 @@ void r_dfs(
9696
visit(vertex_id, pred_id);
9797

9898
// recursively search vertices adjacent to the current vertex
99-
for (const auto& edge : graph.adjacent_edges(vertex_id)) {
99+
for (const auto& edge : graph.incidenct_edges(vertex_id)) {
100100
const auto& incident_vertex_id = edge.incident_vertex(vertex_id);
101101
if (enqueue_vertex_pred(incident_vertex_id, edge))
102102
r_dfs(

include/gl/algorithm/templates/pfs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool pfs(
5959
if (not visit(node.vertex_id, node.pred_id))
6060
return false;
6161

62-
for (const auto& edge : graph.adjacent_edges(node.vertex_id)) {
62+
for (const auto& edge : graph.incidenct_edges(node.vertex_id)) {
6363
const auto incident_vertex_id = edge.incident_vertex(node.vertex_id);
6464

6565
const auto enqueue = enqueue_vertex_pred(incident_vertex_id, edge);

include/gl/graph.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,16 @@ class graph final {
293293
return this->at(vertex.id());
294294
}
295295

296-
// TODO: rename to incident_edges
297-
[[nodiscard]] inline auto adjacent_edges(const id_type vertex_id) const {
296+
[[nodiscard]] inline auto incidenct_edges(const id_type vertex_id) const {
298297
this->_verify_vertex_id(vertex_id);
299298
if constexpr (traits::c_non_empty_properties<edge_properties_type>)
300-
return this->_impl.adjacent_edges(vertex_id, this->_edge_properties);
299+
return this->_impl.incidenct_edges(vertex_id, this->_edge_properties);
301300
else
302-
return this->_impl.adjacent_edges(vertex_id);
301+
return this->_impl.incidenct_edges(vertex_id);
303302
}
304303

305-
// TODO: rename to incident_edges
306-
[[nodiscard]] gl_attr_force_inline auto adjacent_edges(const vertex_type& vertex) const {
307-
return this->adjacent_edges(vertex.id());
304+
[[nodiscard]] gl_attr_force_inline auto incidenct_edges(const vertex_type& vertex) const {
305+
return this->incidenct_edges(vertex.id());
308306
}
309307

310308
[[nodiscard]] inline auto in_edges(const id_type vertex_id) const {
@@ -696,7 +694,7 @@ class graph final {
696694

697695
for (const auto& vertex : this->vertices()) {
698696
os << "- " << vertex << "\n adjacent edges:\n";
699-
for (const auto& edge : this->adjacent_edges(vertex.id()))
697+
for (const auto& edge : this->incidenct_edges(vertex.id()))
700698
os << "\t- " << edge << '\n';
701699
}
702700
}
@@ -706,7 +704,7 @@ class graph final {
706704

707705
for (const auto& vertex : this->vertices()) {
708706
os << "- " << vertex << " :";
709-
for (const auto& edge : this->adjacent_edges(vertex.id()))
707+
for (const auto& edge : this->incidenct_edges(vertex.id()))
710708
os << ' ' << edge;
711709
os << '\n';
712710
}
@@ -736,7 +734,7 @@ class graph final {
736734
if constexpr (traits::c_writable<typename edge_type::properties_type>) {
737735
if (with_edge_properties) {
738736
const auto print_incident_edges = [this, &os](const id_type vertex_id) {
739-
for (const auto& edge : this->adjacent_edges(vertex_id)) {
737+
for (const auto& edge : this->incidenct_edges(vertex_id)) {
740738
if (edge.source() != vertex_id)
741739
continue; // vertex is not the source
742740
os << edge.source() << ' ' << edge.target() << ' ' << edge.properties()
@@ -752,7 +750,7 @@ class graph final {
752750
}
753751

754752
const auto print_incident_edges = [this, &os](const id_type vertex_id) {
755-
for (const auto& edge : this->adjacent_edges(vertex_id)) {
753+
for (const auto& edge : this->incidenct_edges(vertex_id)) {
756754
if (edge.source() != vertex_id)
757755
continue; // vertex is not the source
758756
os << edge.source() << ' ' << edge.target() << '\n';

include/gl/impl/adjacency_list.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ class adjacency_list final {
120120
[[nodiscard]] std::optional<edge_type> get_edge(id_type source_id, id_type target_id) const
121121
requires(traits::c_has_empty_properties<edge_type>)
122122
{
123-
const auto& adjacent_edges = this->_list[to_idx(source_id)];
124-
const auto item_it = std::ranges::find(adjacent_edges, target_id, &item_type::vertex_id);
125-
if (item_it == adjacent_edges.cend())
123+
const auto& incidenct_edges = this->_list[to_idx(source_id)];
124+
const auto item_it = std::ranges::find(incidenct_edges, target_id, &item_type::vertex_id);
125+
if (item_it == incidenct_edges.cend())
126126
return std::nullopt;
127127
return std::make_optional<edge_type>(item_it->edge_id, source_id, target_id);
128128
}
@@ -132,11 +132,11 @@ class adjacency_list final {
132132
) const
133133
requires(traits::c_has_non_empty_properties<edge_type>)
134134
{
135-
const auto& adjacent_edges = this->_list[to_idx(source_id)];
136-
const auto item_it = std::ranges::find(adjacent_edges, target_id, [](const auto& item) {
135+
const auto& incidenct_edges = this->_list[to_idx(source_id)];
136+
const auto item_it = std::ranges::find(incidenct_edges, target_id, [](const auto& item) {
137137
return item.vertex_id;
138138
});
139-
if (item_it == adjacent_edges.cend())
139+
if (item_it == incidenct_edges.cend())
140140
return std::nullopt;
141141
return std::make_optional<edge_type>(
142142
item_it->edge_id, source_id, target_id, *edge_properties_map[to_idx(item_it->edge_id)]
@@ -188,13 +188,13 @@ class adjacency_list final {
188188
return removed_edge_ids;
189189
}
190190

191-
[[nodiscard]] gl_attr_force_inline auto adjacent_edges(id_type vertex_id) const
191+
[[nodiscard]] gl_attr_force_inline auto incidenct_edges(id_type vertex_id) const
192192
requires(traits::c_has_empty_properties<edge_type>)
193193
{
194194
return this->out_edges(vertex_id);
195195
}
196196

197-
[[nodiscard]] gl_attr_force_inline auto adjacent_edges(
197+
[[nodiscard]] gl_attr_force_inline auto incidenct_edges(
198198
id_type vertex_id, const auto& edge_properties_map
199199
) const
200200
requires(traits::c_has_non_empty_properties<edge_type>)
@@ -257,14 +257,14 @@ class adjacency_list final {
257257
[[nodiscard]] gl_attr_force_inline auto at(id_type vertex_id) const
258258
requires(traits::c_has_empty_properties<edge_type>)
259259
{
260-
return this->adjacent_edges(vertex_id);
260+
return this->incidenct_edges(vertex_id);
261261
}
262262

263263
[[nodiscard]] gl_attr_force_inline auto at(id_type vertex_id, const auto& edge_properties_map)
264264
const
265265
requires(traits::c_has_non_empty_properties<edge_type>)
266266
{
267-
return this->adjacent_edges(vertex_id, edge_properties_map);
267+
return this->incidenct_edges(vertex_id, edge_properties_map);
268268
}
269269

270270
// --- comparison ---

include/gl/impl/adjacency_matrix.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ class adjacency_matrix final {
178178
return removed_edge_ids;
179179
}
180180

181-
[[nodiscard]] gl_attr_force_inline auto adjacent_edges(id_type vertex_id) const
181+
[[nodiscard]] gl_attr_force_inline auto incidenct_edges(id_type vertex_id) const
182182
requires(traits::c_has_empty_properties<edge_type>)
183183
{
184184
return this->out_edges(vertex_id);
185185
}
186186

187-
[[nodiscard]] gl_attr_force_inline auto adjacent_edges(
187+
[[nodiscard]] gl_attr_force_inline auto incidenct_edges(
188188
id_type vertex_id, const auto& edge_properties_map
189189
) const
190190
requires(traits::c_has_non_empty_properties<edge_type>)

include/gl/impl/specialized/adjacency_list.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ struct directed_adjacency_list {
7878

7979
[[nodiscard]] static size_type in_degree(const impl_type& self, id_type vertex_id) {
8080
size_type in_deg = 0uz;
81-
for (const auto& adjacent_edges : self._list)
81+
for (const auto& incidenct_edges : self._list)
8282
in_deg += static_cast<size_type>(
83-
std::ranges::count(adjacent_edges, vertex_id, &item_type::vertex_id)
83+
std::ranges::count(incidenct_edges, vertex_id, &item_type::vertex_id)
8484
);
8585

8686
return in_deg;

tests/include/testing/gl/io_common.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void verify_graph_structure(const GraphType& actual, const GraphType& expected)
1313

1414
// verify that the edges of the in graph are equivalent to the edges of the out graph
1515
CHECK(std::ranges::all_of(actual.vertices(), [&](const auto& v_actual) {
16-
return std::ranges::all_of(actual.adjacent_edges(v_actual), [&](const auto& edge) {
16+
return std::ranges::all_of(actual.incidenct_edges(v_actual), [&](const auto& edge) {
1717
return expected.has_edge(edge.source(), edge.target());
1818
});
1919
}));
@@ -35,7 +35,7 @@ void verify_vertex_properties(const GraphType& actual, const GraphType& expected
3535
template <gl::traits::c_graph GraphType>
3636
void verify_edge_properties(const GraphType& actual, const GraphType& expected) {
3737
CHECK(std::ranges::all_of(actual.vertices(), [&](const auto& v_actual) {
38-
return std::ranges::all_of(actual.adjacent_edges(v_actual), [&](const auto& edge) {
38+
return std::ranges::all_of(actual.incidenct_edges(v_actual), [&](const auto& edge) {
3939
return edge.properties()
4040
== expected.get_edge(edge.source(), edge.target())->properties();
4141
});

0 commit comments

Comments
 (0)