Skip to content

Commit 4ea6fe3

Browse files
committed
more docs and format alignment
1 parent bf5fd5f commit 4ea6fe3

10 files changed

Lines changed: 239 additions & 58 deletions

File tree

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ STRIP_FROM_PATH =
199199
# specify the list of include paths that are normally passed to the compiler
200200
# using the -I flag.
201201

202-
STRIP_FROM_INC_PATH =
202+
STRIP_FROM_INC_PATH = include/
203203

204204
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
205205
# less readable) file names. This can be useful is your file systems doesn't

include/gl/decl/impl_tags.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// This file is part of the CPP-GL project (https://github.com/SpectraL519/cpp-gl).
33
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
44

5+
/// @file gl/decl/impl_tags.hpp
6+
/// @brief Forward declares implementation tags for different graph representations.
7+
58
#pragma once
69

710
#include "gl/traits.hpp"
@@ -22,6 +25,19 @@ struct flat_matrix_t;
2225

2326
namespace traits {
2427

28+
/// @ingroup GL GL-Traits
29+
/// @brief Validates if a type is one of the defined graph implementation tags.
30+
///
31+
/// This concept is used to constrain template parameters that are expected to be
32+
/// specific graph implementation tags, ensuring type safety and clear intent in template usage.
33+
///
34+
/// The valid tags include:
35+
/// - @ref gl::impl::list_t "impl::list_t": Represents a standard adjacency list implementation.
36+
/// - @ref gl::impl::flat_list_t "impl::flat_list_t": Represents a flattened adjacency list implementation.
37+
/// - @ref gl::impl::matrix_t "impl::matrix_t": Represents a standard adjacency matrix implementation.
38+
/// - @ref gl::impl::flat_matrix_t "impl::flat_matrix_t": Represents a flattened adjacency matrix implementation.
39+
///
40+
/// @tparam T The type to evaluate against the concept.
2541
template <typename T>
2642
concept c_graph_impl_tag =
2743
c_one_of<T, impl::list_t, impl::flat_list_t, impl::matrix_t, impl::flat_matrix_t>;

include/gl/graph_traits.hpp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,89 @@
22
// This file is part of the CPP-GL project (https://github.com/SpectraL519/cpp-gl).
33
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
44

5+
/// @file gl/graph_traits.hpp
6+
/// @brief Defines the primary graph traits structure and related type aliases for different graph configurations.
7+
58
#pragma once
69

710
#include "gl/decl/graph_traits.hpp"
811
#include "gl/decl/impl_tags.hpp"
12+
#include "gl/directional_tags.hpp"
913
#include "gl/edge_descriptor.hpp"
1014
#include "gl/types/core.hpp"
1115

1216
namespace gl {
1317

18+
/// @ingroup GL GL-Core
19+
/// @brief Primary graph traits structure that encapsulates all necessary type information for graph implementations.
20+
///
21+
/// This structure serves as the central point for defining the properties and types associated with a graph,
22+
/// including directionality, vertex and edge properties, as well as implementation and identifier types. It is designed
23+
/// to be flexible and extensible, allowing users to customize their graph types by specifying different traits.
24+
///
25+
/// ### Template Parameters
26+
/// | Parameter | Description | Default value | Constraints |
27+
/// | :--------------- | :---------- | :------------ | :---------- |
28+
/// | DirectionalTag | Specifies whether the graph is directed or undirected. | @ref gl::directed_t "directed_t" | [**c_graph_directional_tag**](gl_traits.md#gl-traits-c-graph-directional-tag) |
29+
/// | VertexProperties | A type representing the properties associated with vertices in the graph. | @ref gl::empty_properties "empty_properties" | [**c_properties**](gl_traits.md#gl-traits-c-properties) |
30+
/// | EdgeProperties | A type representing the properties associated with edges in the graph. | @ref gl::empty_properties "empty_properties" | [**c_properties**](gl_traits.md#gl-traits-c-properties) |
31+
/// | ImplTag | Specifies the graph implementation type (e.g., adjacency list, adjacency matrix). | @ref gl::impl::list_t "impl::list_t" | [**c_graph_impl_tag**](gl_traits.md#gl-traits-c-graph-impl-tag) |
32+
/// | IdType | The type used for vertex and edge identifiers. | @ref gl::default_id_type "default_id_type" | [**c_id_type**](gl_traits.md#gl-traits-c-id-type) |
33+
///
34+
/// ### See Also
35+
/// - Available implementation tags:
36+
/// - @ref gl::impl::list_t "impl::list_t" : A standard adjacency list implementation.
37+
/// - @ref gl::impl::flat_list_t "impl::flat_list_t" : A flattened adjacency list implementation.
38+
/// - @ref gl::impl::matrix_t "impl::matrix_t" : A standard adjacency matrix implementation.
39+
/// - @ref gl::impl::flat_matrix_t "impl::flat_matrix_t" : A flattened adjacency matrix implementation.
40+
/// - @ref gl::directed_t "directed_t", @ref gl::undirected_t "undirected_t" : For the directional tags used to specify graph directionality.
41+
/// - @ref gl::vertex_descriptor "vertex_descriptor" : For the vertex descriptor type defined based on the graph traits.
42+
/// - @ref gl::edge_descriptor "edge_descriptor" : For the edge descriptor type defined based on the graph traits.
43+
/// - @ref gl::empty_properties "empty_properties" : For the default empty properties type used when no custom properties are needed.
44+
/// - Convenience type aliases for the `graph_traits` type:
45+
/// - @ref gl::list_graph_traits "list_graph_traits",
46+
/// - @ref gl::flat_list_graph_traits "flat_list_graph_traits",
47+
/// - @ref gl::matrix_graph_traits "matrix_graph_traits",
48+
/// - @ref gl::flat_matrix_graph_traits "flat_matrix_graph_traits",
49+
/// - @ref gl::directed_graph_traits "directed_graph_traits",
50+
/// - @ref gl::undirected_graph_traits "undirected_graph_traits"
1451
template <
1552
traits::c_graph_directional_tag DirectionalTag = directed_t,
1653
traits::c_properties VertexProperties = empty_properties,
1754
traits::c_properties EdgeProperties = empty_properties,
1855
traits::c_graph_impl_tag ImplTag = impl::list_t,
1956
traits::c_id_type IdType = default_id_type>
2057
struct graph_traits {
58+
/// @brief The tag indicating the graph's directionality (directed or undirected).
2159
using directional_tag = DirectionalTag;
60+
/// @brief The tag indicating the graph's implementation type (e.g., adjacency list, adjacency matrix).
2261
using implementation_tag = ImplTag;
62+
/// @brief The type of graph element indentifiers (i.e. vertex and edge IDs).
2363
using id_type = IdType;
2464

65+
/// @brief The vertex descriptor type associated with this graph, defined based on the specified vertex properties and identifier type.
2566
using vertex_type = vertex_descriptor<VertexProperties, id_type>;
67+
/// @brief The type of properties associated with the vertex descriptor.
2668
using vertex_properties_type = typename vertex_type::properties_type;
2769

70+
/// @brief The edge descriptor type associated with this graph, defined based on the specified edge properties and identifier type.
2871
using edge_type = edge_descriptor<DirectionalTag, EdgeProperties, id_type>;
72+
/// @brief The type of properties associated with the edge descriptor.
2973
using edge_properties_type = typename edge_type::properties_type;
3074
};
3175

76+
/// @ingroup GL GL-Core
77+
/// @brief Type alias for graph traits with an adjacency list implementation.
78+
///
79+
/// This alias simplifies the specification of graph traits for graphs that use an adjacency list representation,
80+
/// allowing users to easily define their graph types with the desired properties and directionality while defaulting
81+
/// to the adjacency list implementation.
82+
///
83+
/// > [!NOTE] Template parameters
84+
/// >
85+
/// > The template parameters for this alias are the same as those for @ref gl::graph_traits "graph_traits", with the
86+
/// > `ImplTag` parameter fixed to @ref gl::impl::list_t "impl::list_t". This means that when using `list_graph_traits`,
87+
/// > only the `DirectionalTag`, `VertexProperties`, `EdgeProperties`, and `IdType` parameters need to be specified.
3288
template <
3389
traits::c_graph_directional_tag DirectionalTag = directed_t,
3490
traits::c_properties VertexProperties = empty_properties,
@@ -37,6 +93,18 @@ template <
3793
using list_graph_traits =
3894
graph_traits<DirectionalTag, VertexProperties, EdgeProperties, impl::list_t, IdType>;
3995

96+
/// @ingroup GL GL-Core
97+
/// @brief Type alias for graph traits with a flattened adjacency list implementation.
98+
///
99+
/// This alias simplifies the specification of graph traits for graphs that use a flattened adjacency list representation,
100+
/// allowing users to easily define their graph types with the desired properties and directionality while defaulting
101+
/// to the flattened adjacency list implementation.
102+
///
103+
/// > [!NOTE] Template parameters
104+
/// >
105+
/// > The template parameters for this alias are the same as those for @ref gl::graph_traits "graph_traits", with the
106+
/// > `ImplTag` parameter fixed to @ref gl::impl::flat_list_t "impl::flat_list_t". This means that when using `flat_list_graph_traits`,
107+
/// > only the `DirectionalTag`, `VertexProperties`, `EdgeProperties`, and `IdType` parameters need to be specified.
40108
template <
41109
traits::c_graph_directional_tag DirectionalTag = directed_t,
42110
traits::c_properties VertexProperties = empty_properties,
@@ -45,6 +113,18 @@ template <
45113
using flat_list_graph_traits =
46114
graph_traits<DirectionalTag, VertexProperties, EdgeProperties, impl::flat_list_t, IdType>;
47115

116+
/// @ingroup GL GL-Core
117+
/// @brief Type alias for graph traits with an adjacency matrix implementation.
118+
///
119+
/// This alias simplifies the specification of graph traits for graphs that use an adjacency matrix representation,
120+
/// allowing users to easily define their graph types with the desired properties and directionality while defaulting
121+
/// to the adjacency matrix implementation.
122+
///
123+
/// > [!NOTE] Template parameters
124+
/// >
125+
/// > The template parameters for this alias are the same as those for @ref gl::graph_traits "graph_traits", with the
126+
/// > `ImplTag` parameter fixed to @ref gl::impl::matrix_t "impl::matrix_t". This means that when using `matrix_graph_traits`,
127+
/// > only the `DirectionalTag`, `VertexProperties`, `EdgeProperties`, and `IdType` parameters need to be specified.
48128
template <
49129
traits::c_graph_directional_tag DirectionalTag = directed_t,
50130
traits::c_properties VertexProperties = empty_properties,
@@ -53,6 +133,18 @@ template <
53133
using matrix_graph_traits =
54134
graph_traits<DirectionalTag, VertexProperties, EdgeProperties, impl::matrix_t, IdType>;
55135

136+
/// @ingroup GL GL-Core
137+
/// @brief Type alias for graph traits with a flattened adjacency matrix implementation.
138+
///
139+
/// This alias simplifies the specification of graph traits for graphs that use a flattened adjacency matrix representation,
140+
/// allowing users to easily define their graph types with the desired properties and directionality while defaulting
141+
/// to the flattened adjacency matrix implementation.
142+
///
143+
/// > [!NOTE] Template parameters
144+
/// >
145+
/// > The template parameters for this alias are the same as those for @ref gl::graph_traits "graph_traits", with the
146+
/// > `ImplTag` parameter fixed to @ref gl::impl::flat_matrix_t "impl::flat_matrix_t". This means that when using `flat_matrix_graph_traits`,
147+
/// > only the `DirectionalTag`, `VertexProperties`, `EdgeProperties`, and `IdType` parameters need to be specified.
56148
template <
57149
traits::c_graph_directional_tag DirectionalTag = directed_t,
58150
traits::c_properties VertexProperties = empty_properties,
@@ -61,6 +153,16 @@ template <
61153
using flat_matrix_graph_traits =
62154
graph_traits<DirectionalTag, VertexProperties, EdgeProperties, impl::flat_matrix_t, IdType>;
63155

156+
/// @ingroup GL GL-Core
157+
/// @brief Type alias for graph traits with an directed graph configuration.
158+
///
159+
/// This alias simplifies the specification of graph traits for directed graphs, allowing users to easily define their
160+
/// graph types with the desired properties and implementation while defaulting to a directed configuration.
161+
///
162+
/// > [!NOTE] Template parameters
163+
/// > The template parameters for this alias are the same as those for @ref gl::graph_traits "graph_traits", with the
164+
/// > `DirectionalTag` parameter fixed to @ref gl::directed_t "directed_t". This means that when using `directed_graph_traits`,
165+
/// > only the `VertexProperties`, `EdgeProperties`, 'ImplTag', and `IdType` parameters need to be specified.
64166
template <
65167
traits::c_properties VertexProperties = empty_properties,
66168
traits::c_properties EdgeProperties = empty_properties,
@@ -69,6 +171,16 @@ template <
69171
using directed_graph_traits =
70172
graph_traits<directed_t, VertexProperties, EdgeProperties, ImplTag, IdType>;
71173

174+
/// @ingroup GL GL-Core
175+
/// @brief Type alias for graph traits with an undirected graph configuration.
176+
///
177+
/// This alias simplifies the specification of graph traits for undirected graphs, allowing users to easily define their
178+
/// graph types with the desired properties and implementation while defaulting to an undirected configuration.
179+
///
180+
/// > [!NOTE] Template parameters
181+
/// > The template parameters for this alias are the same as those for @ref gl::graph_traits "graph_traits", with the
182+
/// > `DirectionalTag` parameter fixed to @ref gl::undirected_t "undirected_t". This means that when using `undirected_graph_traits`,
183+
/// > only the `VertexProperties`, `EdgeProperties`, 'ImplTag', and `IdType` parameters need to be specified.
72184
template <
73185
traits::c_properties VertexProperties = empty_properties,
74186
traits::c_properties EdgeProperties = empty_properties,
@@ -79,39 +191,63 @@ using undirected_graph_traits =
79191

80192
namespace traits {
81193

194+
/// @ingroup GL GL-Traits
195+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with a list implementation.
196+
/// @tparam TraitsType The type to evaluate against the concept.
82197
template <typename TraitsType>
83198
concept c_list_graph_traits =
84199
c_instantiation_of<TraitsType, graph_traits>
85200
and std::same_as<typename TraitsType::implementation_tag, impl::list_t>;
86201

202+
/// @ingroup GL GL-Traits
203+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with a flattened adjacency list implementation.
204+
/// @tparam TraitsType The type to evaluate against the concept.
87205
template <typename TraitsType>
88206
concept c_flat_list_graph_traits =
89207
c_instantiation_of<TraitsType, graph_traits>
90208
and std::same_as<typename TraitsType::implementation_tag, impl::flat_list_t>;
91209

210+
/// @ingroup GL GL-Traits
211+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with an adjacency list implementation (either standard or flattened).
212+
/// @tparam TraitsType The type to evaluate against the concept.
92213
template <typename TraitsType>
93214
concept c_adjacency_list_graph_traits =
94215
c_list_graph_traits<TraitsType> or c_flat_list_graph_traits<TraitsType>;
95216

217+
/// @ingroup GL GL-Traits
218+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with a matrix implementation.
219+
/// @tparam TraitsType The type to evaluate against the concept.
96220
template <typename TraitsType>
97221
concept c_matrix_graph_traits =
98222
c_instantiation_of<TraitsType, graph_traits>
99223
and std::same_as<typename TraitsType::implementation_tag, impl::matrix_t>;
100224

225+
/// @ingroup GL GL-Traits
226+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with a flattened adjacency matrix implementation.
227+
/// @tparam TraitsType The type to evaluate against the concept.
101228
template <typename TraitsType>
102229
concept c_flat_matrix_graph_traits =
103230
c_instantiation_of<TraitsType, graph_traits>
104231
and std::same_as<typename TraitsType::implementation_tag, impl::flat_matrix_t>;
105232

233+
/// @ingroup GL GL-Traits
234+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with a matrix implementation (either standard or flattened).
235+
/// @tparam TraitsType The type to evaluate against the concept.
106236
template <typename TraitsType>
107237
concept c_adjacency_matrix_graph_traits =
108238
c_matrix_graph_traits<TraitsType> or c_flat_matrix_graph_traits<TraitsType>;
109239

240+
/// @ingroup GL GL-Traits
241+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with a directed graph configuration.
242+
/// @tparam TraitsType The type to evaluate against the concept.
110243
template <typename TraitsType>
111244
concept c_directed_graph_traits =
112245
c_instantiation_of<TraitsType, graph_traits>
113246
and std::same_as<typename TraitsType::directional_tag, directed_t>;
114247

248+
/// @ingroup GL GL-Traits
249+
/// @brief Concept to validate if a type is an instantiation of @ref gl::graph_traits "graph_traits" with an undirected graph configuration.
250+
/// @tparam TraitsType The type to evaluate against the concept.
115251
template <typename TraitsType>
116252
concept c_undirected_graph_traits =
117253
c_instantiation_of<TraitsType, graph_traits>

include/gl/impl/impl_tags.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// This file is part of the CPP-GL project (https://github.com/SpectraL519/cpp-gl).
33
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
44

5+
/// @file gl/impl/impl_tags.hpp
6+
/// @brief Defines implementation tags for different graph representations.
7+
58
#pragma once
69

710
#include "gl/decl/impl_tags.hpp"
@@ -10,25 +13,49 @@
1013

1114
namespace gl::impl {
1215

16+
/// @ingroup GL GL-Core
17+
/// @headerfile gl/impl/impl_tags.hpp
18+
/// @brief Tag struct for the standard adjacency list graph implementation.
1319
struct list_t {
20+
/// @brief Type alias for the adjacency list graph implementation based on the provided graph traits.
21+
/// @tparam GraphTraits The graph traits for which to define the adjacency list type.
22+
/// Must be an instantiation of @ref gl::graph_traits "graph_traits" and have `list_t` as its implementation tag.
1423
template <traits::c_instantiation_of<graph_traits> GraphTraits>
1524
requires(std::same_as<typename GraphTraits::implementation_tag, list_t>)
1625
using type = adjacency_list<GraphTraits>;
1726
};
1827

28+
/// @ingroup GL GL-Core
29+
/// @headerfile gl/impl/impl_tags.hpp
30+
/// @brief Tag struct for the flattened adjacency list graph implementation.
1931
struct flat_list_t {
32+
/// @brief Type alias for the flattened adjacency list graph implementation based on the provided graph traits.
33+
/// @tparam GraphTraits The graph traits for which to define the flattened adjacency list type.
34+
/// Must be an instantiation of @ref gl::graph_traits "graph_traits" and have `flat_list_t` as its implementation tag.
2035
template <traits::c_instantiation_of<graph_traits> GraphTraits>
2136
requires(std::same_as<typename GraphTraits::implementation_tag, flat_list_t>)
2237
using type = adjacency_list<GraphTraits>;
2338
};
2439

40+
/// @ingroup GL GL-Core
41+
/// @headerfile gl/impl/impl_tags.hpp
42+
/// @brief Tag struct for the standard adjacency matrix graph implementation.
2543
struct matrix_t {
44+
/// @brief Type alias for the adjacency matrix graph implementation based on the provided graph traits.
45+
/// @tparam GraphTraits The graph traits for which to define the adjacency matrix type.
46+
/// Must be an instantiation of @ref gl::graph_traits "graph_traits" and have `matrix_t` as its implementation tag.
2647
template <traits::c_instantiation_of<graph_traits> GraphTraits>
2748
requires(std::same_as<typename GraphTraits::implementation_tag, matrix_t>)
2849
using type = adjacency_matrix<GraphTraits>;
2950
};
3051

52+
/// @ingroup GL GL-Core
53+
/// @headerfile gl/impl/impl_tags.hpp
54+
/// @brief Tag struct for the flattened adjacency matrix graph implementation.
3155
struct flat_matrix_t {
56+
/// @brief Type alias for the flattened adjacency matrix graph implementation based on the provided graph traits.
57+
/// @tparam GraphTraits The graph traits for which to define the flattened adjacency matrix type.
58+
/// Must be an instantiation of @ref gl::graph_traits "graph_traits" and have `flat_matrix_t` as its implementation tag.
3259
template <traits::c_instantiation_of<graph_traits> GraphTraits>
3360
requires(std::same_as<typename GraphTraits::implementation_tag, flat_matrix_t>)
3461
using type = adjacency_matrix<GraphTraits>;

0 commit comments

Comments
 (0)