LAL: Linear Arrangement Library 23.01.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lal::iterators::Q_iterator< GRAPH, is_directed, > Class Template Reference

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_pairget_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.
 

Detailed Description

template<typename GRAPH, bool is_directed = std::is_base_of_v<graphs::directed_graph, GRAPH>, std::enable_if_t< std::is_base_of_v< graphs::directed_graph, GRAPH >||std::is_base_of_v< graphs::undirected_graph, GRAPH >, bool > = true>
class lal::iterators::Q_iterator< GRAPH, is_directed, >

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:

Q_iterator it(g); // g is a graph
while (not it.end()) {
const auto [e1,e2] = it.get_edge_pair();
// ...
it.next();
}
Iterator over the set of pairs of independent edges of a graph.
Definition: Q_iterator.hpp:107

or, in a more compact way:

Q_iterator it(g); // g is a graph
while (not it.end()) {
const auto [e1,e2] = it.yield_edge_pair();
// ...
}

Alternatively, the lal::iterators::Q_iterator object can be used in a for loop:

for (Q_iterator it(g); not it.end(); it.next()) {
const auto [e1,e2] = it.get_edge_pair();
// ...
}
bool end() const noexcept
Returns true if the end of the iteration was reached.
Definition: Q_iterator.hpp:125

Constructor & Destructor Documentation

◆ Q_iterator()

template<typename GRAPH , bool is_directed = std::is_base_of_v<graphs::directed_graph, GRAPH>, std::enable_if_t< std::is_base_of_v< graphs::directed_graph, GRAPH >||std::is_base_of_v< graphs::undirected_graph, GRAPH >, bool > = true>
lal::iterators::Q_iterator< GRAPH, is_directed, >::Q_iterator ( const GRAPH &  g)
inlinenoexcept

Constructor.

Parameters
gConstant reference to the graph over which we iterate.

Member Function Documentation

◆ make_current_pair()

template<typename GRAPH , bool is_directed = std::is_base_of_v<graphs::directed_graph, GRAPH>, std::enable_if_t< std::is_base_of_v< graphs::directed_graph, GRAPH >||std::is_base_of_v< graphs::undirected_graph, GRAPH >, bool > = true>
edge_pair lal::iterators::Q_iterator< GRAPH, is_directed, >::make_current_pair ( ) const
inlineprivatenoexcept

Returns the current pair of independent edges.

These are the edges pointed by attribute m_cur1 and by attribute m_cur2.

◆ share_nodes()

template<typename GRAPH , bool is_directed = std::is_base_of_v<graphs::directed_graph, GRAPH>, std::enable_if_t< std::is_base_of_v< graphs::directed_graph, GRAPH >||std::is_base_of_v< graphs::undirected_graph, GRAPH >, bool > = true>
bool lal::iterators::Q_iterator< GRAPH, is_directed, >::share_nodes ( const node  s,
const node  t,
const node  u,
const node  v 
) const
inlineprivatenoexcept

Returns whether two edges share vertices or not.

Parameters
sFirst node of the first edge.
tSecond node of the first edge.
uFirst node of the second edge.
vSecond node of the second edge.
Returns
Whether or not the edges share nodes.

◆ share_nodes_pointer()

template<typename GRAPH , bool is_directed = std::is_base_of_v<graphs::directed_graph, GRAPH>, std::enable_if_t< std::is_base_of_v< graphs::directed_graph, GRAPH >||std::is_base_of_v< graphs::undirected_graph, GRAPH >, bool > = true>
bool lal::iterators::Q_iterator< GRAPH, is_directed, >::share_nodes_pointer ( const node  s,
const std::size_t  pt,
const node  u,
const std::size_t  pv 
) const
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.

Parameters
sFirst node of the first edge.
ptPointer to the second node of the first edge.
uFirst node of the second edge.
pvPointer to the second node of the second edge.
Returns
Whether or not the edges share nodes.

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