Skip to content

Commit e508ac8

Browse files
committed
concrete bfs docs + @see fix
1 parent 1f89fe6 commit e508ac8

11 files changed

Lines changed: 103 additions & 32 deletions

File tree

include/gl/algorithm/spanning_tree/prim_mst.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ struct mst_descriptor {
7373
/// @param graph The undirected graph to evaluate.
7474
/// @param root_id The starting vertex ID for the MST calculation. Defaults to the graph's `initial_id` if `invalid_id` is passed.
7575
/// @return A @ref gl::algorithm::mst_descriptor "mst_descriptor" containing the accumulated minimum weight and the sequence of edges forming the tree.
76-
/// @see @ref gl::algorithm::vertex_heap_prim_mst "vertex_heap_prim_mst" For the vertex-heap variant of the Prim's MST finding algorithm.
76+
/// ### See Also
77+
/// - @ref gl::algorithm::vertex_heap_prim_mst "vertex_heap_prim_mst" For the vertex-heap variant of the Prim's MST finding algorithm.
7778
/// @hideparams
7879
template <traits::c_undirected_graph G>
7980
[[nodiscard]] mst_descriptor<G> edge_heap_prim_mst(const G& graph, typename G::id_type root_id) {
@@ -164,7 +165,8 @@ template <traits::c_undirected_graph G>
164165
/// @param graph The undirected graph to evaluate.
165166
/// @param root_id The starting vertex ID for the MST calculation. Defaults to the graph's `initial_id` if `invalid_id` is passed.
166167
/// @return A @ref gl::algorithm::mst_descriptor "mst_descriptor" containing the accumulated minimum weight and the sequence of edges forming the tree.
167-
/// @see @ref gl::algorithm::edge_heap_prim_mst "edge_heap_prim_mst" For the vertex-heap variant of the Prim's MST finding algorithm.
168+
/// ### See Also
169+
/// - @ref gl::algorithm::edge_heap_prim_mst "edge_heap_prim_mst" For the vertex-heap variant of the Prim's MST finding algorithm.
168170
/// @hideparams
169171
template <traits::c_undirected_graph G>
170172
requires(traits::c_has_numeric_limits_max<vertex_distance_type<G>>)

include/gl/algorithm/topology/coloring.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ template <
117117
/// @brief Convenience wrapper for the @ref gl::algorithm::bipartite_coloring "bipartite_coloring" algorithm to check if a graph is bipartite without extracting the exact coloring map.
118118
/// @param graph The graph to evaluate.
119119
/// @return `true` if the graph is bipartite (2-colorable), `false` otherwise.
120-
/// @see @ref gl::algorithm::apply_coloring "apply_coloring"
120+
/// ### See Also
121+
/// - @ref gl::algorithm::apply_coloring "apply_coloring"
121122
[[nodiscard]] gl_attr_force_inline bool is_bipartite(const traits::c_graph auto& graph) {
122123
return bipartite_coloring(graph).has_value();
123124
}

include/gl/algorithm/traversal/breadth_first_search.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ namespace gl::algorithm {
2626
///
2727
/// ### Example Usage
2828
/// ```cpp
29-
/// auto pred_map = gl::algorithm::breadth_first_search(graph, start_id); // (1)!
29+
/// auto pred_map
30+
/// = gl::algorithm::breadth_first_search(graph, start_id); // (1)!
3031
///
3132
/// gl::algorithm::breadth_first_search<gl::algorithm::noret>( // (2)!
3233
/// graph,
@@ -55,7 +56,7 @@ namespace gl::algorithm {
5556
/// ### Template Parameters
5657
/// | Parameter | Description | Constraint |
5758
/// | :-------- | :--- | :--- |
58-
/// | Result | @ref gl::algorithm::result_discriminator "Discriminator" dictating if the algorithm should return a predecessor map (`ret`) or `void` (`noret`). | Must be a valid @ref gl::algorithm::result_discriminator "result_discriminator" enum value. |
59+
/// | Result | Discriminator dictating if the algorithm should return a predecessor map (`ret`) or `void` (`noret`). | Must be a valid @ref gl::algorithm::result_discriminator "result_discriminator" enum value. |
5960
/// | G | The type of the graph being traversed. | Must satisfy the [**c_graph**](gl_concepts.md#gl-traits-c-graph) concept. |
6061
/// | PreVisitCallback | Type of the callable executed immediately before a vertex is officially visited. | Must be one of:<br/>- `(id_type) -> void` callable<br/>- An @ref gl::algorithm::empty_callback "empty_callback" |
6162
/// | PostVisitCallback | Type of the callable executed after all adjacent edges of a vertex are evaluated. | Must be one of:<br/>- `(id_type) -> void` callable<br/>- An @ref gl::algorithm::empty_callback "empty_callback" |

include/gl/algorithm/traversal/depth_first_search.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ namespace gl::algorithm {
3434
///
3535
/// ### Example Usage
3636
/// ```cpp
37-
/// auto pred_map = gl::algorithm::depth_first_search(graph, start_id); // (1)!
37+
/// auto pred_map
38+
/// = gl::algorithm::depth_first_search(graph, start_id); // (1)!
3839
///
3940
/// gl::algorithm::depth_first_search<gl::algorithm::noret>( // (2)!
4041
/// graph,
@@ -135,7 +136,6 @@ result_type<Result, predecessors_map<G>> depth_first_search(
135136
///
136137
/// ### Example Usage
137138
/// ```cpp
138-
/// // Execution purely for side-effects from a specific root
139139
/// gl::algorithm::recursive_depth_first_search<gl::algorithm::noret>( // (1)!
140140
/// graph,
141141
/// start_id, // (2)!
@@ -144,7 +144,7 @@ result_type<Result, predecessors_map<G>> depth_first_search(
144144
/// );
145145
/// ```
146146
///
147-
/// 1\. Execution purely for side-effects over the entire graph. Uses the @ref gl::algorithm::result_discriminator "noret" discriminator to completely compile away the predecessor map allocations.
147+
/// 1\. Execution purely for side-effects. Uses the @ref gl::algorithm::result_discriminator "noret" discriminator to completely compile away the predecessor map allocations.
148148
///
149149
/// 2\. Initiates the recursion from `start_id`.
150150
///

include/gl/impl/impl_tags.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ struct list_t {
2828
/// @ingroup GL GL-Core
2929
/// @headerfile gl/impl/impl_tags.hpp
3030
/// @brief Tag struct for the flattened adjacency list graph implementation.
31-
/// @see @ref gl::flat_jagged_vector "flat_jagged_vector" : For the data structure used for the underlying model implementation.
31+
/// ### See Also
32+
/// - @ref gl::flat_jagged_vector "flat_jagged_vector" : For the data structure used for the underlying model implementation.
3233
struct flat_list_t {
3334
/// @brief Type alias for the flattened adjacency list graph implementation based on the provided graph traits.
3435
/// @tparam GraphTraits The graph traits for which to define the flattened adjacency list type.
@@ -53,7 +54,8 @@ struct matrix_t {
5354
/// @ingroup GL GL-Core
5455
/// @headerfile gl/impl/impl_tags.hpp
5556
/// @brief Tag struct for the flattened adjacency matrix graph implementation.
56-
/// @see @ref gl::flat_matrix "flat_matrix" : For the data structure used for the underlying model implementation.
57+
/// ### See Also
58+
/// - @ref gl::flat_matrix "flat_matrix" : For the data structure used for the underlying model implementation.
5759
struct flat_matrix_t {
5860
/// @brief Type alias for the flattened adjacency matrix graph implementation based on the provided graph traits.
5961
/// @tparam GraphTraits The graph traits for which to define the flattened adjacency matrix type.

include/gl/io/ranges.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ range_formatter(R&& r, std::string_view, std::string_view, std::string_view)
104104
/// @param range The range object to format.
105105
/// @param sep The separator string between elements. Defaults to `", "`.
106106
/// @return A @ref range_formatter configured for set-style output.
107-
/// @see @ref gl::io::multiline_set_formatter "multiline_set_formatter"
107+
/// ### See Also
108+
/// - @ref gl::io::multiline_set_formatter "multiline_set_formatter"
108109
template <std::ranges::range R>
109110
auto set_formatter(R&& range, std::string_view sep = ", ") {
110111
using view_type = std::views::all_t<R>;
@@ -136,7 +137,8 @@ auto set_formatter(R&& range, std::string_view sep = ", ") {
136137
/// @tparam R The type of the range.
137138
/// @param range The range object to format.
138139
/// @return A @ref range_formatter configured for multiline set-style output.
139-
/// @see @ref gl::io::set_formatter "set_formatter"
140+
/// ### See Also
141+
/// - @ref gl::io::set_formatter "set_formatter"
140142
template <std::ranges::range R>
141143
auto multiline_set_formatter(R&& range) {
142144
using view_type = std::views::all_t<R>;

include/hgl/algorithm/core.hpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,40 @@ namespace algorithm {
2525

2626
/// @ingroup HGL-Algorithm
2727
/// @copybrief gl::algorithm::empty_callback
28-
/// @see gl::algorithm::empty_callback for a more detailed description.
28+
/// ### See Also
29+
/// - @ref gl::algorithm::empty_callback : For a more detailed description.
2930
using empty_callback = gl::algorithm::empty_callback;
3031

3132
/// @ingroup HGL-Algorithm
3233
/// @copybrief gl::algorithm::decision
33-
/// @see gl::algorithm::decision for the full type definition
34+
/// ### See Also
35+
/// - @ref gl::algorithm::decision : For the full type definition.
3436
using decision = gl::algorithm::decision;
3537

3638
/// @ingroup HGL-Algorithm
3739
/// @copybrief gl::algorithm::result_discriminator
38-
/// @see gl::algorithm::result_discriminator for the full type definition.
40+
/// ### See Also
41+
/// - @ref gl::algorithm::result_discriminator : For the full type definition.
3942
using result_discriminator = gl::algorithm::result_discriminator;
4043
using enum result_discriminator;
4144

4245
/// @ingroup HGL-Algorithm
4346
/// @copybrief gl::algorithm::result_type
44-
/// @see gl::algorithm::result_type for the full type definition.
47+
/// ### See Also
48+
/// - @ref gl::algorithm::result_type : For the full type definition.
4549
template <result_discriminator Result, typename ResultType>
4650
using result_type = gl::algorithm::result_type<Result, ResultType>;
4751

4852
/// @ingroup HGL-Algorithm
4953
/// @copybrief gl::algorithm::non_void_result_type
50-
/// @see gl::algorithm::non_void_result_type for the full type definition.
54+
/// @see gl::algorithm::non_void_result_type : For the full type definition.
5155
template <result_discriminator Result, typename ResultType>
5256
using non_void_result_type = gl::algorithm::non_void_result_type<Result, ResultType>;
5357

5458
/// @ingroup HGL-Algorithm
5559
/// @copybrief gl::algorithm::no_root_v
56-
/// @see gl::algorithm::no_root_v
60+
/// ### See Also
61+
/// - @ref gl::algorithm::no_root_v
5762
template <traits::c_id_type IdType>
5863
inline constexpr IdType no_root_v = gl::algorithm::no_root_v<IdType>;
5964

@@ -64,7 +69,8 @@ using no_root_t = gl::algorithm::no_root_t;
6469

6570
/// @ingroup HGL-Algorithm
6671
/// @copybrief gl::algorithm::no_root
67-
/// @see gl::algorithm::no_root
72+
/// ### See Also
73+
/// - @ref gl::algorithm::no_root
6874
inline constexpr no_root_t no_root = gl::algorithm::no_root;
6975

7076
// --- traversal types ---
@@ -111,7 +117,7 @@ struct search_node {
111117
///
112118
/// The $i$-th element corresponds to the vertex with `id == i`. The tree topology is formed implicitly,
113119
/// as each @ref hgl::algorithm::search_node "search_node" stores the ID of its predecessor and the
114-
/// connecting hyperedge, enabling $O(1)$ lookups and and $O(\vert V \vert)$ path reconstruction.
120+
/// connecting hyperedge, enabling \f$O(1)\f$ lookups and and \f$O(\vert V \vert)\f$ path reconstruction.
115121
///
116122
/// @tparam H The type of the hypergraph being searched.
117123
template <traits::c_hypergraph H>

include/hgl/algorithm/traversal/breadth_first_search.hpp

Lines changed: 45 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 hgl/algorithm/traversal/breadth_first_search.hpp
6+
/// @brief Concrete Breadth-First Search (BFS) traversal algorithm implementation for hypergraphs.
7+
58
#pragma once
69

710
#include "hgl/algorithm/core.hpp"
@@ -10,6 +13,48 @@
1013

1114
namespace hgl::algorithm {
1215

16+
/// @ingroup HGL-Algorithm
17+
/// @brief Executes a concrete Breadth-First Search (BFS) traversal over the hypergraph.
18+
///
19+
/// This function utilizes the generic @ref hgl::algorithm::bfs "bfs" template to perform a standard queue-based traversal.
20+
/// It automatically manages the visited states (for both vertices and hyperedges), search tree tracking, and queue initialization.
21+
///
22+
/// If a specific `root_vertex_id` is provided, the algorithm explores only the connected component reachable from that root.
23+
/// If `no_root` is used, it iteratively ensures that every disconnected component in the entire hypergraph is fully traversed.
24+
///
25+
/// ### Example Usage
26+
/// ```cpp
27+
/// auto search_tree
28+
/// = hgl::algorithm::breadth_first_search(hypergraph, start_id); // (1)!
29+
///
30+
/// hgl::algorithm::breadth_first_search<hgl::algorithm::noret>( // (2)!
31+
/// hypergraph,
32+
/// hgl::algorithm::no_root, // (3)!
33+
/// [](const auto& node) { std::cout << "Pre-visit: " << node.vertex_id << '\n'; },
34+
/// [](const auto& node) { std::cout << "Post-visit: " << node.vertex_id << '\n'; }
35+
/// );
36+
/// ```
37+
///
38+
/// 1\. Executes a standard BFS returning a search tree mapped to the components reachable from `start_id`.
39+
///
40+
/// 2\. Executes a BFS purely for side-effects (callbacks) without allocating memory for a search tree.
41+
///
42+
/// 3\. Passing `no_root` forces the algorithm to iterate over all vertices, ensuring disjoint components are traversed.
43+
///
44+
/// ### Template Parameters
45+
/// | Parameter | Description | Constraint |
46+
/// | :-------- | :--- | :--- |
47+
/// | Result | Controls whether the algorithm builds and returns a search tree (`ret`) or evaluates purely for side effects (`noret`). | Must be a valid @ref hgl::algorithm::result_discriminator "result_discriminator" enum value. |
48+
/// | H | The type of the hypergraph being searched. | Must satisfy the [**c_hypergraph**](hgl_concepts.md#hgl-traits-c-hypergraph) concept. |
49+
/// | PreVisitCallback | Type of the callable executed immediately before officially visiting a vertex. | Must be one of:<br/>- A `(const search_node<H>&) -> void` callable<br/>- An @ref hgl::algorithm::empty_callback "empty_callback" |
50+
/// | PostVisitCallback | Type of the callable executed after all adjacent elements are evaluated. | Must be one of:<br/>- A `(const search_node<H>&) -> void` callable<br/>- An @ref hgl::algorithm::empty_callback "empty_callback" |
51+
///
52+
/// @param hypergraph The hypergraph to traverse.
53+
/// @param root_vertex_id The ID of the vertex to start the search from. If `no_root`, searches the entire hypergraph.
54+
/// @param pre_visit Hook executed immediately before officially visiting the vertex.
55+
/// @param post_visit Hook executed after all adjacent hyperedges and target vertices of the current node have been evaluated.
56+
/// @return A @ref hgl::algorithm::search_tree "search_tree" if `Result == ret`, otherwise nothing (`void`).
57+
/// @hideparams
1358
template <
1459
result_discriminator Result = ret,
1560
traits::c_hypergraph H,

include/hgl/impl/impl_tags.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ struct list_t {
5858
///
5959
/// @tparam LayoutTag Specifies the memory layout orientation for the underlying data structure.
6060
/// @tparam IdType The underlying integer type used for identifiers.
61-
/// @see @ref gl::flat_jagged_vector "flat_jagged_vector" for the data structure used for the underlying model implementation.
61+
/// ### See Also
62+
/// - @ref gl::flat_jagged_vector "flat_jagged_vector" for the data structure used for the underlying model implementation.
6263
template <traits::c_hypergraph_layout_tag LayoutTag, traits::c_id_type IdType>
6364
struct flat_list_t {
6465
/// @brief Self type alias.
@@ -115,7 +116,8 @@ struct matrix_t {
115116
///
116117
/// @tparam LayoutTag Specifies the memory layout orientation for the underlying data structure (must be asymmetric).
117118
/// @tparam IdType The underlying integer type used for identifiers.
118-
/// @see @ref gl::flat_matrix "flat_matrix" for the data structure used for the underlying model implementation.
119+
/// ### See Also
120+
/// - @ref gl::flat_matrix "flat_matrix" for the data structure used for the underlying model implementation.
119121
template <traits::c_hypergraph_asymmetric_layout_tag LayoutTag, traits::c_id_type IdType>
120122
struct flat_matrix_t {
121123
/// @brief Self type alias.

include/hgl/types.hpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,22 @@ using gl::to_diff;
4343

4444
/// @ingroup HGL-Types
4545
/// @brief @copybrief gl::flat_jagged_vector
46-
/// @see gl::flat_jagged_vector for the full type definition
46+
/// ### See Also
47+
/// - @ref gl::flat_jagged_vector : For the full type definition.
4748
template <std::semiregular T>
4849
using flat_jagged_vector = gl::flat_jagged_vector<T>;
4950

5051
/// @ingroup HGL-Types
5152
/// @brief @copybrief gl::flat_matrix
52-
/// @see gl::flat_matrix for the full type definition
53+
/// ### See Also
54+
/// - @ref gl::flat_matrix "gl::flat_matrix" : For the full type definition.
5355
template <std::semiregular T>
5456
using flat_matrix = gl::flat_matrix<T>;
5557

5658
/// @ingroup HGL-Types
5759
/// @brief @copybrief gl::homogeneous_pair
58-
/// @see gl::homogeneous_pair for the full type definition
60+
/// ### See Also
61+
/// - @ref gl::homogeneous_pair : For the full type definition.
5962
template <typename T>
6063
using homogeneous_pair = gl::homogeneous_pair<T>;
6164

@@ -69,7 +72,8 @@ using homogeneous_pair = gl::homogeneous_pair<T>;
6972
/// > This type is used as a default `properties_type` for hypergraph components that do not require any user-defined data.
7073
/// > It serves as a marker to indicate that the component is *property-less* and can be optimized accordingly.
7174
///
72-
/// @see gl::empty_properties for the full type definition
75+
/// ### See Also
76+
/// - @ref gl::empty_properties : For the full type definition.
7377
using empty_properties = gl::empty_properties;
7478

7579
/// @ingroup HGL-Core
@@ -79,22 +83,26 @@ using empty_properties = gl::empty_properties;
7983
/// >
8084
/// > This type is used internally by the library to optimize storage for hypergraph components that have no properties.
8185
///
82-
/// @see gl::empty_properties_map for the full type definition
86+
/// ### See Also
87+
/// - @ref gl::empty_properties_map : For the full type definition.
8388
using empty_properties_map = gl::empty_properties_map;
8489

8590
/// @ingroup HGL-Core
8691
/// @brief @copybrief gl::name_property
87-
/// @see gl::name_property for the full type definition
92+
/// ### See Also
93+
/// - @ref gl::name_property : For the full type definition.
8894
using name_property = gl::name_property;
8995

9096
/// @ingroup HGL-Core
9197
/// @brief @copybrief gl::dynamic_properties
92-
/// @see gl::dynamic_properties for the full type definition
98+
/// ### See Also
99+
/// - @ref gl::dynamic_properties : For the full type definition.
93100
using dynamic_properties = gl::dynamic_properties;
94101

95102
/// @ingroup HGL-Core
96103
/// @brief A property struct providing arithmetic weight for hyperedges or vertices.
97-
/// @see gl::weight_property for the full type definition
104+
/// ### See Also
105+
/// - @ref gl::weight_property : For the full type definition.
98106
template <traits::c_arithmetic WeightType = double>
99107
using weight_property = gl::weight_property<WeightType>;
100108

0 commit comments

Comments
 (0)