Skip to content

Commit 84b777a

Browse files
committed
directional tags docs
1 parent 4ea6fe3 commit 84b777a

1 file changed

Lines changed: 73 additions & 8 deletions

File tree

include/gl/directional_tags.hpp

Lines changed: 73 additions & 8 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/directional_tags.hpp
6+
/// @brief Defines tag types used to specify the directionality of a graph.
7+
58
#pragma once
69

710
#include "gl/attributes/force_inline.hpp"
@@ -16,6 +19,14 @@ struct undirected_t;
1619

1720
namespace traits {
1821

22+
/// @ingroup GL GL-Traits
23+
/// @brief Validates if a type is a valid graph directional tag.
24+
///
25+
/// The valid graph directional tags are @ref gl::directed_t "directed_t" and @ref gl::undirected_t "undirected_t".
26+
/// This concept is used to constrain template parameters that are intended to specify the directionality of a graph,
27+
/// ensuring that only valid tags can be used in such contexts.
28+
///
29+
/// @tparam T The type to evaluate against the concept.
1930
template <typename T>
2031
concept c_graph_directional_tag = c_one_of<T, directed_t, undirected_t>;
2132

@@ -29,51 +40,105 @@ class edge_descriptor;
2940

3041
namespace traits {
3142

43+
/// @ingroup GL GL-Traits
44+
/// @brief Concept to validate if a type is an instantiation of @ref gl::edge_descriptor "edge_descriptor" with the @ref gl::directed_t "directed_t" tag.
45+
/// @tparam T The type to evaluate against the concept.
3246
template <typename E>
3347
concept c_directed_edge =
3448
c_instantiation_of<E, edge_descriptor>
3549
and std::same_as<typename E::directional_tag, directed_t>;
3650

51+
/// @ingroup GL GL-Traits
52+
/// @brief Concept to validate if a type is an instantiation of @ref gl::edge_descriptor "edge_descriptor" with the @ref gl::undirected_t "undirected_t" tag.
53+
/// @tparam T The type to evaluate against the concept.
3754
template <typename E>
3855
concept c_undirected_edge =
3956
c_instantiation_of<E, edge_descriptor>
4057
and std::same_as<typename E::directional_tag, undirected_t>;
4158

4259
} // namespace traits
4360

61+
/// @ingroup GL GL-Core
62+
/// @headerfile gl/directional_tags.hpp
63+
/// @brief The tag type representing a directed graph configuration.
64+
///
65+
/// This tag is used to indicate that a graph is directed, meaning that its edges
66+
/// have a specific direction from a source vertex to a target vertex.
67+
///
68+
/// ### See Also
69+
/// - @ref gl::undirected_t "undirected_t" : For the tag representing an undirected graph configuration.
70+
/// - [**c_graph_directional_tag**](gl_traits.md#gl-traits-c-graph-directional-tag) : For the concept used to validate graph directional tags.
71+
/// - @ref gl::edge_descriptor "edge_descriptor" : For the edge descriptor type defined based on the graph traits, which includes the directional tag as part of its definition.
4472
struct directed_t {
73+
/// @brief A type identity alias for the directed_t tag, allowing for easier type comparisons and trait evaluations.
4574
using type = std::type_identity_t<directed_t>;
4675

47-
template <traits::c_instantiation_of<edge_descriptor> EdgeType>
48-
requires(traits::c_directed_edge<EdgeType>)
76+
/// @brief Determines if a given edge is incident from a specified vertex in a directed graph.
77+
///
78+
/// Validates whether the provided vertex ID corresponds specifically to the **source** vertex of the edge.
79+
///
80+
/// @tparam EdgeType The type of the edge descriptor, which must be an instantiation of @ref gl::edge_descriptor "edge_descriptor" with the directed tag.
81+
/// @return For a directed edge $(u, v)$ and a vertex ID `vertex_id`, returns `true` if `vertex_id` corresponds to $u$ (the source vertex), and `false` otherwise.
82+
template <traits::c_directed_edge EdgeType>
4983
[[nodiscard]] gl_attr_force_inline static bool is_incident_from(
5084
const EdgeType& edge, typename EdgeType::id_type vertex_id
5185
) {
5286
return vertex_id == edge._vertices.first;
5387
}
5488

55-
template <traits::c_instantiation_of<edge_descriptor> EdgeType>
56-
requires(traits::c_directed_edge<EdgeType>)
89+
/// @brief Determines if a given edge is incident to a specified vertex in a directed graph.
90+
///
91+
/// Validates whether the provided vertex ID corresponds specifically to the **target** vertex of the edge.
92+
///
93+
/// @tparam EdgeType The type of the edge descriptor, which must be an instantiation of @ref gl::edge_descriptor "edge_descriptor" with the directed tag.
94+
/// @return For a directed edge $(u, v)$ and a vertex ID `vertex_id`, returns `true` if `vertex_id` corresponds to $v$ (the target vertex), and `false` otherwise.
95+
template <traits::c_directed_edge EdgeType>
5796
[[nodiscard]] gl_attr_force_inline static bool is_incident_to(
5897
const EdgeType& edge, typename EdgeType::id_type vertex_id
5998
) {
6099
return vertex_id == edge._vertices.second;
61100
}
62101
};
63102

103+
/// @ingroup GL GL-Core
104+
/// @headerfile gl/directional_tags.hpp
105+
/// @brief The tag type representing an undirected graph configuration.
106+
///
107+
/// This tag is used to indicate that a graph is undirected, meaning that its edges do not have
108+
/// a specific direction and can be traversed in both directions between the connected vertices.
109+
///
110+
/// ### See Also
111+
/// - @ref gl::directed_t "directed_t" : For the tag representing a directed graph configuration.
112+
/// - [**c_graph_directional_tag**](gl_traits.md#gl-traits-c-graph-directional-tag) : For the concept used to validate graph directional tags.
113+
/// - @ref gl::edge_descriptor "edge_descriptor" : For the edge descriptor type defined based on the graph traits, which includes the directional tag as part of its definition.
64114
struct undirected_t {
115+
/// @brief A type identity alias for the undirected_t tag, allowing for easier type comparisons and trait evaluations.
65116
using type = std::type_identity_t<undirected_t>;
66117

67-
template <traits::c_instantiation_of<edge_descriptor> EdgeType>
68-
requires(traits::c_undirected_edge<EdgeType>)
118+
/// @brief Determines if a given edge is incident from a specified vertex in an undirected graph.
119+
///
120+
/// Validates whether the provided vertex ID corresponds to either of the vertices connected by the edge,
121+
/// since in an undirected graph, both vertices are incident *with* the edge, hence they are both considered
122+
/// to be incident from the edge.
123+
///
124+
/// @tparam EdgeType The type of the edge descriptor, which must be an instantiation of @ref gl::edge_descriptor "edge_descriptor" with the undirected tag.
125+
/// @return For an undirected edge \f$\{u, v\}\f$, and a vertex ID `vertex_id`, returns `true` if `vertex_id` corresponds to either $u$ or $v$, and `false` otherwise.
126+
template <traits::c_undirected_edge EdgeType>
69127
[[nodiscard]] gl_attr_force_inline static bool is_incident_from(
70128
const EdgeType& edge, typename EdgeType::id_type vertex_id
71129
) {
72130
return edge.is_incident_with(vertex_id);
73131
}
74132

75-
template <traits::c_instantiation_of<edge_descriptor> EdgeType>
76-
requires(traits::c_undirected_edge<EdgeType>)
133+
/// @brief Determines if a given edge is incident to a specified vertex in an undirected graph.
134+
///
135+
/// Validates whether the provided vertex ID corresponds to either of the vertices connected by the edge,
136+
/// since in an undirected graph, both vertices are incident *with* the edge, hence they are both considered
137+
/// to be incident to the edge.
138+
///
139+
/// @tparam EdgeType The type of the edge descriptor, which must be an instantiation of @ref gl::edge_descriptor "edge_descriptor" with the undirected tag.
140+
/// @return For an undirected edge \f$\{u, v\}\f$, and a vertex ID `vertex_id`, returns `true` if `vertex_id` corresponds to either $u$ or $v$, and `false` otherwise.
141+
template <traits::c_undirected_edge EdgeType>
77142
[[nodiscard]] gl_attr_force_inline static bool is_incident_to(
78143
const EdgeType& edge, typename EdgeType::id_type vertex_id
79144
) {

0 commit comments

Comments
 (0)