LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
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.
 
 ~Q_iterator ()=default
 Default destructor.
 
bool end () const noexcept
 Returns true if the end of the iteration was reached.
 
edge_pair get_edge_pair () const noexcept
 Returns the current edge pair.
 
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.
 
bool share_nodes (const E_pointer &p1, const E_pointer &p2) const noexcept
 Returns whether the edges share vertices or not.
 
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.
 

Static Private Member Functions

static bool share_nodes (const edge_pair &st_uv) noexcept
 Returns whether the edges share vertices or not.
 

Private Attributes

const GRAPH & m_G
 Graph we are iterating on.
 
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:98

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:116

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.


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