Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Const_Graph_View< GT > Class Template Reference

Strict read-only view of a graph. More...

#include <tpl_const_graph_view.H>

Collaboration diagram for Aleph::Const_Graph_View< GT >:
[legend]

Public Types

using Graph_Type = GT
 The type of the graph that is viewed.
 
using Node = const typename GT::Node
 The constant node type.
 
using Arc = const typename GT::Arc
 The constant arc type.
 
using Node_Type = typename GT::Node_Type
 The type of the information stored in a node.
 
using Arc_Type = typename GT::Arc_Type
 The type of the information stored in an arc.
 
using Node_Iterator = Const_Node_Iterator< GT >
 Read-only iterator on the nodes.
 
using Arc_Iterator = Const_Arc_Iterator< GT >
 Read-only iterator on the arcs.
 
using Node_Arc_Iterator = Const_Node_Arc_Iterator< GT >
 Read-only iterator on the arcs of a node.
 

Public Member Functions

 Const_Graph_View (const GT &g) noexcept
 View of the graph g.
 
 Const_Graph_View (const GT &&)=delete
 A view of a temporary graph would dangle.
 
size_t get_num_nodes () const noexcept
 Total number of nodes.
 
size_t vsize () const noexcept
 Synonym of get_num_nodes().
 
bool is_empty () const noexcept
 true if the graph has no nodes.
 
size_t get_num_arcs () const noexcept
 Total number of arcs.
 
size_t esize () const noexcept
 Synonym of get_num_arcs().
 
bool is_digraph () const noexcept
 true if the graph is directed.
 
size_t get_num_arcs (Node *p) const noexcept
 Number of arcs of a node, as the graph counts them.
 
size_t degree (Node *p) const noexcept
 Degree of a node: the number of its arcs.
 
Node * get_src_node (Arc *a) const noexcept
 The source node of an arc.
 
Node * get_tgt_node (Arc *a) const noexcept
 The target node of an arc.
 
Node * get_connected_node (Arc *a, Node *p) const noexcept
 The node at the other end of an arc.
 
Node * get_first_node () const
 Any node of the graph.
 
Arc * get_first_arc () const
 Any arc of the graph.
 
Arc * get_first_arc (Node *p) const
 Any arc of a node.
 
Node_Iterator get_node_it () const
 Iterator positioned on the first node.
 
Arc_Iterator get_arc_it () const
 Iterator positioned on the first arc.
 
Node_Arc_Iterator get_arc_it (Node *p) const
 Iterator positioned on the first arc of a node.
 
template<class Op >
requires PredicateWith<Op &, Node *>
bool traverse_nodes (Op &&op) const
 Visit the nodes while an operation answers true.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
bool traverse_arcs (Op &&op) const
 Visit the arcs while an operation answers true.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
bool traverse_arcs (Node *p, Op &&op) const
 Visit the arcs of a node while an operation answers true.
 
template<class Op >
requires CallableWith<Op &, Node *>
void for_each_node (Op &&op) const
 Visit every node.
 
template<class Op >
requires CallableWith<Op &, Arc *>
void for_each_arc (Op &&op) const
 Visit every arc.
 
template<class Op >
requires CallableWith<Op &, Arc *>
void for_each_arc (Node *p, Op &&op) const
 Visit every arc of a node.
 
template<class Op >
requires PredicateWith<Op &, Node *>
bool all_nodes (Op &&op) const
 true if every node satisfies a condition.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
bool all_arcs (Op &&op) const
 true if every arc satisfies a condition.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
bool all_arcs (Node *p, Op &&op) const
 true if every arc of a node satisfies a condition.
 
template<class Op >
requires PredicateWith<Op &, Node *>
Node * search_node (Op &&op) const
 Linear search of a node.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
Arc * search_arc (Op &&op) const
 Linear search of an arc.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
Arc * search_arc (Node *p, Op &&op) const
 Linear search among the arcs of a node.
 
Arc * search_arc (Node *src, Node *tgt) const noexcept
 Search an arc connecting two nodes.
 
Node * find_node (const Node_Type &info) const
 Search a node by its information.
 
Arc * find_arc (const Arc_Type &info) const
 Search an arc by its information.
 
template<class Op >
requires PredicateWith<Op &, Node *>
bool exists_node (Op &&op) const
 true if some node satisfies a condition.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
bool exists_arc (Op &&op) const
 true if some arc satisfies a condition.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
bool exists_arc (Node *p, Op &&op) const
 true if some arc of a node satisfies a condition.
 
template<class Op >
requires PredicateWith<Op &, Node *>
size_t count_nodes (Op &&op) const
 Number of nodes satisfying a condition.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
size_t count_arcs (Op &&op) const
 Number of arcs satisfying a condition.
 
DynList< Node * > nodes () const
 The nodes of the graph.
 
DynList< Arc * > arcs () const
 The arcs of the graph.
 
DynList< Arc * > arcs (Node *p) const
 The arcs of a node.
 
DynList< Node * > adjacent_nodes (Node *p) const
 The nodes connected to a node.
 
template<class Op >
requires PredicateWith<Op &, Node *>
DynList< Node * > filter_nodes (Op &&op) const
 The nodes satisfying a condition.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
DynList< Arc * > filter_arcs (Op &&op) const
 The arcs satisfying a condition.
 
template<class Op >
requires PredicateWith<Op &, Arc *>
DynList< Arc * > filter_arcs (Node *p, Op &&op) const
 The arcs of a node satisfying a condition.
 
template<typename T = Node_Type, class Op >
requires std::is_invocable_r_v<T, Op &, Node *>
DynList< T > nodes_map (Op op) const
 Map the nodes to a list.
 
template<typename T = Arc_Type, class Op >
requires std::is_invocable_r_v<T, Op &, Arc *>
DynList< T > arcs_map (Op op) const
 Map the arcs to a list.
 
template<typename T = Node_Type, class Op >
requires std::is_invocable_r_v<T, Op &, const T &, Node *>
T foldl_nodes (const T &init, Op op) const
 Fold the nodes from the left.
 
template<typename T = Arc_Type, class Op >
requires std::is_invocable_r_v<T, Op &, const T &, Arc *>
T foldl_arcs (const T &init, Op op) const
 Fold the arcs from the left.
 

Static Public Attributes

static constexpr bool filter_iterator_keeps_a_copy = true
 A Filter_Iterator on a view keeps a copy of it: the view is small, and it is often a temporary.
 

Private Member Functions

constexpr Const_Graph_View () noexcept
 
bool is_null_view () const noexcept
 

Static Private Member Functions

template<class T >
static constexpr T * as_graph_item (const T *p) noexcept
 

Private Attributes

const GT * graph_ptr
 

Friends

class Const_Node_Iterator< GT >
 
class Const_Arc_Iterator< GT >
 
template<class , class , class >
class Filter_Iterator
 

Detailed Description

template<class GT>
class Aleph::Const_Graph_View< GT >

Strict read-only view of a graph.

Every member hands out const Node * and const Arc *, and every operation received is called with them: neither the information nor the bookkeeping of the nodes and of the arcs can be written through a view. See the description of tpl_const_graph_view.H for the meaning of a const graph, the cost, the lifetime and the limits of a view.

The members mirror the reading members of the graph classes, with the same names. Node and Arc are the constant node and arc types, so that Node * reads as in the graph classes and the view satisfies AlephGraph.

Template Parameters
GTthe graph type: List_Graph, List_Digraph, List_SGraph, List_SDigraph, Array_Graph, Array_Digraph or any class with their interface.
See also
const_view() Const_Node_Iterator Const_Arc_Iterator Const_Node_Arc_Iterator

Definition at line 386 of file tpl_const_graph_view.H.

Member Typedef Documentation

◆ Arc

template<class GT >
using Aleph::Const_Graph_View< GT >::Arc = const typename GT::Arc

The constant arc type.

Definition at line 415 of file tpl_const_graph_view.H.

◆ Arc_Iterator

template<class GT >
using Aleph::Const_Graph_View< GT >::Arc_Iterator = Const_Arc_Iterator<GT>

Read-only iterator on the arcs.

Definition at line 427 of file tpl_const_graph_view.H.

◆ Arc_Type

template<class GT >
using Aleph::Const_Graph_View< GT >::Arc_Type = typename GT::Arc_Type

The type of the information stored in an arc.

Definition at line 421 of file tpl_const_graph_view.H.

◆ Graph_Type

template<class GT >
using Aleph::Const_Graph_View< GT >::Graph_Type = GT

The type of the graph that is viewed.

Definition at line 407 of file tpl_const_graph_view.H.

◆ Node

template<class GT >
using Aleph::Const_Graph_View< GT >::Node = const typename GT::Node

The constant node type.

Definition at line 413 of file tpl_const_graph_view.H.

◆ Node_Arc_Iterator

template<class GT >
using Aleph::Const_Graph_View< GT >::Node_Arc_Iterator = Const_Node_Arc_Iterator<GT>

Read-only iterator on the arcs of a node.

Definition at line 430 of file tpl_const_graph_view.H.

◆ Node_Iterator

template<class GT >
using Aleph::Const_Graph_View< GT >::Node_Iterator = Const_Node_Iterator<GT>

Read-only iterator on the nodes.

Definition at line 424 of file tpl_const_graph_view.H.

◆ Node_Type

template<class GT >
using Aleph::Const_Graph_View< GT >::Node_Type = typename GT::Node_Type

The type of the information stored in a node.

Definition at line 418 of file tpl_const_graph_view.H.

Constructor & Destructor Documentation

◆ Const_Graph_View() [1/3]

template<class GT >
constexpr Aleph::Const_Graph_View< GT >::Const_Graph_View ( )
inlineconstexprprivatenoexcept

Definition at line 396 of file tpl_const_graph_view.H.

◆ Const_Graph_View() [2/3]

template<class GT >
Aleph::Const_Graph_View< GT >::Const_Graph_View ( const GT &  g)
inlineexplicitnoexcept

View of the graph g.

Parameters
[in]gthe graph; it must outlive the view.

Definition at line 435 of file tpl_const_graph_view.H.

◆ Const_Graph_View() [3/3]

template<class GT >
Aleph::Const_Graph_View< GT >::Const_Graph_View ( const GT &&  )
delete

A view of a temporary graph would dangle.

Member Function Documentation

◆ adjacent_nodes()

template<class GT >
DynList< Node * > Aleph::Const_Graph_View< GT >::adjacent_nodes ( Node *  p) const
inline

The nodes connected to a node.

Parameters
[in]pa node of the graph.
Returns
a list with the node at the other end of every arc of p.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 858 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ all_arcs() [1/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
bool Aleph::Const_Graph_View< GT >::all_arcs ( Node *  p,
Op &&  op 
) const
inline

true if every arc of a node satisfies a condition.

Parameters
[in]pa node of the graph.
[in]opthe condition, on a const Arc *.
Returns
true if op holds for every arc of p.

Definition at line 673 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::traverse_arcs().

◆ all_arcs() [2/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
bool Aleph::Const_Graph_View< GT >::all_arcs ( Op &&  op) const
inline

true if every arc satisfies a condition.

Parameters
[in]opthe condition, on a const Arc *.
Returns
true if op holds for every arc.

Definition at line 661 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::traverse_arcs().

◆ all_nodes()

template<class GT >
template<class Op >
requires PredicateWith<Op &, Node *>
bool Aleph::Const_Graph_View< GT >::all_nodes ( Op &&  op) const
inline

true if every node satisfies a condition.

Parameters
[in]opthe condition, on a const Node *.
Returns
true if op holds for every node.

Definition at line 650 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::traverse_nodes().

◆ arcs() [1/2]

template<class GT >
DynList< Arc * > Aleph::Const_Graph_View< GT >::arcs ( ) const
inline

The arcs of the graph.

Returns
a list with a pointer to every arc.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 832 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ arcs() [2/2]

template<class GT >
DynList< Arc * > Aleph::Const_Graph_View< GT >::arcs ( Node *  p) const
inline

The arcs of a node.

Parameters
[in]pa node of the graph.
Returns
a list with a pointer to every arc of p.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 845 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ arcs_map()

template<class GT >
template<typename T = Arc_Type, class Op >
requires std::is_invocable_r_v<T, Op &, Arc *>
DynList< T > Aleph::Const_Graph_View< GT >::arcs_map ( Op  op) const
inline

Map the arcs to a list.

Template Parameters
Tthe type of the items of the list; by default, the type of the information of an arc.
Parameters
[in]opcalled as op(a) with a a const Arc *; its result converts to T.
Returns
the list of the results, in the order of the visit.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 943 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ as_graph_item()

◆ count_arcs()

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
size_t Aleph::Const_Graph_View< GT >::count_arcs ( Op &&  op) const
inline

Number of arcs satisfying a condition.

Parameters
[in]opthe condition, on a const Arc *.
Returns
how many arcs satisfy op.

Definition at line 807 of file tpl_const_graph_view.H.

References Aleph::count(), and Aleph::Const_Iterator< It >::has_curr().

◆ count_nodes()

template<class GT >
template<class Op >
requires PredicateWith<Op &, Node *>
size_t Aleph::Const_Graph_View< GT >::count_nodes ( Op &&  op) const
inline

Number of nodes satisfying a condition.

Parameters
[in]opthe condition, on a const Node *.
Returns
how many nodes satisfy op.

Definition at line 792 of file tpl_const_graph_view.H.

References Aleph::count(), and Aleph::Const_Iterator< It >::has_curr().

◆ degree()

template<class GT >
size_t Aleph::Const_Graph_View< GT >::degree ( Node *  p) const
inlinenoexcept

Degree of a node: the number of its arcs.

Parameters
[in]pa node of the graph.
Returns
the number of arcs of p.

Definition at line 480 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::get_num_arcs().

◆ esize()

template<class GT >
size_t Aleph::Const_Graph_View< GT >::esize ( ) const
inlinenoexcept

Synonym of get_num_arcs().

Definition at line 459 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::get_num_arcs().

◆ exists_arc() [1/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
bool Aleph::Const_Graph_View< GT >::exists_arc ( Node *  p,
Op &&  op 
) const
inline

true if some arc of a node satisfies a condition.

Parameters
[in]pa node of the graph.
[in]opthe condition, on a const Arc *.
Returns
true if op holds for at least one arc of p.

Definition at line 781 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::search_arc().

◆ exists_arc() [2/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
bool Aleph::Const_Graph_View< GT >::exists_arc ( Op &&  op) const
inline

true if some arc satisfies a condition.

Parameters
[in]opthe condition, on a const Arc *.
Returns
true if op holds for at least one arc.

Definition at line 769 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::search_arc().

◆ exists_node()

template<class GT >
template<class Op >
requires PredicateWith<Op &, Node *>
bool Aleph::Const_Graph_View< GT >::exists_node ( Op &&  op) const
inline

true if some node satisfies a condition.

Parameters
[in]opthe condition, on a const Node *.
Returns
true if op holds for at least one node.

Definition at line 758 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::search_node().

◆ filter_arcs() [1/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
DynList< Arc * > Aleph::Const_Graph_View< GT >::filter_arcs ( Node *  p,
Op &&  op 
) const
inline

The arcs of a node satisfying a condition.

Parameters
[in]pa node of the graph.
[in]opthe condition, on a const Arc *.
Returns
a list with a pointer to every arc of p satisfying op.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 906 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ filter_arcs() [2/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
DynList< Arc * > Aleph::Const_Graph_View< GT >::filter_arcs ( Op &&  op) const
inline

The arcs satisfying a condition.

Parameters
[in]opthe condition, on a const Arc *.
Returns
a list with a pointer to every arc satisfying op.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 889 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ filter_nodes()

template<class GT >
template<class Op >
requires PredicateWith<Op &, Node *>
DynList< Node * > Aleph::Const_Graph_View< GT >::filter_nodes ( Op &&  op) const
inline

The nodes satisfying a condition.

Parameters
[in]opthe condition, on a const Node *.
Returns
a list with a pointer to every node satisfying op.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 873 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ find_arc()

template<class GT >
Arc * Aleph::Const_Graph_View< GT >::find_arc ( const Arc_Type &  info) const
inline

Search an arc by its information.

Parameters
[in]infothe information, compared with ==.
Returns
an arc whose information equals info, or nullptr.

Definition at line 747 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::search_arc().

◆ find_node()

template<class GT >
Node * Aleph::Const_Graph_View< GT >::find_node ( const Node_Type &  info) const
inline

Search a node by its information.

Parameters
[in]infothe information, compared with ==.
Returns
a node whose information equals info, or nullptr.

Definition at line 738 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::search_node().

◆ foldl_arcs()

template<class GT >
template<typename T = Arc_Type, class Op >
requires std::is_invocable_r_v<T, Op &, const T &, Arc *>
T Aleph::Const_Graph_View< GT >::foldl_arcs ( const T &  init,
Op  op 
) const
inline

Fold the arcs from the left.

Template Parameters
Tthe type of the accumulated value.
Parameters
[in]initthe initial value.
[in]opcalled as op(acc, a) with a a const Arc *; its result converts to T and becomes the accumulated value.
Returns
the accumulated value after the last arc.

Definition at line 977 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr(), and Aleph::init.

◆ foldl_nodes()

template<class GT >
template<typename T = Node_Type, class Op >
requires std::is_invocable_r_v<T, Op &, const T &, Node *>
T Aleph::Const_Graph_View< GT >::foldl_nodes ( const T &  init,
Op  op 
) const
inline

Fold the nodes from the left.

Template Parameters
Tthe type of the accumulated value.
Parameters
[in]initthe initial value.
[in]opcalled as op(acc, p) with p a const Node *; its result converts to T and becomes the accumulated value.
Returns
the accumulated value after the last node.

Definition at line 960 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr(), and Aleph::init.

◆ for_each_arc() [1/2]

template<class GT >
template<class Op >
requires CallableWith<Op &, Arc *>
void Aleph::Const_Graph_View< GT >::for_each_arc ( Node *  p,
Op &&  op 
) const
inline

Visit every arc of a node.

Parameters
[in]pa node of the graph.
[in]opcalled as op(a) with a a const Arc *.

Definition at line 638 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

◆ for_each_arc() [2/2]

template<class GT >
template<class Op >
requires CallableWith<Op &, Arc *>
void Aleph::Const_Graph_View< GT >::for_each_arc ( Op &&  op) const
inline

Visit every arc.

Parameters
[in]opcalled as op(a) with a a const Arc *.

Definition at line 626 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

◆ for_each_node()

template<class GT >
template<class Op >
requires CallableWith<Op &, Node *>
void Aleph::Const_Graph_View< GT >::for_each_node ( Op &&  op) const
inline

Visit every node.

Parameters
[in]opcalled as op(p) with p a const Node *.

Definition at line 615 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

◆ get_arc_it() [1/2]

template<class GT >
Arc_Iterator Aleph::Const_Graph_View< GT >::get_arc_it ( ) const
inline

Iterator positioned on the first arc.

Definition at line 550 of file tpl_const_graph_view.H.

◆ get_arc_it() [2/2]

template<class GT >
Node_Arc_Iterator Aleph::Const_Graph_View< GT >::get_arc_it ( Node *  p) const
inline

Iterator positioned on the first arc of a node.

Parameters
[in]pa node of the graph.
Returns
an iterator on the arcs of p.

Definition at line 559 of file tpl_const_graph_view.H.

◆ get_connected_node()

template<class GT >
Node * Aleph::Const_Graph_View< GT >::get_connected_node ( Arc *  a,
Node *  p 
) const
inlinenoexcept

The node at the other end of an arc.

Parameters
[in]aan arc of the graph.
[in]pone of the end points of a.
Returns
the other end point of a.

Definition at line 508 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::as_graph_item(), GraphCommon< GT, Node, Arc >::get_connected_node(), and Aleph::Const_Graph_View< GT >::graph_ptr.

◆ get_first_arc() [1/2]

template<class GT >
Arc * Aleph::Const_Graph_View< GT >::get_first_arc ( ) const
inline

Any arc of the graph.

Precondition
the graph has at least one arc; a graph without arcs is handled as GT::get_first_arc() handles it, and not every graph class checks.
Returns
a pointer to an arc.

Definition at line 528 of file tpl_const_graph_view.H.

References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_arc(), and Aleph::Const_Graph_View< GT >::graph_ptr.

◆ get_first_arc() [2/2]

template<class GT >
Arc * Aleph::Const_Graph_View< GT >::get_first_arc ( Node *  p) const
inline

Any arc of a node.

Parameters
[in]pa node of the graph.
Returns
a pointer to an arc of p.
Exceptions
std::range_errorif p has no arcs.

Definition at line 538 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::as_graph_item(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_arc(), and Aleph::Const_Graph_View< GT >::graph_ptr.

◆ get_first_node()

template<class GT >
Node * Aleph::Const_Graph_View< GT >::get_first_node ( ) const
inline

Any node of the graph.

Precondition
the graph has at least one node; an empty graph is handled as GT::get_first_node() handles it, and not every graph class checks.
Returns
a pointer to a node.

Definition at line 518 of file tpl_const_graph_view.H.

References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::get_first_node(), and Aleph::Const_Graph_View< GT >::graph_ptr.

◆ get_node_it()

template<class GT >
Node_Iterator Aleph::Const_Graph_View< GT >::get_node_it ( ) const
inline

Iterator positioned on the first node.

Definition at line 544 of file tpl_const_graph_view.H.

◆ get_num_arcs() [1/2]

template<class GT >
size_t Aleph::Const_Graph_View< GT >::get_num_arcs ( ) const
inlinenoexcept

◆ get_num_arcs() [2/2]

template<class GT >
size_t Aleph::Const_Graph_View< GT >::get_num_arcs ( Node *  p) const
inlinenoexcept

Number of arcs of a node, as the graph counts them.

Parameters
[in]pa node of the graph.
Returns
the number of arcs of p.

Definition at line 471 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::as_graph_item(), GraphCommon< GT, Node, Arc >::get_num_arcs(), and Aleph::Const_Graph_View< GT >::graph_ptr.

◆ get_num_nodes()

template<class GT >
size_t Aleph::Const_Graph_View< GT >::get_num_nodes ( ) const
inlinenoexcept

◆ get_src_node()

template<class GT >
Node * Aleph::Const_Graph_View< GT >::get_src_node ( Arc *  a) const
inlinenoexcept

The source node of an arc.

Parameters
[in]aan arc of the graph.
Returns
the node given first when a was inserted.

Definition at line 489 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::as_graph_item(), GraphCommon< GT, Node, Arc >::get_src_node(), and Aleph::Const_Graph_View< GT >::graph_ptr.

◆ get_tgt_node()

template<class GT >
Node * Aleph::Const_Graph_View< GT >::get_tgt_node ( Arc *  a) const
inlinenoexcept

The target node of an arc.

Parameters
[in]aan arc of the graph.
Returns
the node given second when a was inserted.

Definition at line 498 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::as_graph_item(), GraphCommon< GT, Node, Arc >::get_tgt_node(), and Aleph::Const_Graph_View< GT >::graph_ptr.

◆ is_digraph()

template<class GT >
bool Aleph::Const_Graph_View< GT >::is_digraph ( ) const
inlinenoexcept

true if the graph is directed.

Definition at line 462 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::graph_ptr, and GraphCommon< GT, Node, Arc >::is_digraph().

◆ is_empty()

template<class GT >
bool Aleph::Const_Graph_View< GT >::is_empty ( ) const
inlinenoexcept

true if the graph has no nodes.

Definition at line 450 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::get_num_nodes().

◆ is_null_view()

template<class GT >
bool Aleph::Const_Graph_View< GT >::is_null_view ( ) const
inlineprivatenoexcept

Definition at line 398 of file tpl_const_graph_view.H.

References Aleph::Const_Graph_View< GT >::graph_ptr.

◆ nodes()

template<class GT >
DynList< Node * > Aleph::Const_Graph_View< GT >::nodes ( ) const
inline

The nodes of the graph.

Returns
a list with a pointer to every node.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 820 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ nodes_map()

template<class GT >
template<typename T = Node_Type, class Op >
requires std::is_invocable_r_v<T, Op &, Node *>
DynList< T > Aleph::Const_Graph_View< GT >::nodes_map ( Op  op) const
inline

Map the nodes to a list.

Template Parameters
Tthe type of the items of the list; by default, the type of the information of a node.
Parameters
[in]opcalled as op(p) with p a const Node *; its result converts to T.
Returns
the list of the results, in the order of the visit.
Exceptions
std::bad_allocif there is no memory for the list.

Definition at line 925 of file tpl_const_graph_view.H.

References Aleph::DynList< T >::append(), and Aleph::Const_Iterator< It >::has_curr().

◆ search_arc() [1/3]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
Arc * Aleph::Const_Graph_View< GT >::search_arc ( Node *  p,
Op &&  op 
) const
inline

Linear search among the arcs of a node.

Parameters
[in]pa node of the graph.
[in]opthe condition, on a const Arc *.
Returns
the first arc of p satisfying op, or nullptr.

Definition at line 713 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

◆ search_arc() [2/3]

template<class GT >
Arc * Aleph::Const_Graph_View< GT >::search_arc ( Node *  src,
Node *  tgt 
) const
inlinenoexcept

Search an arc connecting two nodes.

Parameters
[in]srcthe node whose arcs are searched.
[in]tgtthe node at the other end.
Returns
an arc of src whose other end is tgt, or nullptr.

Definition at line 726 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

◆ search_arc() [3/3]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
Arc * Aleph::Const_Graph_View< GT >::search_arc ( Op &&  op) const
inline

Linear search of an arc.

Parameters
[in]opthe condition, on a const Arc *.
Returns
the first arc satisfying op, or nullptr.

Definition at line 698 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

Referenced by Aleph::Const_Graph_View< GT >::exists_arc(), Aleph::Const_Graph_View< GT >::exists_arc(), and Aleph::Const_Graph_View< GT >::find_arc().

◆ search_node()

template<class GT >
template<class Op >
requires PredicateWith<Op &, Node *>
Node * Aleph::Const_Graph_View< GT >::search_node ( Op &&  op) const
inline

Linear search of a node.

Parameters
[in]opthe condition, on a const Node *.
Returns
the first node satisfying op, or nullptr.

Definition at line 684 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

Referenced by Aleph::Const_Graph_View< GT >::exists_node(), and Aleph::Const_Graph_View< GT >::find_node().

◆ traverse_arcs() [1/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
bool Aleph::Const_Graph_View< GT >::traverse_arcs ( Node *  p,
Op &&  op 
) const
inline

Visit the arcs of a node while an operation answers true.

Parameters
[in]pa node of the graph.
[in]opcalled as op(a) with a a const Arc *; its result is used as a condition.
Returns
true if every arc of p was visited.

Definition at line 602 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

◆ traverse_arcs() [2/2]

template<class GT >
template<class Op >
requires PredicateWith<Op &, Arc *>
bool Aleph::Const_Graph_View< GT >::traverse_arcs ( Op &&  op) const
inline

Visit the arcs while an operation answers true.

Parameters
[in]opcalled as op(a) with a a const Arc *; its result is used as a condition.
Returns
true if every arc was visited.

Definition at line 586 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

Referenced by Aleph::Const_Graph_View< GT >::all_arcs(), and Aleph::Const_Graph_View< GT >::all_arcs().

◆ traverse_nodes()

template<class GT >
template<class Op >
requires PredicateWith<Op &, Node *>
bool Aleph::Const_Graph_View< GT >::traverse_nodes ( Op &&  op) const
inline

Visit the nodes while an operation answers true.

Parameters
[in]opcalled as op(p) with p a const Node *; its result is used as a condition.
Returns
true if every node was visited.

Definition at line 571 of file tpl_const_graph_view.H.

References Aleph::Const_Iterator< It >::has_curr().

Referenced by Aleph::Const_Graph_View< GT >::all_nodes().

◆ vsize()

template<class GT >
size_t Aleph::Const_Graph_View< GT >::vsize ( ) const
inlinenoexcept

Friends And Related Symbol Documentation

◆ Const_Arc_Iterator< GT >

template<class GT >
friend class Const_Arc_Iterator< GT >
friend

Definition at line 388 of file tpl_const_graph_view.H.

◆ Const_Node_Iterator< GT >

template<class GT >
friend class Const_Node_Iterator< GT >
friend

Definition at line 388 of file tpl_const_graph_view.H.

◆ Filter_Iterator

template<class GT >
template<class , class , class >
friend class Filter_Iterator
friend

Definition at line 393 of file tpl_const_graph_view.H.

Member Data Documentation

◆ filter_iterator_keeps_a_copy

template<class GT >
constexpr bool Aleph::Const_Graph_View< GT >::filter_iterator_keeps_a_copy = true
staticconstexpr

A Filter_Iterator on a view keeps a copy of it: the view is small, and it is often a temporary.

Definition at line 411 of file tpl_const_graph_view.H.

◆ graph_ptr


The documentation for this class was generated from the following file: