You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
YT-CPPHGL-2: Cleanup of the CPP-GL module implementation and documentation
A small cleanup required for the development of HGL
- Changed the minimum required C++ standard to C++23
- Changed the minimum required GCC version to 14 and CLang version to 18
- Replaced the usage of `std::optional<bool>` as algorithm predicate result type with a new ternary `predicate_result` type
- Removed the `no_return` and `default_return` algorithm-specific types and related concepts; Introduced a `result_discriminator` type in their place
- Aligned the documentation
@@ -128,13 +128,14 @@ The instructions and requirements of working on the `CPP-GL` project can be foun
128
128
129
129
## Compiler support
130
130
131
+
<!--TODO: verify whether the min compiler version is correct for C++23-->
131
132
| Compiler | Min version |
132
133
| :-: | :-: |
133
-
| GNU G++ |13|
134
-
| Clang |17|
134
+
| GNU G++ |14|
135
+
| Clang |18|
135
136
136
137
> [!NOTE]
137
-
> Although currently the project has been properly verified using only the G++ and Clang compilers it should work fine with other compilers with C++20 support like MSVC.
138
+
> Although currently the project has been properly verified using only the G++ and Clang compilers it should work fine with other compilers with C++23 support like MSVC.
Copy file name to clipboardExpand all lines: docs/algoithms.md
+36-24Lines changed: 36 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Algorithms
2
2
3
-
The `CPP-GL` library provides a set of customizable graph algorithms, which are defined in the [gl/algorithms.hpp](/include/gl/algorithms.hpp) header file or in the specific header files in the [gl/algorithm/](/include/gl/algorithm/) directory.
3
+
The `CPP-GL` library provides a set of customizable graph algorithms, which are defined in the [gl/algorithm.hpp](/include/gl/algorithm.hpp) header file or in the specific header files in the [gl/algorithm/](/include/gl/algorithm/) directory.
4
4
5
5
<br />
6
6
@@ -31,7 +31,12 @@ This section covers the specific types and type traits used for the algorithm im
31
31
> [!NOTE]
32
32
> All types listed below are defined in the `gl::algorithm` namespace
33
33
34
-
-`no_return` - A placeholder type to represent algorithms that do not return a value. It is primarily used in type traits to conditionally handle return types.
34
+
-`result_discriminator` - An enumeration type used to discriminate whether the algorithm should return a result value or not.
35
+
-**Members:**
36
+
-`ret` - Indicates that the algorithm returns a value.
37
+
-`noret` - Indicates that the algorithm does not return a value.
38
+
- The `gl::algorithm` namespace [uses](https://en.cppreference.com/w/cpp/language/enum.html#using_enum_declaration) the `result_discriminator` enum, which allows for the usage of it's members directly from the `gl::algorithm` namespace, e.g. `gl::algorithm::noret`.
39
+
35
40
-`empty_callback` - Represents an empty callback, used as a default value where no callback functionality is needed.
36
41
37
42
-`vertex_callback`
@@ -68,6 +73,25 @@ This section covers the specific types and type traits used for the algorithm im
68
73
-`edge: types::const_ref_wrap<EdgeType>` - a constant reference wrapper for the edge.
69
74
-`source_id: types::id_type` - the ID of the source vertex of the held edge.
70
75
76
+
-`predicate_result`
77
+
-*Description*: Represents the result of a predicate evaluation.
78
+
-*Type definitions*:
79
+
-`eval` - an enumeration type representing the result value.
80
+
-`ok` - equivalent to `true`.
81
+
-`not_ok` - equivalent to `false`.
82
+
-`unknown` - represents an unknown result.
83
+
-*Constructors*:
84
+
-`predicate_result(const eval value)` - initializes the object with the given evaluation result.
85
+
-`predicate_result(const bool value)` - initializes the object with the given boolean value.
86
+
- If the value is `true`, initializes the object with `eval::ok`.
87
+
- If the value is `false`, initializes the object with `eval::not_ok`.
88
+
-*Member variables*:
89
+
-`value: eval` - the evaluation result.
90
+
-*Operators*:
91
+
-`operator bool()` - returns `true` if the result is `eval::ok`, `false` otherwise.
92
+
-`operator==(const eval& value) const` - returns `true` if the result's value is equal to the given value.
93
+
-`operator=(const bool value)` - initializes the object with the given boolean value similarly to the boolean constructor.
94
+
71
95
-`predecessors_descriptor`
72
96
-*Description*: A structure that holds a collection of predecessors for a set of vertices.
73
97
-*Type definitions*:
@@ -93,18 +117,6 @@ This section covers the specific types and type traits used for the algorithm im
93
117
> [!NOTE]
94
118
> All concepts listed below are defined in the `gl::type_traits` namespace
95
119
96
-
-`c_alg_no_return_type`
97
-
-*Description*: Checks if the type `T` is `algorithm::no_return`. Used to identify algorithms that do not return a value.
-*Description*: Checks if the type `T` is a valid return type for graph algorithms, i.e., either a graph type or `no_return`.
104
-
-*Template parameters*:
105
-
-`T` - the type to check.
106
-
-*Equivalent to*: `c_graph<T> or c_alg_no_return_type<T>`
107
-
108
120
-`c_empty_callback`
109
121
-*Description*: Checks if a callback type is `algorithm::empty_callback`. Used to determine when no callback is needed for an algorithm.
110
122
-*Template parameters*:
@@ -169,7 +181,7 @@ This section covers the specific types and type traits used for the algorithm im
169
181
-*Description*: Performs an iterative depth-first search (DFS) on the specified graph and conditionally returns a `predecessors_descriptor` instance.
170
182
171
183
-*Template parameters*:
172
-
-`AlgReturnType: type_traits::c_alg_return_type` (default = `algorithm::default_return`) - Specifies whether the algorrithm should return the predecessors descriptor or not (can be eigher `algorithm::default_return` or `algorithm::no_return`).
184
+
-`ResultDiscriminator: result_discriminator` (default = `algorithm::ret`) - Specifies whether the algorrithm should return the predecessors descriptor or not (can be eigher `algorithm::ret` or `algorithm::no_return`).
173
185
-`GraphType: type_traits::c_graph` - The type of the graph on which the search is performed.
174
186
-`PreVisitCallback: type_traits::c_optional_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called before visiting a vertex.
175
187
-`PostVisitCallback: type_traits::c_optional_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called after visiting a vertex.
@@ -181,24 +193,24 @@ This section covers the specific types and type traits used for the algorithm im
181
193
-`post_visit: const PostVisitCallback&` (default = `{}`) - The callback function to be called after visiting a vertex.
182
194
183
195
-*Return type*:
184
-
-`impl::alg_return_type<AlgReturnType, predecessors_descriptor>` - If `AlgReturnType` is `algorithm::no_return` - nothing will be returned (`void`). Otherwise the algorithm will return an instance of `predecessors_descriptor`.
196
+
-`impl::alg_return_type<ResultDiscriminator, predecessors_descriptor>` - If `ResultDiscriminator` is `algorithm::noret` - nothing will be returned (`void`). Otherwise the algorithm will return an instance of `predecessors_descriptor`.
-*Description*: Performs an breadth-first search (BFS) on the specified graph and conditionally returns a `predecessors_descriptor` instance.
199
211
200
212
-*Template parameters*:
201
-
-`AlgReturnType: type_traits::c_alg_return_type` (default = `algorithm::default_return`) - Specifies whether the algorrithm should return the predecessors descriptor or not (can be eigher `algorithm::default_return` or `algorithm::no_return`).
213
+
-`ResultDiscriminator: result_discriminator` (default = `algorithm::ret`) - Specifies whether the algorrithm should return the predecessors descriptor or not (can be eigher `algorithm::ret` or `algorithm::no_return`).
202
214
-`GraphType: type_traits::c_graph` - The type of the graph on which the search is performed.
203
215
-`PreVisitCallback: type_traits::c_optional_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called before visiting a vertex.
204
216
-`PostVisitCallback: type_traits::c_optional_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called after visiting a vertex.
@@ -210,7 +222,7 @@ This section covers the specific types and type traits used for the algorithm im
210
222
-`post_visit: const PostVisitCallback&` (default = `{}`) - The callback function to be called after visiting a vertex.
211
223
212
224
-*Return type*:
213
-
-`impl::alg_return_type<AlgReturnType, predecessors_descriptor>` - If `AlgReturnType` is `algorithm::no_return` - nothing will be returned (`void`). Otherwise the algorithm will return an instance of `predecessors_descriptor`.
225
+
-`impl::alg_return_type<ResultDiscriminator, predecessors_descriptor>` - If `ResultDiscriminator` is `algorithm::noret` - nothing will be returned (`void`). Otherwise the algorithm will return an instance of `predecessors_descriptor`.
@@ -401,7 +413,7 @@ Additionaly you can use the depth-first/breadth-first search algorithm templates
401
413
-`GraphType: type_traits::c_graph` - The type of the graph on which the search is performed.
402
414
-`VisitVertexPredicate: type_traits::c_optional_vertex_callback<GraphType, bool>` - The vertex visiting unary predicate type.
403
415
-`VisitCallback: type_traits::c_vertex_callback<GraphType, bool, types::id_type>` - The vertex visting callback type (arguments: `vertex, source_id`).
404
-
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, std::optional<bool>, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
416
+
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, algorithm::predicate_result, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
405
417
-`PreVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called before visiting a vertex.
406
418
-`PostVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called after visiting a vertex.
407
419
@@ -423,7 +435,7 @@ Additionaly you can use the depth-first/breadth-first search algorithm templates
423
435
-`GraphType: type_traits::c_graph` - The type of the graph on which the search is performed.
424
436
-`VisitVertexPredicate: type_traits::c_optional_vertex_callback<GraphType, bool>` - The vertex visiting unary predicate type.
425
437
-`VisitCallback: type_traits::c_vertex_callback<GraphType, bool, types::id_type>` - The vertex visting callback type (arguments: `vertex, source_id`).
426
-
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, std::optional<bool>, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
438
+
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, algorithm::predicate_result, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
427
439
-`PreVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called before visiting a vertex.
428
440
-`PostVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called after visiting a vertex.
429
441
@@ -452,7 +464,7 @@ Additionaly you can use the depth-first/breadth-first search algorithm templates
452
464
-`InitQueueRangeType: type_traits::c_sized_range_of<algorithm::vertex_info>` (default = `std::vector<algorithm::vertex_info>`) - The type of the `vertex_info` range which will be inserted into the queue at the beginning of the algorithm.
453
465
-`VisitVertexPredicate: type_traits::c_optional_vertex_callback<GraphType, bool>` - The vertex visiting unary predicate type.
454
466
-`VisitCallback: type_traits::c_vertex_callback<GraphType, bool, types::id_type>` - The vertex visting callback type (arguments: `vertex, source_id`).
455
-
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, std::optional<bool>, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
467
+
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, algorithm::predicate_result, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
456
468
-`PreVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called before visiting a vertex.
457
469
-`PostVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called after visiting a vertex.
458
470
@@ -483,7 +495,7 @@ Additionaly you can use the depth-first/breadth-first search algorithm templates
483
495
-`InitQueueRangeType: type_traits::c_sized_range_of<algorithm::vertex_info>` (default = `std::vector<algorithm::vertex_info>`) - The type of the `vertex_info` range which will be inserted into the queue at the beginning of the algorithm.
484
496
-`VisitVertexPredicate: type_traits::c_optional_vertex_callback<GraphType, bool>` - The vertex visiting unary predicate type.
485
497
-`VisitCallback: type_traits::c_vertex_callback<GraphType, bool, types::id_type>` - The vertex visting callback type (arguments: `vertex, source_id`).
486
-
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, std::optional<bool>, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
498
+
-`EnqueueVertexPred: type_traits::c_vertex_callback<GraphType, algorithm::predicate_result, const typename GraphType::edge_type&>` - The vertex enqueue predicate type (arguments: `vertex, in_edge`)
487
499
-`PreVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called before visiting a vertex.
488
500
-`PostVisitCallback: type_traits::c_vertex_callback<GraphType, void>` (default = `algorithm::empty_callback`) - The type of the callback function called after visiting a vertex.
-*Description*: Returns the vertex on the other end of the edge relative to the provided vertex. Throws an error if the provided vertex is not incident with the edge.
167
-
-*Returned value*: $\begin{cases} v & \text{: vertex} = u \\ u & \text{: vertex} = v \\ \text{error} & \text{: otherwise} \end{cases}$
167
+
-*Returned value*:
168
+
- $v$ if $\text{vertex} = u$
169
+
- $u$ if $\text{vertex} = v$
170
+
- error otherwise
168
171
-*Parameters*:
169
172
-`vertex: const vertex_type&` – the vertex for which the opposite vertex is requested.
-*Description*: Returns the ID of the vertex on the other end of the edge relative to the provided vertex ID. Throws an error if the provided vertex ID is invalid.
0 commit comments