Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-graph-concepts.H
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
63# ifndef AH_GRAPH_CONCEPTS_H
64# define AH_GRAPH_CONCEPTS_H
65
66# include <concepts>
67# include <cstddef>
68# include <type_traits>
69
70# include <ah-concepts.H>
71
72namespace Aleph
73{
74 template <class BaseGraph> class Digraph;
75
76 namespace graph_concepts_detail
77 {
79 template <class G>
81 requires
82 {
83 typename G::Node;
84 typename G::Arc;
85 typename G::Node_Type;
86 typename G::Arc_Type;
87 } and
88 requires(const G & g, typename G::Arc * a)
89 {
90 { g.get_num_nodes() } -> std::convertible_to<std::size_t>;
91 { g.get_num_arcs() } -> std::convertible_to<std::size_t>;
92 { g.get_src_node(a) } -> std::convertible_to<typename G::Node *>;
93 { g.get_tgt_node(a) } -> std::convertible_to<typename G::Node *>;
94 { g.is_digraph() } -> std::convertible_to<bool>;
95 };
96
98 template <class GT>
99 using graph_t = std::remove_cvref_t<GT>;
100
103 template <class B>
104 std::true_type derives_from_digraph(const volatile Digraph<B> *);
105
107 std::false_type derives_from_digraph(const volatile void *);
108 } // namespace graph_concepts_detail
109
120 template <class GT>
122
131 template <class SN, class GT>
132 concept NodeFilter =
135
146 template <class SA, class GT>
147 concept ArcFilter =
148 AlephGraph<GT> and std::copy_constructible<SA> and
150
160 template <class D, class GT>
161 concept ArcDistance =
163 requires { typename D::Distance_Type; } and
164 requires(D & d, typename graph_concepts_detail::graph_t<GT>::Arc * a)
165 {
166 { d(a) } -> std::convertible_to<typename D::Distance_Type>;
167 };
168
185 template <class GT>
186 concept DigraphType =
188 static_cast<graph_concepts_detail::graph_t<GT> *>(nullptr)))::value;
189
198 template <class Net>
199 concept FlowNetwork =
201 requires { typename graph_concepts_detail::graph_t<Net>::Flow_Type; } and
202 requires(const graph_concepts_detail::graph_t<Net> & net,
204 {
205 { net.get_source() } -> std::convertible_to<typename graph_concepts_detail::graph_t<Net>::Node *>;
206 { net.get_sink() } -> std::convertible_to<typename graph_concepts_detail::graph_t<Net>::Node *>;
207 { net.is_single_source() } -> std::convertible_to<bool>;
208 { net.is_single_sink() } -> std::convertible_to<bool>;
209 { a->cap } -> std::convertible_to<typename graph_concepts_detail::graph_t<Net>::Flow_Type>;
210 { a->flow } -> std::convertible_to<typename graph_concepts_detail::graph_t<Net>::Flow_Type>;
211 };
212
213} // namespace Aleph
214
215# endif // AH_GRAPH_CONCEPTS_H
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
size_t size_t int32_t value
Definition ca-c-api.h:116
Generic directed graph (digraph) wrapper template.
Definition graph-dry.H:4377
A graph usable by the graph algorithms.
An arc distance (Distance) for graph GT.
An arc filter (SA) for graph GT.
A graph type built with the Digraph template.
A flow network usable by the max-flow and min-cost algorithms.
A node filter (SN) for graph GT.
f(args...) is a valid call whose result is usable as a condition.
Unqualified form of AlephGraph, applied to a cv/ref-free type.
List_Graph< Graph_Node< string >, Graph_Arc< Empty_Class > > G
List_Digraph< Node, Arc > Digraph
Definition graphpic.C:400
std::true_type derives_from_digraph(const volatile Digraph< B > *)
Chosen when a pointer to the graph converts to one to a Digraph<B>, that is, when its type derives fr...
std::remove_cvref_t< GT > graph_t
GT with cv-qualifiers and references removed.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.