31# ifndef ALEPH_TEST_GRAPH_HELPERS_H
32# define ALEPH_TEST_GRAPH_HELPERS_H
35# include <initializer_list>
48 const std::vector<std::pair<size_t, size_t>> & edges)
53 for (
size_t i = 0; i < n; ++i)
56 for (
const auto & [u, v] : edges)
71 const std::initializer_list<std::pair<size_t, size_t>> & edges)
74 g, n, std::vector<std::pair<size_t, size_t>>(edges));
86 for (
size_t i = 0; i < n; ++i)
89 for (
auto it = edges.get_it(); it.has_curr(); it.next_ne())
91 const auto & e = it.get_curr();
92 const size_t u = e.first;
93 const size_t v = e.second;
107 return a->get_info() > 0;
111 template <
class EdgeContainer>
115 if constexpr (
requires(EdgeContainer e,
size_t cap) { e.reserve(cap); })
116 edges.reserve(n > 0 ? n - 1 : 0);
118 for (
size_t v = 1; v < n; ++v)
120 std::uniform_int_distribution<size_t> pick(0, v - 1);
121 auto e = std::make_pair(v, pick(
rng));
122 if constexpr (
requires(EdgeContainer c,
const std::pair<size_t, size_t> & p)
128 edges.emplace_back(e);
WeightedDigraph::Node Node
Simple dynamic array with automatic resizing and functional operations.
static Array create(const size_t n)
Create an array with n logical elements.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Graph_Node< Node_Info > Node
The graph type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
DynArray< Graph::Node * > nodes
Aleph::Array< typename GT::Node * > build_graph_with_unit_arcs(GT &g, const size_t n, const std::vector< std::pair< size_t, size_t > > &edges)
EdgeContainer make_random_tree_edges(const size_t n, std::mt19937 &rng)
bool operator()(Arc *a) const noexcept
Dynamic array container with automatic resizing.