Skip to content

Commit 36fc8d0

Browse files
committed
YT-CPPGL-52: Naming cleanup
- Renamed - The `algorithm::detail` namespace to `algorithm::impl` - The `{bds/dfs}_impl` functions to `{bfs/dfs}` - `destination` to `target` in the context of vertices - Aligned the documentation
1 parent 7bf56dc commit 36fc8d0

24 files changed

Lines changed: 172 additions & 187 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ else()
88
endif()
99

1010
project(cpp-gl
11-
VERSION 1.0.2
11+
VERSION 1.0.3
1212
DESCRIPTION "General purpose header-only template graph library for C++20"
1313
HOMEPAGE_URL "https://github.com/SpectraL519/cpp-gl"
1414
LANGUAGES CXX

docs/algoithms.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ This section covers the specific types and type traits used for the algorithm im
161161
- `post_visit: const PostVisitCallback&` (default = `{}`) - The callback function to be called after visiting a vertex.
162162

163163
- *Return type*:
164-
- `detail::alg_return_graph_type<SearchTreeType>` - If `SearchTreeType` is not `types::no_return`, returns a search tree of type `SearchTreeType`. Otherwise, the return type is `void`.
164+
- `impl::alg_return_graph_type<SearchTreeType>` - If `SearchTreeType` is not `types::no_return`, returns a search tree of type `SearchTreeType`. Otherwise, the return type is `void`.
165165

166166
- *Defined in*: [gl/algorithm/depth_first_search.hpp](/include/gl/algorithm/deapth_first_search.hpp)
167167

@@ -190,7 +190,7 @@ This section covers the specific types and type traits used for the algorithm im
190190
- `post_visit: const PostVisitCallback&` (default = `{}`) - The callback function to be called after visiting a vertex.
191191

192192
- *Return type*:
193-
- `detail::alg_return_graph_type<SearchTreeType>` - If `SearchTreeType` is not `types::no_return`, returns a search tree of type `SearchTreeType`. Otherwise, the return type is `void`.
193+
- `impl::alg_return_graph_type<SearchTreeType>` - If `SearchTreeType` is not `types::no_return`, returns a search tree of type `SearchTreeType`. Otherwise, the return type is `void`.
194194

195195
- *Defined in*: [gl/algorithm/breadth_first_search.hpp](/include/gl/algorithm/breadth_first_search.hpp)
196196

@@ -352,14 +352,14 @@ This section covers the specific types and type traits used for the algorithm im
352352

353353
To write custom graph algorithms you can use the types and concepts described in the [Algorithm-specific types and concepts](#algorithm-specific-types-and-concepts) as well as the general graph utility described in the [graph class documentation page](/docs/graph.md#additional-utility).
354354

355-
Additionaly you can use the depth-first/breadth-first search algorithm templates which are defined in the `gl::algorithm::detail` namespace:
355+
Additionaly you can use the depth-first/breadth-first search algorithm templates which are defined in the `gl::algorithm::impl` namespace:
356356

357357
### Depth-first search templates
358358

359359
> [!NOTE]
360-
> The DFS algorithm templates are defined in the [gl/algorithm/detail/dfs_impl.hpp](/include/gl/algorithm/detail/dfs_impl.hpp) file.
360+
> The DFS algorithm templates are defined in the [gl/algorithm/impl/dfs.hpp](/include/gl/algorithm/impl/dfs.hpp) file.
361361
362-
- `dfs_impl(graph, root_vertex, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
362+
- `dfs(graph, root_vertex, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
363363
- *Desciption*: An iterative DFS algoithm template.
364364

365365
- *Template parameters*:
@@ -381,7 +381,7 @@ Additionaly you can use the depth-first/breadth-first search algorithm templates
381381

382382
- *Return type*: `void`
383383

384-
- `rdfs_impl(graph, vertex, source_id, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
384+
- `r_dfs(graph, vertex, source_id, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
385385
- *Description*: A recursive DFS algorithm template.
386386

387387
- *Template parameters*:
@@ -407,9 +407,9 @@ Additionaly you can use the depth-first/breadth-first search algorithm templates
407407
### Breadth-first search templates
408408

409409
> [!NOTE]
410-
> The BFS algorithm templates are defined in the [gl/algorithm/detail/bfs_impl.hpp](/include/gl/algorithm/detail/bfs_impl.hpp) file.
410+
> The BFS algorithm templates are defined in the [gl/algorithm/impl/bfs.hpp](/include/gl/algorithm/impl/bfs.hpp) file.
411411
412-
- `bfs_impl(graph, initial_queue_content, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
412+
- `bfs(graph, initial_queue_content, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
413413
- *Desciption*: A *standard* BFS algorithm template.
414414

415415
- *Template parameters*:
@@ -434,7 +434,7 @@ Additionaly you can use the depth-first/breadth-first search algorithm templates
434434

435435
- *Return type*: `void`
436436

437-
- `pq_bfs_impl(graph, pq_compare, initial_queue_content, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
437+
- `pq_bfs(graph, pq_compare, initial_queue_content, visit_vertex_pred, visit, enque_vertex_pred, pre_visit, post_visit)`
438438
- *Desciption*: A *priority queue* BFS algorithm template.
439439

440440
- *Template parameters*:

docs/graph.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,29 +320,29 @@ Based on the specified traits, the `graph` class defines the following types:
320320
- *Return type*: `const edge_type&`
321321
- *Requires*: non-default `edge_properties_type`
322322

323-
- **`graph.add_edges_from(source_id, destination_id_range)`**:
324-
- *Description*: Adds multiple edges from a source vertex (specified by ID) to a range of destination vertices (also specified by IDs).
323+
- **`graph.add_edges_from(source_id, target_id_range)`**:
324+
- *Description*: Adds multiple edges from a source vertex (specified by ID) to a range of target vertices (also specified by IDs).
325325
- *Template parameters*:
326326
- `IdRange: type_traits::c_sized_range_of<types::id_type>` – a range of vertex IDs that must satisfy the size and type constraints.
327327
- *Parameters*:
328328
- `source_id: types::id_type` – the ID of the source vertex.
329-
- `destination_id_range: const IdRange&` – a range of destination vertex IDs to connect to the source vertex.
329+
- `target_id_range: const IdRange&` – a range of target vertex IDs to connect to the source vertex.
330330
- *Return type*: `void`
331331

332-
- **`graph.add_edges_from(source, destination_range)`**:
333-
- *Description*: Adds multiple edges from a specified source vertex to a range of destination vertices (specified by references).
332+
- **`graph.add_edges_from(source, target_range)`**:
333+
- *Description*: Adds multiple edges from a specified source vertex to a range of target vertices (specified by references).
334334
- *Template parameters*:
335335
- `VertexRefRange: type_traits::c_sized_range_of<types::const_ref_wrap<vertex_type>>` – a range of vertex references that must satisfy the size and type constraints.
336336
- *Parameters*:
337337
- `source: const vertex_type&` – the source vertex.
338-
- `destination_range: const VertexRefRange&` – a range of destination vertex references to connect to the source vertex.
338+
- `target_range: const VertexRefRange&` – a range of target vertex references to connect to the source vertex.
339339
- *Return type*: `void`
340340

341341
> [!IMPORTANT]
342342
> Behaviour of adding an edge between `first` and `second`:
343343
>
344-
> - for *directed* graphs: adds a one-directional edge where `first` is the source vertex and `second` is the destination vertex
345-
> - for *undirected* graphs: adds a bidirectional edge where both vertices are source and destination vertices
344+
> - for *directed* graphs: adds a one-directional edge where `first` is the source vertex and `second` is the target vertex
345+
> - for *undirected* graphs: adds a bidirectional edge where both vertices are source and target vertices
346346
347347
- **`graph.has_edge(first_id, second_id) const`**:
348348
- *Description*: Returns true if there is an edge between the vertices with the specified IDs.

docs/graph_elements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ The destructor is *defaulted*, allowing proper cleanup of the `edge_descriptor`
186186
- *Return type*: `bool`
187187

188188
- **`is_incident_to(const vertex_type& vertex) const`**:
189-
- *Description*: Returns `true` if the provided vertex is the destination of the edge (for directed edges).
189+
- *Description*: Returns `true` if the provided vertex is the target vertex of the edge (for directed edges).
190190
- *Returned value*:
191191
- For directed edges: $\text{vertex} = v$
192192
- For undirected edges: `is_incident_with(vertex)`
193193
- *Parameters*:
194-
- `vertex: const vertex_type&` – the vertex to check if it is the destination.
194+
- `vertex: const vertex_type&` – the vertex to check if it is the target.
195195
- *Return type*: `bool`
196196

197197
- **`is_loop() const`**:

include/gl/algorithm/breadth_first_search.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#pragma once
66

77
#include "constants.hpp"
8-
#include "detail/bfs_impl.hpp"
8+
#include "impl/bfs.hpp"
99
#include "types.hpp"
1010

1111
namespace gl::algorithm {
@@ -17,7 +17,7 @@ template <
1717
types::empty_callback,
1818
type_traits::c_optional_vertex_callback<GraphType, void> PostVisitCallback =
1919
types::empty_callback>
20-
detail::alg_return_graph_type<SearchTreeType> breadth_first_search(
20+
impl::alg_return_graph_type<SearchTreeType> breadth_first_search(
2121
const GraphType& graph,
2222
const std::optional<types::id_type>& root_vertex_id_opt = no_root_vertex,
2323
const PreVisitCallback& pre_visit = {},
@@ -29,27 +29,27 @@ detail::alg_return_graph_type<SearchTreeType> breadth_first_search(
2929
std::vector<bool> visited(graph.n_vertices(), false);
3030
std::vector<types::id_type> sources(graph.n_vertices());
3131

32-
auto search_tree = detail::init_search_tree<SearchTreeType>(graph);
32+
auto search_tree = impl::init_search_tree<SearchTreeType>(graph);
3333

3434
if (root_vertex_id_opt) {
35-
detail::bfs_impl(
35+
impl::bfs(
3636
graph,
37-
detail::init_range(root_vertex_id_opt.value()),
38-
detail::default_visit_vertex_predicate<GraphType>(visited),
39-
detail::default_visit_callback<GraphType>(visited, search_tree),
40-
detail::default_enqueue_vertex_predicate<GraphType, true>(visited),
37+
impl::init_range(root_vertex_id_opt.value()),
38+
impl::default_visit_vertex_predicate<GraphType>(visited),
39+
impl::default_visit_callback<GraphType>(visited, search_tree),
40+
impl::default_enqueue_vertex_predicate<GraphType, true>(visited),
4141
pre_visit,
4242
post_visit
4343
);
4444
}
4545
else {
4646
for (const auto root_id : graph.vertex_ids())
47-
detail::bfs_impl(
47+
impl::bfs(
4848
graph,
49-
detail::init_range(root_id),
50-
detail::default_visit_vertex_predicate<GraphType>(visited),
51-
detail::default_visit_callback<GraphType>(visited, search_tree),
52-
detail::default_enqueue_vertex_predicate<GraphType, true>(visited),
49+
impl::init_range(root_id),
50+
impl::default_visit_vertex_predicate<GraphType>(visited),
51+
impl::default_visit_callback<GraphType>(visited, search_tree),
52+
impl::default_enqueue_vertex_predicate<GraphType, true>(visited),
5353
pre_visit,
5454
post_visit
5555
);

include/gl/algorithm/coloring.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#pragma once
66

7-
#include "detail/bfs_impl.hpp"
7+
#include "impl/bfs.hpp"
88

99
namespace gl::algorithm {
1010

@@ -36,9 +36,9 @@ template <
3636
// color the root vertex
3737
coloring[root_id] = bin_color_value::black;
3838

39-
const bool is_bipartite = detail::bfs_impl(
39+
const bool is_bipartite = impl::bfs(
4040
graph,
41-
detail::init_range(root_id),
41+
impl::init_range(root_id),
4242
types::empty_callback{}, // visit predicate
4343
types::empty_callback{}, // visit callback
4444
[&coloring](const vertex_type& vertex, const edge_type& in_edge)

include/gl/algorithm/deapth_first_search.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#pragma once
66

77
#include "constants.hpp"
8-
#include "detail/dfs_impl.hpp"
8+
#include "impl/dfs.hpp"
99

1010
namespace gl::algorithm {
1111

@@ -16,7 +16,7 @@ template <
1616
types::empty_callback,
1717
type_traits::c_optional_vertex_callback<GraphType, void> PostVisitCallback =
1818
types::empty_callback>
19-
detail::alg_return_graph_type<SearchTreeType> depth_first_search(
19+
impl::alg_return_graph_type<SearchTreeType> depth_first_search(
2020
const GraphType& graph,
2121
const std::optional<types::id_type>& root_vertex_id_opt = no_root_vertex,
2222
const PreVisitCallback& pre_visit = {},
@@ -28,27 +28,27 @@ detail::alg_return_graph_type<SearchTreeType> depth_first_search(
2828
std::vector<bool> visited(graph.n_vertices(), false);
2929
std::vector<types::id_type> sources(graph.n_vertices());
3030

31-
auto search_tree = detail::init_search_tree<SearchTreeType>(graph);
31+
auto search_tree = impl::init_search_tree<SearchTreeType>(graph);
3232

3333
if (root_vertex_id_opt) {
34-
detail::dfs_impl(
34+
impl::dfs(
3535
graph,
3636
graph.get_vertex(root_vertex_id_opt.value()),
37-
detail::default_visit_vertex_predicate<GraphType>(visited),
38-
detail::default_visit_callback<GraphType>(visited, search_tree),
39-
detail::default_enqueue_vertex_predicate<GraphType>(visited),
37+
impl::default_visit_vertex_predicate<GraphType>(visited),
38+
impl::default_visit_callback<GraphType>(visited, search_tree),
39+
impl::default_enqueue_vertex_predicate<GraphType>(visited),
4040
pre_visit,
4141
post_visit
4242
);
4343
}
4444
else {
4545
for (const auto& root_vertex : graph.vertices())
46-
detail::dfs_impl(
46+
impl::dfs(
4747
graph,
4848
root_vertex,
49-
detail::default_visit_vertex_predicate<GraphType>(visited),
50-
detail::default_visit_callback<GraphType>(visited, search_tree),
51-
detail::default_enqueue_vertex_predicate<GraphType>(visited),
49+
impl::default_visit_vertex_predicate<GraphType>(visited),
50+
impl::default_visit_callback<GraphType>(visited, search_tree),
51+
impl::default_enqueue_vertex_predicate<GraphType>(visited),
5252
pre_visit,
5353
post_visit
5454
);
@@ -65,7 +65,7 @@ template <
6565
types::empty_callback,
6666
type_traits::c_optional_vertex_callback<GraphType, void> PostVisitCallback =
6767
types::empty_callback>
68-
detail::alg_return_graph_type<SearchTreeType> recursive_depth_first_search(
68+
impl::alg_return_graph_type<SearchTreeType> recursive_depth_first_search(
6969
const GraphType& graph,
7070
const std::optional<types::id_type>& root_vertex_id_opt = no_root_vertex,
7171
const PreVisitCallback& pre_visit = {},
@@ -77,30 +77,30 @@ detail::alg_return_graph_type<SearchTreeType> recursive_depth_first_search(
7777
std::vector<bool> visited(graph.n_vertices(), false);
7878
std::vector<types::id_type> sources(graph.n_vertices());
7979

80-
auto search_tree = detail::init_search_tree<SearchTreeType>(graph);
80+
auto search_tree = impl::init_search_tree<SearchTreeType>(graph);
8181

8282
if (root_vertex_id_opt) {
8383
const auto root_id = root_vertex_id_opt.value();
84-
detail::rdfs_impl(
84+
impl::r_dfs(
8585
graph,
8686
graph.get_vertex(root_id),
8787
root_id,
88-
detail::default_visit_vertex_predicate<GraphType>(visited),
89-
detail::default_visit_callback<GraphType>(visited, search_tree),
90-
detail::default_enqueue_vertex_predicate<GraphType>(visited),
88+
impl::default_visit_vertex_predicate<GraphType>(visited),
89+
impl::default_visit_callback<GraphType>(visited, search_tree),
90+
impl::default_enqueue_vertex_predicate<GraphType>(visited),
9191
pre_visit,
9292
post_visit
9393
);
9494
}
9595
else {
9696
for (const auto& root_vertex : graph.vertices())
97-
detail::rdfs_impl(
97+
impl::r_dfs(
9898
graph,
9999
root_vertex,
100100
root_vertex.id(),
101-
detail::default_visit_vertex_predicate<GraphType>(visited),
102-
detail::default_visit_callback<GraphType>(visited, search_tree),
103-
detail::default_enqueue_vertex_predicate<GraphType>(visited),
101+
impl::default_visit_vertex_predicate<GraphType>(visited),
102+
impl::default_visit_callback<GraphType>(visited, search_tree),
103+
impl::default_enqueue_vertex_predicate<GraphType>(visited),
104104
pre_visit,
105105
post_visit
106106
);

include/gl/algorithm/dijkstra.hpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#pragma once
66

7-
#include "detail/bfs_impl.hpp"
87
#include "gl/graph_utility.hpp"
8+
#include "impl/bfs.hpp"
99

1010
#include <deque>
1111

@@ -29,18 +29,14 @@ struct paths_descriptor {
2929
std::vector<distance_type> distances;
3030
};
3131

32-
namespace detail {
33-
3432
template <type_traits::c_graph GraphType>
3533
using paths_descriptor_type = paths_descriptor<types::vertex_distance_type<GraphType>>;
3634

37-
} // namespace detail
38-
3935
template <type_traits::c_graph GraphType>
40-
[[nodiscard]] gl_attr_force_inline detail::paths_descriptor_type<GraphType> make_paths_descriptor(
36+
[[nodiscard]] gl_attr_force_inline paths_descriptor_type<GraphType> make_paths_descriptor(
4137
const GraphType& graph
4238
) {
43-
return detail::paths_descriptor_type<GraphType>{graph.n_vertices()};
39+
return paths_descriptor_type<GraphType>{graph.n_vertices()};
4440
}
4541

4642
template <
@@ -49,7 +45,7 @@ template <
4945
types::empty_callback,
5046
type_traits::c_optional_vertex_callback<GraphType, void> PostVisitCallback =
5147
types::empty_callback>
52-
[[nodiscard]] detail::paths_descriptor_type<GraphType> dijkstra_shortest_paths(
48+
[[nodiscard]] paths_descriptor_type<GraphType> dijkstra_shortest_paths(
5349
const GraphType& graph,
5450
const types::id_type source_id,
5551
const PreVisitCallback& pre_visit = {},
@@ -66,12 +62,12 @@ template <
6662

6763
std::optional<types::const_ref_wrap<edge_type>> negative_edge;
6864

69-
detail::pq_bfs_impl(
65+
impl::pq_bfs(
7066
graph,
7167
[&paths](const types::vertex_info& lhs, const types::vertex_info& rhs) {
7268
return paths.distances[lhs.id] > paths.distances[rhs.id];
7369
},
74-
detail::init_range(source_id),
70+
impl::init_range(source_id),
7571
types::empty_callback{}, // visit predicate
7672
types::empty_callback{}, // visit callback
7773
[&paths, &negative_edge](const vertex_type& vertex, const edge_type& in_edge)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <queue>
1010

11-
namespace gl::algorithm::detail {
11+
namespace gl::algorithm::impl {
1212

1313
template <
1414
type_traits::c_graph GraphType,
@@ -23,7 +23,7 @@ template <
2323
types::empty_callback,
2424
type_traits::c_optional_vertex_callback<GraphType, void> PostVisitCallback =
2525
types::empty_callback>
26-
bool bfs_impl(
26+
bool bfs(
2727
const GraphType& graph,
2828
const InitQueueRangeType& initial_queue_content,
2929
const VisitVertexPredicate& visit_vertex_pred = {},
@@ -92,7 +92,7 @@ template <
9292
types::empty_callback,
9393
type_traits::c_optional_vertex_callback<GraphType, void> PostVisitCallback =
9494
types::empty_callback>
95-
bool pq_bfs_impl(
95+
bool pq_bfs(
9696
const GraphType& graph,
9797
const PQCompare& pq_compare,
9898
const InitQueueRangeType& initial_queue_content,
@@ -148,4 +148,4 @@ bool pq_bfs_impl(
148148
return true;
149149
}
150150

151-
} // namespace gl::algorithm::detail
151+
} // namespace gl::algorithm::impl

0 commit comments

Comments
 (0)