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>
157 auto [found, new_cur1, new_cur2] =
174 typedef std::pair<node,std::size_t> E_pointer;
199 if (
m_G.get_num_edges() <= 1) {
207 m_cur2.second = std::numeric_limits<std::size_t>::max();
209 const auto [found, new_cur1, new_cur2] =
224 new_cur1.first, new_cur1.second,
225 new_cur2.first, new_cur2.second));
235 const auto [f2, _, __] =
261 if constexpr (is_directed) {
262 t =
m_G.get_out_neighbours(s)[
m_cur1.second];
263 v =
m_G.get_out_neighbours(u)[
m_cur2.second];
266 t =
m_G.get_neighbours(s)[
m_cur1.second];
267 v =
m_G.get_neighbours(u)[
m_cur2.second];
269 return {{s,t}, {u,v}};
285 const node s,
const std::size_t pt,
286 const node u,
const std::size_t pv
291 if constexpr (is_directed) {
292 t =
m_G.get_out_neighbours(s)[pt];
293 v =
m_G.get_out_neighbours(u)[pv];
296 t =
m_G.get_neighbours(s)[pt];
297 v =
m_G.get_neighbours(u)[pv];
312 {
return s == u or s == v or t == u or t == v; }
315 template <
bool isdir = is_directed, std::enable_if_t<isdir,
bool> = true>
316 std::tuple<bool, E_pointer, E_pointer>
322 return {
false, {s,pt}, {u,pv}};
325 if (pt >=
m_G.get_out_degree(s)) {
334 if (pv >=
m_G.get_out_degree(u)) {
343 return {
true, {s,pt}, {u,pv}};
347 template <
bool isdir = is_directed, std::enable_if_t<not isdir,
bool> = true>
348 std::tuple<bool, E_pointer, E_pointer>
354 return {
false, {s,pt}, {u,pv}};
357 if (pt >=
m_G.get_degree(s)) {
366 if (pv >=
m_G.get_degree(u)) {
371 const auto& Ns =
m_G.get_neighbours(s);
376 const auto& Nu =
m_G.get_neighbours(u);
381 return {
true, {s,pt}, {u,pv}};
Iterator over the set of pairs of independent edges of a graph.
Definition: Q_iterator.hpp:107
E_pointer m_cur2
Current pointers to the second edge.
Definition: Q_iterator.hpp:186
bool end() const noexcept
Returns true if the end of the iteration was reached.
Definition: Q_iterator.hpp:125
void __reset() noexcept
Sets the iterator at the beginning of the set of edges.
Definition: Q_iterator.hpp:197
void next() noexcept
Moves the iterator to the next pair, if there is any.
Definition: Q_iterator.hpp:143
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:284
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:310
E_pointer m_cur1
Current pointers to the first edge.
Definition: Q_iterator.hpp:184
const edge_pair & get_edge_pair() const noexcept
Returns the current edge pair.
Definition: Q_iterator.hpp:128
~Q_iterator()=default
Default destructor.
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.
Definition: Q_iterator.hpp:317
const uint64_t m_n
Number of vertices.
Definition: Q_iterator.hpp:181
const GRAPH & m_G
Graph we are iterating on.
Definition: Q_iterator.hpp:179
bool m_reached_end
Has the end of the iteration been reached?
Definition: Q_iterator.hpp:191
bool m_exists_next
Is there a next pair of independent edges?
Definition: Q_iterator.hpp:189
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:193
edge_pair make_current_pair() const noexcept
Returns the current pair of independent edges.
Definition: Q_iterator.hpp:257
edge_pair yield_edge_pair() noexcept
Returns the current edge pair and advances the iterator.
Definition: Q_iterator.hpp:134
edge_pair_t get_edge_pair_t() const noexcept
Returns the current edge pair.
Definition: Q_iterator.hpp:131
void reset() noexcept
Sets the iterator at the beginning of the set of edges.
Definition: Q_iterator.hpp:168
Main namespace of the library.
Definition: basic_types.hpp:50
std::pair< edge, edge > edge_pair
Edge pair type.
Definition: basic_types.hpp:60
std::pair< edge_t, edge_t > edge_pair_t
Similar to edge_pair.
Definition: basic_types.hpp:165
uint64_t node
Node type. See Node / Vertex page for further details.
Definition: basic_types.hpp:53