LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
|
Iterator over the set of edges of a graph. More...
#include <E_iterator.hpp>
Public Member Functions | |
E_iterator (const graph_t &g) noexcept | |
Constructor. | |
~E_iterator ()=default | |
Default destructor. | |
bool | end () const noexcept |
Returns true if the end of the iteration was reached. | |
const edge & | get_edge () const noexcept |
Returns the current edge. | |
edge_t | get_edge_t () const noexcept |
Returns the current edge. | |
edge | yield_edge () noexcept |
Returns the current edge and advances the iterator. | |
edge_t | yield_edge_t () noexcept |
Returns the current edge and advances the iterator. | |
void | next () noexcept |
Moves the iterator to the next edge. | |
void | reset () noexcept |
Sets the iterator at the beginning of the set of edges. | |
Private Types | |
typedef std::pair< node, std::size_t > | E_pointer |
Useful typedef. | |
Private Member Functions | |
void | __reset () noexcept |
Sets the iterator at the beginning of the set of edges. | |
edge | make_current_edge () const noexcept |
Returns the edge pointed by m_cur. | |
template<bool isdir = is_directed, std::enable_if_t< isdir, bool > = true> | |
std::pair< bool, E_pointer > | find_next_edge () const noexcept |
Finds the next edge on a directed graph. | |
template<bool isdir = is_directed, std::enable_if_t< not isdir, bool > = true> | |
std::pair< bool, E_pointer > | find_next_edge () const noexcept |
Finds the next edge on an undirected graph. | |
Private Attributes | |
const graph_t & | m_G |
The graph whose edges have to be iterated on. | |
const uint64_t | m_num_nodes |
Number of nodes of the graph. | |
E_pointer | m_cur |
Pointer to the next edge. | |
bool | m_exists_next |
Is there a next edge to iterate over? | |
bool | m_reached_end |
Has the end of the iteration been reached? | |
edge | m_cur_edge |
Copy of the current edge. | |
Iterator over the set of edges of a graph.
This class is used to easily iterate over the edges of a graph \(E\). For undirected graphs, the edge returned is an edge \((u,v)\) so that the inequality \(u < v\) always holds. For directed graphs, the edge returned always has left-to-right orientation, therefore said inequality need not always hold.
This class has to be initialized 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::E_iterator object can be used in a for loop:
|
inlinenoexcept |
Constructor.
g | Constant reference to the graph over which we iterate. |
|
inlinenodiscardprivatenoexcept |
Finds the next edge on a directed graph.
|
inlinenodiscardprivatenoexcept |
Finds the next edge on an undirected graph.