13#include <gtest/gtest.h>
44 for (
auto it = g.
get_arc_it(); it.has_curr(); it.next_ne())
55 for (
auto it = tree.
get_arc_it(); it.has_curr(); it.next_ne())
65 for (
auto it = g.
get_arc_it(); it.has_curr(); it.next_ne())
67 auto arc = it.get_current_arc_ne();
69 total += arc->get_info();
78 using Distance_Type =
int;
79 static const Distance_Type Zero_Distance = 0;
80 static const Distance_Type Max_Distance = std::numeric_limits<int>::max();
83 Scaled_Dist() =
default;
84 explicit Scaled_Dist(
int f) : factor(f) {}
86 int operator()(
typename G::Arc *a)
const noexcept
88 return a->get_info() * factor;
133 auto tgt = it.get_tgt_node_ne();
213 std::vector<Node*>
nodes;
266 std::vector<Node*>
leaves;
290 std::vector<std::vector<Node*>>
grid(3, std::vector<Node*>(3));
294 for (
int i = 0; i < 3; ++i)
295 for (
int j = 0; j < 3; ++j)
299 for (
int i = 0; i < 3; ++i)
300 for (
int j = 0; j < 2; ++j)
304 for (
int i = 0; i < 2; ++i)
305 for (
int j = 0; j < 3; ++j)
484 std::vector<Node*>
nodes;
554 std::vector<Node*>
nodes;
592 for (
typename GT::Node_Iterator it(tree); it.has_curr(); it.next_ne())
606 std::vector<Node*>
nodes;
612 std::mt19937
rng(12345);
664 for (
typename GT::Node_Iterator it(tree); it.has_curr(); it.next_ne())
689 for (
typename GT::Arc_Iterator it(tree); it.has_curr(); it.next_ne())
702 auto n0 = dg.insert_node(0);
703 auto n1 = dg.insert_node(1);
704 dg.insert_arc(n0, n1, 1);
772 Node* n1 =
g1.insert_node(1);
773 g1.insert_arc(n0, n1, 5);
798 std::vector<Node*>
nodes;
808 std::mt19937
rng(99999);
810 std::uniform_int_distribution<int>
wdist(1, 1000);
961 ::testing::InitGoogleTest(&
argc,
argv);
Kruskal's minimum spanning tree algorithm.
WeightedDigraph::Node Node
virtual Node * insert_node(Node *p)
Arc * insert_arc(Node *src, Node *tgt, void *a)
Generic directed graph (digraph) wrapper template.
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)
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
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)
DynArray< Graph::Node * > nodes
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
#define IS_ARC_VISITED(p, bit)
Determine whether the bit field is or not set 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.
bool operator()(typename GT::Arc *a) const
Array-based graph implementation.
Generic graph and digraph implementations.
Simple graph implementation with adjacency lists.