|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Filtered iterator for incoming arcs of a node. More...
#include <tpl_graph.H>
Public Types | |
| using | Item_Type = typename GT::Arc * |
Public Types inherited from Aleph::Digraph_Iterator< GT, __In_Filt< GT > > | |
| using | Item_Type = typename Itor::Item_Type |
| using | Iterator_Type = Itor |
| The type of element. | |
Public Member Functions | |
| In_Iterator ()=default | |
| In_Iterator (typename GT::Node *p, SA sa=SA()) | |
Iterator on the arcs of the list of p whose target is p and that sa shows. | |
| In_Iterator (const GT &g, typename GT::Node *p, SA sa=SA()) | |
Iterator on the arcs of g into p that sa shows; on a graph of an undirected type, those of the list of p. | |
| void | next () |
| void | next_ne () noexcept(NothrowPredicateWith< SA &, typename GT::Arc * >) |
| next() without the check of the current arc; noexcept when the filter is, else what the filter throws goes out | |
| void | prev () |
| Move to the previous arc that the filter shows. | |
Public Member Functions inherited from Aleph::Digraph_Iterator< GT, __In_Filt< GT > > | |
| Digraph_Iterator (typename GT::Node *p) | |
Initialize an iterator on adjacent arcs (incoming or outcoming) of p | |
| void | next () |
| Move the iterator one position forward. | |
| void | next_ne () noexcept(shows_ne) |
| next() without its check: the current arc must exist. | |
| void | prev () |
| Move the iterator one position backward. | |
| bool | has_curr () const noexcept |
Return true the iterator has an current arc. | |
| GT::Arc * | get_curr () const |
| Return the current arc. | |
| GT::Arc * | get_curr_ne () const noexcept |
| Return the current arc. | |
| auto | get_current_arc () const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Alias for get_curr(). | |
| GT::Node * | get_node (typename GT::Arc *a) const noexcept |
Return the connected node to arc. | |
| GT::Node * | get_node () const |
| Return the connected node to current arc. | |
| auto | get_tgt_node () const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Alias for get_node(). | |
| GT::Node * | get_node_ne () const noexcept |
| Return the connected node to current arc. | |
| auto | get_tgt_node_ne () const noexcept |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Alias for get_node_ne(). | |
| void | reset_first () noexcept(shows_ne) |
| Reset the iterator to the first arc. | |
| void | reset_last () noexcept(shows_ne) |
| Reset the iterator to the last arc. | |
| void | end () noexcept(shows_ne) |
| Put the iterator in end state. | |
Private Types | |
| using | Base = Digraph_Iterator< GT, __In_Filt< GT > > |
Private Member Functions | |
| void | goto_first_valid () |
| void | goto_last_valid () |
Static Private Member Functions | |
| static void | refuse_a_digraph () |
| static GT::Node * | of_lists (const GT &g, typename GT::Node *p) |
Private Attributes | |
| SA | show_arc |
Additional Inherited Members | |
Static Public Attributes inherited from Aleph::Digraph_Iterator< GT, __In_Filt< GT > > | |
| static constexpr bool | goes_back |
| Iterator type. | |
| static constexpr bool | goes_to_last |
| Whether the iterator goes to its last arc, which reset_last() and end() need. | |
| static constexpr bool | shows_ne |
| Whether what the filter says of an arc cannot throw, nor its conversion to bool: the moves without checks and the resets are noexcept then. | |
Filtered iterator for incoming arcs of a node.
This iterator traverses the incoming arcs of a node, those whose target is the node, optionally filtered by the Show_Arc predicate.
A digraph keeps each arc only in the list of its source, while a graph that is not directed keeps it in the lists of both ends, so that the iterator has two forms:
In_Iterator(g, p, sa) takes the graph. On a digraph type (DigraphType) it walks the arcs of g and keeps those whose target is p and that sa shows, in the order of the arc iterator of g: to build it and go through all of them takes \(O(E)\). On a graph that is not directed it walks the list of p, as the other form; it throws domain_error on a graph of an undirected type that says that it is directed (see set_digraph()), whose arcs into p are not in the list of p.In_Iterator(p, sa) walks the list of p. It does not compile on a digraph type, whose list of p holds only the arcs that leave p. It cannot tell a graph of an undirected type that says that it is directed, on which it sees only the loops of p.The functions on the arcs into a node that take the graph, as in_arcs(g, p) and in_degree(g, p), tell a digraph at run time, also of an undirected type. To go through the arcs into many nodes of a digraph, build an In_Arcs_Index once, in \(O(V + E)\).
prev() and reset_last() exist only where the iterators of the graph move back: not on List_SGraph and List_SDigraph.
| GT | The graph type |
| SA | Arc filter predicate (default shows all arcs) |
Definition at line 2044 of file tpl_graph.H.
|
private |
Definition at line 2046 of file tpl_graph.H.
| using Aleph::In_Iterator< GT, SA >::Item_Type = typename GT::Arc * |
Definition at line 2082 of file tpl_graph.H.
|
default |
|
inline |
Iterator on the arcs of the list of p whose target is p and that sa shows.
The list holds the arcs into p only in a graph that is not directed: on a digraph type it does not compile.
| [in] | p | the node. |
| [in] | sa | the arc filter. |
Definition at line 2093 of file tpl_graph.H.
References Aleph::In_Iterator< GT, SA >::goto_first_valid().
|
inline |
Iterator on the arcs of g into p that sa shows; on a graph of an undirected type, those of the list of p.
It is inlined, as the form that takes only the node is, so that it costs on a graph that is not directed only the test of g.is_digraph().
| [in] | g | the graph of p. |
| [in] | p | the node. |
| [in] | sa | the arc filter. |
| domain_error | if g says that it is directed. |
Definition at line 2111 of file tpl_graph.H.
|
inlineprivate |
Definition at line 2049 of file tpl_graph.H.
References Aleph::and, Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::get_curr_ne(), Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::has_curr(), Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::next_ne(), and Aleph::In_Iterator< GT, SA >::show_arc.
Referenced by Aleph::In_Iterator< GT, SA >::In_Iterator(), Aleph::In_Iterator< GT, SA >::next(), and Aleph::In_Iterator< GT, SA >::next_ne().
|
inlineprivate |
Definition at line 2055 of file tpl_graph.H.
References Aleph::and, Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::get_curr_ne(), Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::has_curr(), Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::prev(), and Aleph::In_Iterator< GT, SA >::show_arc.
Referenced by Aleph::In_Iterator< GT, SA >::prev().
|
inline |
Definition at line 2117 of file tpl_graph.H.
References Aleph::In_Iterator< GT, SA >::goto_first_valid(), and Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::next().
|
inlinenoexcept |
next() without the check of the current arc; noexcept when the filter is, else what the filter throws goes out
Definition at line 2125 of file tpl_graph.H.
References Aleph::In_Iterator< GT, SA >::goto_first_valid(), and Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::next_ne().
|
inlinestaticprivate |
Definition at line 2074 of file tpl_graph.H.
References GraphCommon< GT, Node, Arc >::is_digraph(), and Aleph::In_Iterator< GT, SA >::refuse_a_digraph().
|
inline |
Move to the previous arc that the filter shows.
Only where the iterator moves back: not on List_SGraph
Definition at line 2133 of file tpl_graph.H.
References Aleph::In_Iterator< GT, SA >::goto_last_valid(), and Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::prev().
|
inlinestaticprivate |
Definition at line 2064 of file tpl_graph.H.
References ah_domain_error.
Referenced by Aleph::In_Iterator< GT, SA >::of_lists().
|
private |
Definition at line 2047 of file tpl_graph.H.
Referenced by Aleph::In_Iterator< GT, SA >::goto_first_valid(), and Aleph::In_Iterator< GT, SA >::goto_last_valid().