53#include <lal/graphs/directed_graph.hpp>
54#include <lal/graphs/undirected_graph.hpp>
100 bool is_directed = std::is_base_of_v<graphs::directed_graph, GRAPH>,
102 std::is_base_of_v<graphs::directed_graph, GRAPH> ||
103 std::is_base_of_v<graphs::undirected_graph, GRAPH>
160 auto [found, new_cur1, new_cur2] =
177 typedef std::pair<node,std::size_t> E_pointer;
205 if (
m_G.get_num_edges() <= 1) {
213 m_cur2.second = std::numeric_limits<std::size_t>::max();
215 const auto [found, new_cur1, new_cur2] =
230 new_cur1.first, new_cur1.second,
231 new_cur2.first, new_cur2.second));
241 const auto [f2, _, __] =
267 if constexpr (is_directed) {
268 t =
m_G.get_out_neighbors(s)[
m_cur1.second];
269 v =
m_G.get_out_neighbors(u)[
m_cur2.second];
275 return {{s,t}, {u,v}};
292 const node s,
const std::size_t pt,
293 const node u,
const std::size_t pv
298 if constexpr (is_directed) {
299 t =
m_G.get_out_neighbors(s)[pt];
300 v =
m_G.get_out_neighbors(u)[pv];
303 t =
m_G.get_neighbors(s)[pt];
304 v =
m_G.get_neighbors(u)[pv];
323 return s == u or s == v or t == u or t == v;
327 template <
bool isdir = is_directed, std::enable_if_t<isdir,
bool> = true>
328 [[nodiscard]] std::tuple<bool, E_pointer, E_pointer>
330 const node s,
const std::size_t pt,
331 const node u,
const std::size_t pv
337 return {
false, {s,pt}, {u,pv}};
340 if (pt >=
m_G.get_out_degree(s)) {
349 if (pv >=
m_G.get_out_degree(u)) {
358 return {
true, {s,pt}, {u,pv}};
362 template <
bool isdir = is_directed, std::enable_if_t<not isdir,
bool> = true>
363 [[nodiscard]] std::tuple<bool, E_pointer, E_pointer>
365 const node s,
const std::size_t pt,
366 const node u,
const std::size_t pv
372 return {
false, {s,pt}, {u,pv}};
375 if (pt >=
m_G.get_degree(s)) {
384 if (pv >=
m_G.get_degree(u)) {
389 const auto& Ns =
m_G.get_neighbors(s);
394 const auto& Nu =
m_G.get_neighbors(u);
399 return {
true, {s,pt}, {u,pv}};
Iterator over the set of pairs of independent edges of a graph.
Definition Q_iterator.hpp:107
std::tuple< bool, E_pointer, E_pointer > find_next_pair(const node s, const std::size_t pt, const node u, const std::size_t pv) noexcept
Find the next pair in a directed graph.
Definition Q_iterator.hpp:329
E_pointer m_cur2
Current pointers to the second edge.
Definition Q_iterator.hpp:189
bool end() const noexcept
Returns true if the end of the iteration was reached.
Definition Q_iterator.hpp:128
void __reset() noexcept
Sets the iterator at the beginning of the set of edges.
Definition Q_iterator.hpp:200
void next() noexcept
Moves the iterator to the next pair, if there is any.
Definition Q_iterator.hpp:146
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.
Definition Q_iterator.hpp:291
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.
Definition Q_iterator.hpp:317
E_pointer m_cur1
Current pointers to the first edge.
Definition Q_iterator.hpp:187
const edge_pair & get_edge_pair() const noexcept
Returns the current edge pair.
Definition Q_iterator.hpp:131
~Q_iterator()=default
Default destructor.
const uint64_t m_n
Number of vertices.
Definition Q_iterator.hpp:184
const GRAPH & m_G
Graph we are iterating on.
Definition Q_iterator.hpp:182
bool m_reached_end
Has the end of the iteration been reached?
Definition Q_iterator.hpp:194
bool m_exists_next
Is there a next pair of independent edges?
Definition Q_iterator.hpp:192
Q_iterator(const GRAPH &g) noexcept
Constructor.
Definition Q_iterator.hpp:115
edge_pair m_cur_pair
Current pair of independent edges.
Definition Q_iterator.hpp:196
edge_pair make_current_pair() const noexcept
Returns the current pair of independent edges.
Definition Q_iterator.hpp:263
edge_pair yield_edge_pair() noexcept
Returns the current edge pair and advances the iterator.
Definition Q_iterator.hpp:137
edge_pair_t get_edge_pair_t() const noexcept
Returns the current edge pair.
Definition Q_iterator.hpp:134
void reset() noexcept
Sets the iterator at the beginning of the set of edges.
Definition Q_iterator.hpp:171
Main namespace of the library.
Definition basic_types.hpp:48
std::pair< edge, edge > edge_pair
Edge pair type.
Definition basic_types.hpp:62
std::pair< edge_t, edge_t > edge_pair_t
Similar to edge_pair.
Definition basic_types.hpp:241
uint64_t node
Node type. See Node / Vertex page for further details.
Definition basic_types.hpp:51