LAL: Linear Arrangement Library 23.01.00
A library focused on algorithms on linear arrangements of graphs.
|
Iterator over the set of pairs of independent edges of a graph. More...
#include <Q_iterator.hpp>
Public Member Functions | |
Q_iterator (const GRAPH &g) noexcept | |
Constructor. More... | |
~Q_iterator ()=default | |
Default destructor. | |
bool | end () const noexcept |
Returns true if the end of the iteration was reached. | |
const edge_pair & | get_edge_pair () const noexcept |
Returns the current edge pair. | |
edge_pair_t | get_edge_pair_t () const noexcept |
Returns the current edge pair. | |
edge_pair | yield_edge_pair () noexcept |
Returns the current edge pair and advances the iterator. | |
void | next () noexcept |
Moves the iterator to the next pair, if there is any. | |
void | reset () noexcept |
Sets the iterator at the beginning of the set of edges. | |
Private Member Functions | |
void | __reset () noexcept |
Sets the iterator at the beginning of the set of edges. | |
edge_pair | make_current_pair () const noexcept |
Returns the current pair of independent edges. More... | |
bool | share_nodes_pointer (const node s, const std::size_t pt, const node u, const std::size_t pv) const noexcept |
Returns whether two edges share vertices or not. More... | |
bool | share_nodes (const node s, const node t, const node u, const node v) const noexcept |
Returns whether two edges share vertices or not. More... | |
template<bool isdir = is_directed, std::enable_if_t< isdir, bool > = true> | |
std::tuple< bool, E_pointer, E_pointer > | find_next_pair (node s, std::size_t pt, node u, std::size_t pv) noexcept |
Find the next pair in a directed graph. | |
template<bool isdir = is_directed, std::enable_if_t< not isdir, bool > = true> | |
std::tuple< bool, E_pointer, E_pointer > | find_next_pair (node s, std::size_t pt, node u, std::size_t pv) noexcept |
Find the next pair in an undirected graph. | |
Private Attributes | |
const GRAPH & | m_G |
Graph we are iterating on. | |
const uint64_t | m_n |
Number of vertices. | |
E_pointer | m_cur1 = E_pointer(0,0) |
Current pointers to the first edge. | |
E_pointer | m_cur2 = E_pointer(0,0) |
Current pointers to the second edge. | |
bool | m_exists_next = true |
Is there a next pair of independent edges? | |
bool | m_reached_end = false |
Has the end of the iteration been reached? | |
edge_pair | m_cur_pair = { {0,0}, {0,0} } |
Current pair of independent edges. | |
Iterator over the set of pairs of independent edges of a graph.
This class is used to easily iterate over the elements of the set \(Q\) of a graph.
This class iterates over the independent pairs of edges of a graph. For undirected graphs, the edges of the pair returned are edges \((u,v)\) so that the inequality \(u < v\) always holds. For directed graphs, this is not always true, since the edges returned always has left-to-right direction.
This class has to be initialised with a constant reference to a graph.
A possible usage of this class is the following:
or, in a more compact way:
Alternatively, the lal::iterators::Q_iterator object can be used in a for loop:
|
inlinenoexcept |
Constructor.
g | Constant reference to the graph over which we iterate. |
|
inlineprivatenoexcept |
|
inlineprivatenoexcept |
Returns whether two edges share vertices or not.
s | First node of the first edge. |
t | Second node of the first edge. |
u | First node of the second edge. |
v | Second node of the second edge. |
|
inlineprivatenoexcept |
Returns whether two edges share vertices or not.
The edges are determined in the following manner. The first edge is determined by node s, and the node pointed by pt. The second edge is determined by node u, and the node pointed by pv.
s | First node of the first edge. |
pt | Pointer to the second node of the first edge. |
u | First node of the second edge. |
pv | Pointer to the second node of the second edge. |