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 (
typename Aleph::Array<std::pair<size_t, size_t>>::Iterator it(edges);
90 it.has_curr(); it.next_ne())
92 const auto & e = it.get_curr();
93 const size_t u = e.first;
94 const size_t v = e.second;
108 return a->get_info() > 0;
112 template <
class EdgeContainer>
116 if constexpr (
requires(
EdgeContainer e,
size_t cap) { e.reserve(cap); })
117 edges.reserve(n > 0 ? n - 1 : 0);
119 for (
size_t v = 1; v < n; ++v)
121 std::uniform_int_distribution<size_t> pick(0, v - 1);
122 auto e = std::make_pair(v, pick(
rng));
123 if constexpr (
requires(
EdgeContainer c,
const std::pair<size_t, size_t> & p)
129 edges.emplace_back(e);
WeightedDigraph::Node Node
Simple dynamic array with automatic resizing and functional operations.
static Array create(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)
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
bool operator()(Arc *a) const noexcept
Dynamic array container with automatic resizing.