49#include <lal/graphs/directed_graph.hpp>
50#include <lal/graphs/undirected_graph.hpp>
86 bool is_directed = std::is_base_of_v<graphs::directed_graph, GRAPH>,
88 std::is_base_of_v<graphs::directed_graph, GRAPH> ||
89 std::is_base_of_v<graphs::undirected_graph, GRAPH>
137 typedef std::pair<node,std::size_t> E_pointer;
158 m_cur.second =
static_cast<std::size_t
>(-1);
178 if (
m_G.get_num_edges() == 1) {
193 if constexpr (is_directed) {
195 t =
m_G.get_out_neighbours(s)[
m_cur.second];
199 t =
m_G.get_neighbours(s)[
m_cur.second];
210 template<
bool isdir = is_directed, std::enable_if_t<isdir,
bool> = true>
212 const uint32_t n =
m_G.get_num_nodes();
215 std::size_t pt =
m_cur.second;
219 if (s < n and pt <
m_G.get_out_degree(s)) {
225 while (s < n and
m_G.get_out_degree(s) == 0) { ++s; }
228 return make_pair(found, E_pointer(s, pt));
236 template<
bool isdir = is_directed, std::enable_if_t<not isdir,
bool> = true>
238 const uint32_t n =
m_G.get_num_nodes();
241 std::size_t pt =
m_cur.second + 1;
244 while (s < n and not found) {
245 const auto& Ns =
m_G.get_neighbours(s);
246 while (pt < Ns.size() and s > Ns[pt]) { ++pt; }
248 found = pt < Ns.size();
254 return make_pair(found, E_pointer(s, pt));
Iterator over the set of edges of a graph.
Definition E_iterator.hpp:93
void __reset() noexcept
Sets the iterator at the beginning of the set of edges.
Definition E_iterator.hpp:153
E_pointer m_cur
Pointer to the next edge.
Definition E_iterator.hpp:143
void reset() noexcept
Sets the iterator at the beginning of the set of edges.
Definition E_iterator.hpp:131
void next() noexcept
Moves the iterator to the next edge.
Definition E_iterator.hpp:118
edge m_cur_edge
Copy of the current edge.
Definition E_iterator.hpp:149
std::pair< bool, E_pointer > find_next_edge() const noexcept
Finds the next edge on a directed graph.
Definition E_iterator.hpp:211
bool m_exists_next
Is there a next edge to iterate over?
Definition E_iterator.hpp:145
edge make_current_edge() const noexcept
Returns the edge pointed by m_cur.
Definition E_iterator.hpp:191
edge get_edge() const noexcept
Returns the current edge.
Definition E_iterator.hpp:113
const GRAPH & m_G
The graph whose edges have to be iterated on.
Definition E_iterator.hpp:141
E_iterator(const GRAPH &g) noexcept
Constructor.
Definition E_iterator.hpp:101
~E_iterator()=default
Default destructor.
bool end() const noexcept
Returns true if the end of the iteration was reached.
Definition E_iterator.hpp:110
bool m_reached_end
Has the end of the iteration been reached?
Definition E_iterator.hpp:147
Main namespace of the library.
Definition definitions.hpp:48
std::pair< node, node > edge
Edge type.
Definition definitions.hpp:75
uint32_t node
Node type.
Definition definitions.hpp:51