Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_const_graph_view.H
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 version 2.0.0b
6 https://github.com/lrleon/Aleph-w
7
8 This file is part of Aleph-w library
9
10 Copyright (c) 2002-2026 Leandro Rabindranath Leon
11
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files (the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29*/
30
31
126# ifndef TPL_CONST_GRAPH_VIEW_H
127# define TPL_CONST_GRAPH_VIEW_H
128
129# include <cstddef>
130# include <type_traits>
131# include <utility>
132
133# include <ah-concepts.H>
134# include <ah-graph-concepts.H>
135# include <ah-iterator.H>
136# include <htlist.H>
137
138namespace Aleph
139{
140 template <class GT>
141 class Const_Graph_View;
142
143 namespace const_graph_view_detail
144 {
155 template <class T>
156 [[nodiscard]] constexpr T * as_graph_item(const T *p) noexcept
157 {
158 return const_cast<T *>(p);
159 }
160 } // namespace const_graph_view_detail
161
172 template <class GT>
173 class Const_Node_Iterator : public Const_Iterator<typename GT::Node_Iterator>
174 {
176
177 // A node iterator handing out a reference to the stored pointer would
178 // turn into a reference to a constant pointer to a modifiable node.
179 static_assert(std::is_same_v<decltype(std::declval<const Base &>().get_curr()),
180 const typename GT::Node *>,
181 "GT::Node_Iterator::get_curr() must hand out a Node * by value");
182
183 public:
185 using Item_Type = const typename GT::Node *;
186
188 using Set_Type = GT;
189
192
196 explicit Const_Node_Iterator(const GT & g) : Base(g) {}
197
202 : Base(*view.graph_ptr) {}
203
208 [[nodiscard]] Item_Type get_current_node() const { return this->get_curr(); }
209
211 [[nodiscard]] Item_Type get_current_node_ne() const noexcept
212 {
213 return this->get_curr_ne();
214 }
215 };
216
226 template <class GT>
227 class Const_Arc_Iterator : public Const_Iterator<typename GT::Arc_Iterator>
228 {
230
231 static_assert(std::is_same_v<decltype(std::declval<const Base &>().get_curr()),
232 const typename GT::Arc *>,
233 "GT::Arc_Iterator::get_curr() must hand out an Arc * by value");
234
235 public:
237 using Item_Type = const typename GT::Arc *;
238
240 using Set_Type = GT;
241
244
248 explicit Const_Arc_Iterator(const GT & g) : Base(g) {}
249
254 : Base(*view.graph_ptr) {}
255
260 [[nodiscard]] Item_Type get_current_arc() const { return this->get_curr(); }
261
263 [[nodiscard]] Item_Type get_current_arc_ne() const noexcept
264 {
265 return this->get_curr_ne();
266 }
267
272 [[nodiscard]] const typename GT::Node * get_src_node() const
273 {
274 return this->underlying().get_src_node();
275 }
276
278 [[nodiscard]] const typename GT::Node * get_src_node_ne() const noexcept
279 {
280 return this->underlying().get_src_node_ne();
281 }
282
287 [[nodiscard]] const typename GT::Node * get_tgt_node() const
288 {
289 return this->underlying().get_tgt_node();
290 }
291
293 [[nodiscard]] const typename GT::Node * get_tgt_node_ne() const noexcept
294 {
295 return this->underlying().get_tgt_node_ne();
296 }
297 };
298
309 template <class GT>
311 : public Const_Iterator<typename GT::Node_Arc_Iterator>
312 {
314
315 static_assert(std::is_same_v<decltype(std::declval<const Base &>().get_curr()),
316 const typename GT::Arc *>,
317 "GT::Node_Arc_Iterator::get_curr() must hand out an Arc * by value");
318
319 public:
321 using Item_Type = const typename GT::Arc *;
322
324 using Set_Type = const typename GT::Node *;
325
328
333 explicit Const_Node_Arc_Iterator(const typename GT::Node *p)
334 : Base(typename GT::Node_Arc_Iterator(const_graph_view_detail::as_graph_item(p))) {}
335
340 [[nodiscard]] Item_Type get_current_arc() const { return this->get_curr(); }
341
343 [[nodiscard]] Item_Type get_current_arc_ne() const noexcept
344 {
345 return this->get_curr_ne();
346 }
347
353 [[nodiscard]] const typename GT::Node * get_tgt_node() const
354 {
355 return this->underlying().get_tgt_node();
356 }
357
359 [[nodiscard]] const typename GT::Node * get_tgt_node_ne() const noexcept
360 {
361 return this->underlying().get_tgt_node_ne();
362 }
363 };
364
385 template <class GT>
387 {
388 const GT *graph_ptr;
389
390 friend class Const_Node_Iterator<GT>;
391 friend class Const_Arc_Iterator<GT>;
392
393 template <class, class, class> friend class Filter_Iterator;
394
395 // the empty view that a Filter_Iterator holds before it is given one
396 constexpr Const_Graph_View() noexcept : graph_ptr(nullptr) {}
397
398 [[nodiscard]] bool is_null_view() const noexcept { return graph_ptr == nullptr; }
399
400 template <class T>
401 static constexpr T * as_graph_item(const T *p) noexcept
402 {
404 }
405
406 public:
407 using Graph_Type = GT;
408
411 static constexpr bool filter_iterator_keeps_a_copy = true;
412
413 using Node = const typename GT::Node;
414
415 using Arc = const typename GT::Arc;
416
418 using Node_Type = typename GT::Node_Type;
419
421 using Arc_Type = typename GT::Arc_Type;
422
425
428
431
435 explicit Const_Graph_View(const GT & g) noexcept : graph_ptr(&g) {}
436
438 Const_Graph_View(const GT &&) = delete;
439
441 [[nodiscard]] size_t get_num_nodes() const noexcept
442 {
443 return graph_ptr->get_num_nodes();
444 }
445
447 [[nodiscard]] size_t vsize() const noexcept { return get_num_nodes(); }
448
450 [[nodiscard]] bool is_empty() const noexcept { return get_num_nodes() == 0; }
451
453 [[nodiscard]] size_t get_num_arcs() const noexcept
454 {
455 return graph_ptr->get_num_arcs();
456 }
457
459 [[nodiscard]] size_t esize() const noexcept { return get_num_arcs(); }
460
462 [[nodiscard]] bool is_digraph() const noexcept
463 {
464 return graph_ptr->is_digraph();
465 }
466
471 [[nodiscard]] size_t get_num_arcs(Node *p) const noexcept
472 {
474 }
475
480 [[nodiscard]] size_t degree(Node *p) const noexcept
481 {
482 return get_num_arcs(p);
483 }
484
489 [[nodiscard]] Node * get_src_node(Arc *a) const noexcept
490 {
492 }
493
498 [[nodiscard]] Node * get_tgt_node(Arc *a) const noexcept
499 {
501 }
502
508 [[nodiscard]] Node * get_connected_node(Arc *a, Node *p) const noexcept
509 {
511 }
512
518 [[nodiscard]] Node * get_first_node() const
519 {
520 return graph_ptr->get_first_node();
521 }
522
528 [[nodiscard]] Arc * get_first_arc() const
529 {
530 return graph_ptr->get_first_arc();
531 }
532
538 [[nodiscard]] Arc * get_first_arc(Node *p) const
539 {
541 }
542
544 [[nodiscard]] Node_Iterator get_node_it() const
545 {
546 return Node_Iterator(*this);
547 }
548
550 [[nodiscard]] Arc_Iterator get_arc_it() const
551 {
552 return Arc_Iterator(*this);
553 }
554
559 [[nodiscard]] Node_Arc_Iterator get_arc_it(Node *p) const
560 {
561 return Node_Arc_Iterator(p);
562 }
563
569 template <class Op>
571 bool traverse_nodes(Op && op) const
572 {
573 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
574 if (not op(it.get_curr_ne()))
575 return false;
576 return true;
577 }
578
584 template <class Op>
586 bool traverse_arcs(Op && op) const
587 {
588 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
589 if (not op(it.get_curr_ne()))
590 return false;
591 return true;
592 }
593
600 template <class Op>
602 bool traverse_arcs(Node *p, Op && op) const
603 {
604 for (Node_Arc_Iterator it(p); it.has_curr(); it.next_ne())
605 if (not op(it.get_curr_ne()))
606 return false;
607 return true;
608 }
609
613 template <class Op>
615 void for_each_node(Op && op) const
616 {
617 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
618 op(it.get_curr_ne());
619 }
620
624 template <class Op>
626 void for_each_arc(Op && op) const
627 {
628 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
629 op(it.get_curr_ne());
630 }
631
636 template <class Op>
638 void for_each_arc(Node *p, Op && op) const
639 {
640 for (Node_Arc_Iterator it(p); it.has_curr(); it.next_ne())
641 op(it.get_curr_ne());
642 }
643
648 template <class Op>
650 [[nodiscard]] bool all_nodes(Op && op) const
651 {
652 return traverse_nodes(op);
653 }
654
659 template <class Op>
661 [[nodiscard]] bool all_arcs(Op && op) const
662 {
663 return traverse_arcs(op);
664 }
665
671 template <class Op>
673 [[nodiscard]] bool all_arcs(Node *p, Op && op) const
674 {
675 return traverse_arcs(p, op);
676 }
677
682 template <class Op>
684 [[nodiscard]] Node * search_node(Op && op) const
685 {
686 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
687 if (Node *p = it.get_curr_ne(); op(p))
688 return p;
689 return nullptr;
690 }
691
696 template <class Op>
698 [[nodiscard]] Arc * search_arc(Op && op) const
699 {
700 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
701 if (Arc *a = it.get_curr_ne(); op(a))
702 return a;
703 return nullptr;
704 }
705
711 template <class Op>
713 [[nodiscard]] Arc * search_arc(Node *p, Op && op) const
714 {
715 for (Node_Arc_Iterator it(p); it.has_curr(); it.next_ne())
716 if (Arc *a = it.get_curr_ne(); op(a))
717 return a;
718 return nullptr;
719 }
720
726 [[nodiscard]] Arc * search_arc(Node *src, Node *tgt) const noexcept
727 {
728 for (Node_Arc_Iterator it(src); it.has_curr(); it.next_ne())
729 if (it.get_tgt_node_ne() == tgt)
730 return it.get_curr_ne();
731 return nullptr;
732 }
733
738 [[nodiscard]] Node * find_node(const Node_Type & info) const
739 {
740 return search_node([&info] (Node *p) { return p->get_info() == info; });
741 }
742
747 [[nodiscard]] Arc * find_arc(const Arc_Type & info) const
748 {
749 return search_arc([&info] (Arc *a) { return a->get_info() == info; });
750 }
751
756 template <class Op>
758 [[nodiscard]] bool exists_node(Op && op) const
759 {
760 return search_node(op) != nullptr;
761 }
762
767 template <class Op>
769 [[nodiscard]] bool exists_arc(Op && op) const
770 {
771 return search_arc(op) != nullptr;
772 }
773
779 template <class Op>
781 [[nodiscard]] bool exists_arc(Node *p, Op && op) const
782 {
783 return search_arc(p, op) != nullptr;
784 }
785
790 template <class Op>
792 [[nodiscard]] size_t count_nodes(Op && op) const
793 {
794 size_t count = 0;
795 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
796 if (op(it.get_curr_ne()))
797 ++count;
798 return count;
799 }
800
805 template <class Op>
807 [[nodiscard]] size_t count_arcs(Op && op) const
808 {
809 size_t count = 0;
810 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
811 if (op(it.get_curr_ne()))
812 ++count;
813 return count;
814 }
815
820 [[nodiscard]] DynList<Node *> nodes() const
821 {
822 DynList<Node *> ret;
823 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
824 ret.append(it.get_curr_ne());
825 return ret;
826 }
827
832 [[nodiscard]] DynList<Arc *> arcs() const
833 {
834 DynList<Arc *> ret;
835 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
836 ret.append(it.get_curr_ne());
837 return ret;
838 }
839
845 [[nodiscard]] DynList<Arc *> arcs(Node *p) const
846 {
847 DynList<Arc *> ret;
848 for (Node_Arc_Iterator it(p); it.has_curr(); it.next_ne())
849 ret.append(it.get_curr_ne());
850 return ret;
851 }
852
858 [[nodiscard]] DynList<Node *> adjacent_nodes(Node *p) const
859 {
860 DynList<Node *> ret;
861 for (Node_Arc_Iterator it(p); it.has_curr(); it.next_ne())
862 ret.append(it.get_tgt_node_ne());
863 return ret;
864 }
865
871 template <class Op>
873 [[nodiscard]] DynList<Node *> filter_nodes(Op && op) const
874 {
875 DynList<Node *> ret;
876 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
877 if (Node *p = it.get_curr_ne(); op(p))
878 ret.append(p);
879 return ret;
880 }
881
887 template <class Op>
889 [[nodiscard]] DynList<Arc *> filter_arcs(Op && op) const
890 {
891 DynList<Arc *> ret;
892 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
893 if (Arc *a = it.get_curr_ne(); op(a))
894 ret.append(a);
895 return ret;
896 }
897
904 template <class Op>
906 [[nodiscard]] DynList<Arc *> filter_arcs(Node *p, Op && op) const
907 {
908 DynList<Arc *> ret;
909 for (Node_Arc_Iterator it(p); it.has_curr(); it.next_ne())
910 if (Arc *a = it.get_curr_ne(); op(a))
911 ret.append(a);
912 return ret;
913 }
914
923 template <typename T = Node_Type, class Op>
924 requires std::is_invocable_r_v<T, Op &, Node *>
925 [[nodiscard]] DynList<T> nodes_map(Op op) const
926 {
927 DynList<T> ret;
928 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
929 ret.append(concepts_detail::invoke_as<T (Node *)>::call(op, it.get_curr_ne()));
930 return ret;
931 }
932
941 template <typename T = Arc_Type, class Op>
942 requires std::is_invocable_r_v<T, Op &, Arc *>
943 [[nodiscard]] DynList<T> arcs_map(Op op) const
944 {
945 DynList<T> ret;
946 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
947 ret.append(concepts_detail::invoke_as<T (Arc *)>::call(op, it.get_curr_ne()));
948 return ret;
949 }
950
958 template <typename T = Node_Type, class Op>
959 requires std::is_invocable_r_v<T, Op &, const T &, Node *>
960 [[nodiscard]] T foldl_nodes(const T & init, Op op) const
961 {
962 T ret = init;
963 for (Node_Iterator it(*this); it.has_curr(); it.next_ne())
964 ret = concepts_detail::invoke_as<T (const T &, Node *)>::call(op, ret, it.get_curr_ne());
965 return ret;
966 }
967
975 template <typename T = Arc_Type, class Op>
976 requires std::is_invocable_r_v<T, Op &, const T &, Arc *>
977 [[nodiscard]] T foldl_arcs(const T & init, Op op) const
978 {
979 T ret = init;
980 for (Arc_Iterator it(*this); it.has_curr(); it.next_ne())
981 ret = concepts_detail::invoke_as<T (const T &, Arc *)>::call(op, ret, it.get_curr_ne());
982 return ret;
983 }
984 };
985
998 template <AlephGraph GT>
999 [[nodiscard]] Const_Graph_View<GT> const_view(const GT & g) noexcept
1000 {
1001 return Const_Graph_View<GT>(g);
1002 }
1003
1005 template <AlephGraph GT>
1006 void const_view(const GT &&) = delete;
1007} // namespace Aleph
1008
1009# endif // TPL_CONST_GRAPH_VIEW_H
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
C++20 concepts for the protocol shared by graph algorithms.
STL-compatible iterator adapters for Aleph containers.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
Read-only iterator on the arcs of a graph.
Item_Type get_current_arc() const
The current arc.
const GT::Node * get_src_node_ne() const noexcept
get_src_node() without checking that there is a current arc.
const GT::Node * get_tgt_node_ne() const noexcept
get_tgt_node() without checking that there is a current arc.
Const_Arc_Iterator()=default
An iterator with no current arc.
const GT::Node * get_src_node() const
The source node of the current arc.
const GT::Node * get_tgt_node() const
The target node of the current arc.
Item_Type get_current_arc_ne() const noexcept
get_current_arc() without checking that there is a current arc.
const typename GT::Arc * Item_Type
The type of the items: a pointer to a constant arc.
Const_Arc_Iterator(const GT &g)
Iterator positioned on the first arc of g.
Const_Arc_Iterator(const Const_Graph_View< GT > &view)
Iterator positioned on the first arc seen through view.
Strict read-only view of a graph.
Node_Iterator get_node_it() const
Iterator positioned on the first node.
size_t degree(Node *p) const noexcept
Degree of a node: the number of its arcs.
size_t get_num_nodes() const noexcept
Total number of nodes.
Const_Node_Arc_Iterator< GT > Node_Arc_Iterator
Read-only iterator on the arcs of a node.
Arc_Iterator get_arc_it() const
Iterator positioned on the first arc.
Node * find_node(const Node_Type &info) const
Search a node by its information.
void for_each_arc(Node *p, Op &&op) const
Visit every arc of a node.
bool traverse_arcs(Op &&op) const
Visit the arcs while an operation answers true.
bool is_empty() const noexcept
true if the graph has no nodes.
bool exists_arc(Node *p, Op &&op) const
true if some arc of a node satisfies a condition.
bool all_nodes(Op &&op) const
true if every node satisfies a condition.
bool traverse_arcs(Node *p, Op &&op) const
Visit the arcs of a node while an operation answers true.
const typename GT::Arc Arc
The constant arc type.
Arc * search_arc(Op &&op) const
Linear search of an arc.
Arc * find_arc(const Arc_Type &info) const
Search an arc by its information.
bool all_arcs(Node *p, Op &&op) const
true if every arc of a node satisfies a condition.
Const_Graph_View(const GT &&)=delete
A view of a temporary graph would dangle.
size_t count_nodes(Op &&op) const
Number of nodes satisfying a condition.
Const_Node_Iterator< GT > Node_Iterator
Read-only iterator on the nodes.
Const_Arc_Iterator< GT > Arc_Iterator
Read-only iterator on the arcs.
bool all_arcs(Op &&op) const
true if every arc satisfies a condition.
Node * get_src_node(Arc *a) const noexcept
The source node of an arc.
Arc * search_arc(Node *p, Op &&op) const
Linear search among the arcs of a node.
bool traverse_nodes(Op &&op) const
Visit the nodes while an operation answers true.
DynList< Arc * > arcs() const
The arcs of the graph.
bool exists_node(Op &&op) const
true if some node satisfies a condition.
Node * get_connected_node(Arc *a, Node *p) const noexcept
The node at the other end of an arc.
DynList< T > nodes_map(Op op) const
Map the nodes to a list.
size_t esize() const noexcept
Synonym of get_num_arcs().
bool is_digraph() const noexcept
true if the graph is directed.
DynList< Node * > nodes() const
The nodes of the graph.
Arc * get_first_arc(Node *p) const
Any arc of a node.
Node * get_first_node() const
Any node of the graph.
static constexpr bool filter_iterator_keeps_a_copy
A Filter_Iterator on a view keeps a copy of it: the view is small, and it is often a temporary.
DynList< T > arcs_map(Op op) const
Map the arcs to a list.
Const_Graph_View(const GT &g) noexcept
View of the graph g.
Node * get_tgt_node(Arc *a) const noexcept
The target node of an arc.
T foldl_nodes(const T &init, Op op) const
Fold the nodes from the left.
Arc * get_first_arc() const
Any arc of the graph.
void for_each_node(Op &&op) const
Visit every node.
Node * search_node(Op &&op) const
Linear search of a node.
DynList< Arc * > filter_arcs(Op &&op) const
The arcs satisfying a condition.
size_t get_num_arcs() const noexcept
Total number of arcs.
size_t vsize() const noexcept
Synonym of get_num_nodes().
const typename GT::Node Node
The constant node type.
typename GT::Node_Type Node_Type
The type of the information stored in a node.
T foldl_arcs(const T &init, Op op) const
Fold the arcs from the left.
constexpr Const_Graph_View() noexcept
DynList< Arc * > filter_arcs(Node *p, Op &&op) const
The arcs of a node satisfying a condition.
bool exists_arc(Op &&op) const
true if some arc satisfies a condition.
void for_each_arc(Op &&op) const
Visit every arc.
Node_Arc_Iterator get_arc_it(Node *p) const
Iterator positioned on the first arc of a node.
size_t get_num_arcs(Node *p) const noexcept
Number of arcs of a node, as the graph counts them.
DynList< Arc * > arcs(Node *p) const
The arcs of a node.
static constexpr T * as_graph_item(const T *p) noexcept
DynList< Node * > adjacent_nodes(Node *p) const
The nodes connected to a node.
typename GT::Arc_Type Arc_Type
The type of the information stored in an arc.
Arc * search_arc(Node *src, Node *tgt) const noexcept
Search an arc connecting two nodes.
DynList< Node * > filter_nodes(Op &&op) const
The nodes satisfying a condition.
bool is_null_view() const noexcept
size_t count_arcs(Op &&op) const
Number of arcs satisfying a condition.
Read-only view of an Aleph iterator: the iterator of a constant container.
GT::Arc_Iterator & underlying() const noexcept
The underlying iterator, for the views that extend the reading protocol with members of their own (th...
auto has_curr() const noexcept(noexcept(std::declval< I & >().has_curr())) -> decltype(std::declval< I & >().has_curr())
true if there is a current item.
auto get_curr_ne() const noexcept(noexcept(std::declval< I & >().get_curr_ne())) -> const_iterator_detail::const_item_t< decltype(std::declval< I & >().get_curr_ne())>
get_curr() without the checks of the underlying iterator.
auto get_curr() const noexcept(noexcept(std::declval< I & >().get_curr())) -> const_iterator_detail::const_item_t< decltype(std::declval< I & >().get_curr())>
The current item, read-only.
Read-only iterator on the arcs of a node.
Item_Type get_current_arc_ne() const noexcept
get_current_arc() without checking that there is a current arc.
const typename GT::Node * Set_Type
The type of what is iterated: a constant node.
const GT::Node * get_tgt_node_ne() const noexcept
get_tgt_node() without checking that there is a current arc.
const typename GT::Arc * Item_Type
The type of the items: a pointer to a constant arc.
Const_Node_Arc_Iterator(const typename GT::Node *p)
Iterator positioned on the first arc of the node p.
Const_Node_Arc_Iterator()=default
An iterator with no current arc.
const GT::Node * get_tgt_node() const
The node at the other end of the current arc.
Item_Type get_current_arc() const
The current arc.
Read-only iterator on the nodes of a graph.
Const_Node_Iterator()=default
An iterator with no current node.
Item_Type get_current_node() const
The current node.
Const_Node_Iterator(const GT &g)
Iterator positioned on the first node of g.
const typename GT::Node * Item_Type
The type of the items: a pointer to a constant node.
Item_Type get_current_node_ne() const noexcept
get_current_node() without checking that there is a current node.
Const_Node_Iterator(const Const_Graph_View< GT > &view)
Iterator positioned on the first node seen through view.
Doubly-linked list (defined in tpl_dynList.H).
Definition htlist.H:1231
T & append(const T &item)
Definition htlist.H:1362
Generic filter iterator wrapper.
Node * get_first_node() const
Return any node in the graph.
Definition tpl_graph.H:590
Arc * get_first_arc(Node *node) const
Return any arc adjacent to a node.
Definition tpl_graph.H:609
typename Node::Node_Type Node_Type
The arc class type.
Definition tpl_graph.H:447
typename Arc::Arc_Type Arc_Type
The type of data stored in the arc.
Definition tpl_graph.H:450
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Definition graph-dry.H:975
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Definition graph-dry.H:1017
bool is_digraph() const noexcept
Return true if the graph this is directed.
Definition graph-dry.H:937
Node * get_connected_node(Arc *arc, Node *node) const noexcept
Return the adjacent node to node through arc.
Definition graph-dry.H:1058
constexpr size_t get_num_arcs() const noexcept
Return the number of arcs of the graph.
Definition graph-dry.H:1064
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
Definition graph-dry.H:1023
f(args...) is a valid call expression, exactly as written.
f(args...) is a valid call whose result is usable as a condition.
Const_Graph_View< GT > const_view(const GT &g) noexcept
Strict read-only view of a graph.
Singly linked list implementations with head-tail access.
constexpr T * as_graph_item(const T *p) noexcept
Hands a node or an arc read through a view back to the graph.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
Definition ah-zip.H:152
static std::atomic< bool > init
Definition hash-fct.C:54
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Definition ahAlgo.H:127
Filtered iterator of adjacent arcs of a node.
Definition tpl_graph.H:1155