Skip to content

Commit 97e3e04

Browse files
committed
more docu
1 parent eceb700 commit 97e3e04

2 files changed

Lines changed: 107 additions & 16 deletions

File tree

include/osp/concepts/constructable_computational_dag_concept.hpp

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,32 @@ limitations under the License.
2222

2323
#include "computational_dag_concept.hpp"
2424

25+
/**
26+
* @file constructable_computational_dag_concept.hpp
27+
* @brief Concepts for Constructable and Modifiable Computational DAGs.
28+
*
29+
* This file defines concepts that validate whether a graph type supports dynamic construction
30+
* and modification of its structure and properties. This includes adding vertices and edges,
31+
* as well as setting weights and types for existing elements.
32+
*
33+
* These concepts are useful for algorithms that need to build or transform graphs,
34+
* such as graph generators or coarsening algorithms.
35+
*/
2536

2637
namespace osp {
2738

28-
// modify vertices
39+
/**
40+
* @brief Concept to check if vertex weights are modifiable.
41+
*
42+
* Requires:
43+
* - `set_vertex_work_weight(v, w)`
44+
* - `set_vertex_comm_weight(v, w)`
45+
* - `set_vertex_mem_weight(v, w)`
46+
*
47+
* Also requires the graph to be default constructible, copy/move constructible, and assignable.
48+
*
49+
* @tparam T The graph type.
50+
*/
2951
template<typename T, typename = void>
3052
struct is_modifiable_cdag_vertex : std::false_type {};
3153

@@ -36,54 +58,83 @@ struct is_modifiable_cdag_vertex<
3658
decltype(std::declval<T>().set_vertex_mem_weight(std::declval<vertex_idx_t<T>>(), std::declval<v_memw_t<T>>()))>>
3759
: std::conjunction<is_computational_dag<T>,
3860
std::is_default_constructible<T>,
39-
std::is_copy_constructible<T>,
40-
std::is_move_constructible<T>,
61+
std::is_copy_constructible<T>,
62+
std::is_move_constructible<T>,
4163
std::is_copy_assignable<T>,
4264
std::is_move_assignable<T>> {};
4365

4466
template<typename T>
4567
inline constexpr bool is_modifiable_cdag_vertex_v = is_modifiable_cdag_vertex<T>::value;
4668

47-
// add vertices
69+
/**
70+
* @brief Concept to check if vertices can be added to the graph.
71+
*
72+
* Requires:
73+
* - `add_vertex(work_weight, comm_weight, mem_weight)`
74+
* - Constructibility from `vertex_idx_t` (for reserving size).
75+
*
76+
* @tparam T The graph type.
77+
*/
4878
template<typename T, typename = void>
4979
struct is_constructable_cdag_vertex : std::false_type {};
5080

5181
template<typename T>
5282
struct is_constructable_cdag_vertex<
5383
T, std::void_t<decltype(std::declval<T>().add_vertex(std::declval<v_workw_t<T>>(), std::declval<v_commw_t<T>>(), std::declval<v_memw_t<T>>()))>>
54-
: std::conjunction<is_modifiable_cdag_vertex<T>,
84+
: std::conjunction<is_modifiable_cdag_vertex<T>,
5585
std::is_constructible<T, vertex_idx_t<T>>> {};
5686

5787
template<typename T>
5888
inline constexpr bool is_constructable_cdag_vertex_v = is_constructable_cdag_vertex<T>::value;
5989

60-
// modify vertices types
90+
/**
91+
* @brief Concept to check if vertex types are modifiable.
92+
*
93+
* Requires:
94+
* - `set_vertex_type(v, type)`
95+
*
96+
* @tparam T The graph type.
97+
*/
6198
template<typename T, typename = void>
6299
struct is_modifiable_cdag_typed_vertex : std::false_type {};
63100

64101
template<typename T>
65102
struct is_modifiable_cdag_typed_vertex<
66103
T, std::void_t<decltype(std::declval<T>().set_vertex_type(std::declval<vertex_idx_t<T>>(), std::declval<v_type_t<T>>()))>>
67-
: std::conjunction<is_modifiable_cdag_vertex<T>,
104+
: std::conjunction<is_modifiable_cdag_vertex<T>,
68105
is_computational_dag_typed_vertices<T>> {}; // for default node type
69106

70107
template<typename T>
71108
inline constexpr bool is_modifiable_cdag_typed_vertex_v = is_modifiable_cdag_typed_vertex<T>::value;
72109

73-
// add vertices with types
110+
/**
111+
* @brief Concept to check if typed vertices can be added.
112+
*
113+
* Requires:
114+
* - `add_vertex(work, comm, mem, type)`
115+
*
116+
* @tparam T The graph type.
117+
*/
74118
template<typename T, typename = void>
75119
struct is_constructable_cdag_typed_vertex : std::false_type {};
76120

77121
template<typename T>
78122
struct is_constructable_cdag_typed_vertex<
79123
T, std::void_t<decltype(std::declval<T>().add_vertex(std::declval<v_workw_t<T>>(), std::declval<v_commw_t<T>>(), std::declval<v_memw_t<T>>(), std::declval<v_type_t<T>>()))>>
80-
: std::conjunction<is_constructable_cdag_vertex<T>,
124+
: std::conjunction<is_constructable_cdag_vertex<T>,
81125
is_modifiable_cdag_typed_vertex<T>> {}; // for default node type
82126

83127
template<typename T>
84128
inline constexpr bool is_constructable_cdag_typed_vertex_v = is_constructable_cdag_typed_vertex<T>::value;
85129

86-
// add edges
130+
/**
131+
* @brief Concept to check if edges can be added (unweighted).
132+
*
133+
* Requires:
134+
* - `add_edge(source, target)`
135+
*
136+
* @tparam T The graph type.
137+
*/
87138
template<typename T, typename = void>
88139
struct is_constructable_cdag_edge : std::false_type {};
89140

@@ -95,7 +146,14 @@ struct is_constructable_cdag_edge<T, std::void_t<decltype(std::declval<T>().add_
95146
template<typename T>
96147
inline constexpr bool is_constructable_cdag_edge_v = is_constructable_cdag_edge<T>::value;
97148

98-
// modify edges with comm costs
149+
/**
150+
* @brief Concept to check if edge communication weights are modifiable.
151+
*
152+
* Requires:
153+
* - `set_edge_comm_weight(edge, weight)`
154+
*
155+
* @tparam T The graph type.
156+
*/
99157
template<typename T, typename = void>
100158
struct is_modifiable_cdag_comm_edge : std::false_type {};
101159

@@ -107,20 +165,34 @@ struct is_modifiable_cdag_comm_edge<
107165
template<typename T>
108166
inline constexpr bool is_modifiable_cdag_comm_edge_v = is_modifiable_cdag_comm_edge<T>::value;
109167

110-
// add edges with comm costs
168+
/**
169+
* @brief Concept to check if weighted edges can be added.
170+
*
171+
* Requires:
172+
* - `add_edge(source, target, weight)`
173+
*
174+
* @tparam T The graph type.
175+
*/
111176
template<typename T, typename = void>
112177
struct is_constructable_cdag_comm_edge : std::false_type {};
113178

114179
template<typename T>
115180
struct is_constructable_cdag_comm_edge<
116181
T, std::void_t<decltype(std::declval<T>().add_edge(std::declval<vertex_idx_t<T>>(), std::declval<vertex_idx_t<T>>(), std::declval<e_commw_t<T>>()))>>
117-
: std::conjunction<is_constructable_cdag_edge<T>,
182+
: std::conjunction<is_constructable_cdag_edge<T>,
118183
is_computational_dag_edge_desc<T>,
119184
is_modifiable_cdag_comm_edge<T>> {}; // for default edge weight
120185

121186
template<typename T>
122187
inline constexpr bool is_constructable_cdag_comm_edge_v = is_constructable_cdag_comm_edge<T>::value;
123188

189+
/**
190+
* @brief Concept for a fully constructable computational DAG.
191+
*
192+
* Combines `is_constructable_cdag_vertex` and `is_constructable_cdag_edge`.
193+
*
194+
* @tparam T The graph type.
195+
*/
124196
template<typename T, typename = void>
125197
struct is_constructable_cdag : std::false_type {};
126198

@@ -131,6 +203,9 @@ struct is_constructable_cdag<T, std::void_t<>>
131203
template<typename T>
132204
inline constexpr bool is_constructable_cdag_v = is_constructable_cdag<T>::value;
133205

206+
/**
207+
* @brief Helper trait to check if a graph can be directly constructed from a vertex count and a set of edges.
208+
*/
134209
template<typename T>
135210
inline constexpr bool is_direct_constructable_cdag_v = std::is_constructible<T, vertex_idx_t<T>, std::set<std::pair<vertex_idx_t<T>, vertex_idx_t<T>>>>::value;
136211

include/osp/concepts/specific_graph_impl.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,37 @@ limitations under the License.
1818

1919
#pragma once
2020

21+
/**
22+
* @file specific_graph_impl.hpp
23+
* @brief Type traits for specific graph implementations used in OneStopParallel.
24+
*
25+
* This file contains trait checks for specific graph implementations, such as
26+
* Compact Sparse Graphs (CSR-like structures), which may require specialized
27+
* handling or offer optimizations in certain algorithms.
28+
*/
29+
2130
namespace osp {
2231

23-
// Compact Sparse Graph concept
32+
/**
33+
* @brief Trait to check if a graph type is a `Compact_Sparse_Graph`.
34+
*
35+
* @tparam T The graph type.
36+
*/
2437
template<typename T, typename = void>
2538
struct is_Compact_Sparse_Graph : std::false_type {};
2639

2740
template<typename T>
2841
inline constexpr bool is_Compact_Sparse_Graph_v = is_Compact_Sparse_Graph<T>::value;
2942

30-
// Compact Sparse Graph concept with reorder
43+
/**
44+
* @brief Trait to check if a graph type is a `Compact_Sparse_Graph` that supports reordering.
45+
*
46+
* @tparam T The graph type.
47+
*/
3148
template<typename T, typename = void>
3249
struct is_Compact_Sparse_Graph_reorder : std::false_type {};
3350

3451
template<typename T>
3552
inline constexpr bool is_Compact_Sparse_Graph_reorder_v = is_Compact_Sparse_Graph_reorder<T>::value;
3653

37-
3854
} // namespace osp

0 commit comments

Comments
 (0)