13#include <gtest/gtest.h>
39 for (
auto it = tree.get_arc_it(); it.has_curr(); it.next_ne())
40 total += it.get_current_arc_ne()->get_info();
48 if (tree.get_num_nodes() == 0)
50 if (tree.get_num_nodes() == 1)
54 if (tree.get_num_arcs() != tree.get_num_nodes() - 1)
59 auto first = tree.get_first_node();
71 auto tgt = it.get_tgt_node_ne();
81 return visited == tree.get_num_nodes();
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)
Append a new item by copy.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
constexpr bool is_empty() const noexcept
Return true if list is empty.
Computes the minimum spanning tree of a graph using Kruskal's algorithm.
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.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
constexpr size_t get_num_arcs() const noexcept
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.
DynList< T > maps(const C &c, Op op)
Classic map operation.
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.