13#include <gtest/gtest.h>
39 for (
auto it = tree.
get_arc_it(); it.has_curr(); it.next_ne())
71 auto tgt = it.get_tgt_node_ne();
213 std::mt19937
rng(42);
214 std::uniform_int_distribution<int>
weight_dist(1, 100);
218 std::vector<Node *>
nodes;
220 for (
int i = 0; i <
N; ++i)
224 for (
int i = 1; i <
N; ++i)
228 for (
int i = 0; i <
N * 2; ++i)
308 for (
int i = 1; i <= 5; ++i)
330 std::mt19937
rng(12345);
331 std::uniform_int_distribution<int>
weight_dist(1, 1000);
335 std::vector<Node *>
nodes;
337 for (
int i = 0; i <
N; ++i)
341 for (
int i = 1; i <
N; ++i)
345 for (
int i = 0; i <
N * 3; ++i)
371 std::mt19937
rng(54321);
372 std::uniform_int_distribution<int>
weight_dist(1, 100);
376 std::vector<Node *>
nodes;
378 for (
int i = 0; i <
N; ++i)
382 for (
int i = 0; i <
N; ++i)
383 for (
int j = i + 1; j <
N; ++j)
421 for (
auto it = g.
get_node_it(); it.has_curr(); it.next_ne())
423 auto gnode = it.get_curr();
Kruskal's minimum spanning tree algorithm.
Prim's algorithm for minimum spanning trees.
WeightedDigraph::Node Node
Dynamic singly linked list with functional programming support.
T & append(const T &item)
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
constexpr bool is_empty() const noexcept
Computes the minimum spanning tree of a graph using Kruskal's algorithm.
Node * get_first_node() const
Return any node in the graph.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Graph_Node< int > Node
The graph type.
Graph_Arc< int > Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Calcula el árbol abarcador mínimo de un grafo según el algoritmo de Prim.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
auto get_arc_it() const noexcept
Obtains an iterator to the arc of graph.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
constexpr size_t get_num_arcs() const noexcept
void reset_nodes() const
Reset all the nodes of graph (the control bits, the state, the counter and the cookie)
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
DynArray< Graph::Node * > nodes
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
#define NODE_BITS(p)
Get the control bits of a node.
Main namespace for Aleph-w library functions.
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.
Arc of graph implemented with double-linked adjacency lists.
Filtered iterator of adjacent arcs of a node.
Generic graph and digraph implementations.
Utility algorithms and operations for graphs.