46 for (
int i = 0; i < (int)
V; ++i)
49 for (
int i = 0; i < (int)
V - 1; ++i)
52 for (
int j = i + 1; j < (int)
V; ++j)
63 for (
size_t i = 0; i <
V; ++i)
67 for (
typename GT::Node_Iterator it(g); it.has_curr(); it.next())
69 const auto info = it.get_curr()->get_info();
72 cout <<
"Inconsistencia en el nodo " << info << endl;
78 cout <<
"Nodo duplicado " << info << endl;
86 for (
size_t i = 0; i <
V; ++i)
89 cout <<
"Falta el nodo " << i << endl;
95 cout <<
"Cantidad incorrecta de nodos " <<
count << endl;
99 for (
typename GT::Arc_Iterator it(g); it.has_curr(); it.next())
101 typename GT::Arc * a = it.get_curr();
106 cout <<
"Inconsistencia en el arco " << a->
get_info() << endl;
117 cout <<
"R value ctor test" << endl;
118 GT lg = create_graph <GT> ();
120 cout <<
"done" << endl << endl;
123 cout <<
"L value ctor test" << endl;
126 cout <<
"done" << endl << endl;
130 cout <<
"L value = test" << endl;
134 cout <<
"done" << endl << endl;
137 cout <<
"R value = test" << endl;
138 lg = create_graph <GT> ();
140 cout <<
"done" << endl << endl;
148 for (
int i = beg; i <= end; ++i)
159 for (
auto it =
l.
get_it(); it.has_curr(); it.next())
160 if (it.get_curr() != i++)
162 cout <<
"Inconsistencia en el nodo " << i - 1
163 <<
"(" << it.get_curr() <<
")" << endl;
173 for (
auto it =
l.
get_it(); it.has_curr(); it.next())
174 cout << it.get_curr() <<
" ";
181 cout <<
"R value ctor test" << endl;
182 L
l = create_list <L> ();
184 cout <<
"done" << endl << endl;
187 cout <<
"L value ctor test" << endl;
190 cout <<
"done" << endl << endl;
194 cout <<
"L value = test" << endl;
198 cout <<
"done" << endl << endl;
201 cout <<
"R value = test" << endl;
202 l = create_list <L> ();
204 cout <<
"done" << endl << endl;
207 cout <<
"R value list append test" << endl;
214 cout <<
"R value list insert test" << endl;
221 cout <<
"L value list append test" << endl;
222 L ll = create_list <DynList<>> (2*
V, 3*
V - 1);
229 cout <<
"L value list insert test" << endl;
230 L ll = create_list <DynList<>> (-2*
V-1, -
V - 1);
242 cout <<
"Probando con contenedor tipo arbol" << endl;
244 typedef void (*Print)(
Tree & t);
247 t.for_each([] (
const std::pair<int, int> & p)
249 cout << p.first <<
"," << p.second <<
" ";
253 Tree (*create_tree)(int) = [] (
int n) ->
Tree
256 for (
int i = 0; i < n; ++i)
263 for (
int i = 0; i < (int) n; ++i)
268 Tree t2 = (*create_tree)(n);
270 t2 = (*create_tree)(2*n);
280 cout <<
"Probando diferentes combinaciones de insert\n"
285 int i = n + 1, j = n + 2;
288 cout <<
"\n\nL val R val\n";
292 cout <<
"\n\nR val L val\n";
295 cout <<
"\n\nR val R val\n";
298 cout << endl << endl;
299 (*print)(tt); cout << endl;
302int main(
int argc,
char *argv[])
308 const int tmp = std::stoi(argv[1]);
311 std::cout <<
"V must be positive" << std::endl;
314 V =
static_cast<size_t>(tmp);
316 catch (
const std::exception & e)
318 std::cerr <<
"Error parsing V: " << e.what() << std::endl;
325 cout <<
"V must be positive" << endl;
329 test_map_tree <DynMapBinTree<int,int>> (
V);
333 cout <<
"Testing DynList" << endl;
334 test_list <DynList<>> ();
337 cout <<
"Testing List_Graph" << endl;
338 test <List_Graph<>> ();
341 cout <<
"Testing List_Digraph" << endl;
342 test <List_Digraph<>> ();
345 cout <<
"Testing List_SGraph" << endl;
346 test <List_SGraph<>> ();
349 cout <<
"Testing List_SDigraph" << endl;
350 test <List_SDigraph<>> ();
353 cout <<
"Testing Array_Graph" << endl;
354 test <Array_Graph<>> ();
357 cout <<
"Testing Array_Digraph" << endl;
358 test <Array_Digraph<>> ();
void reserve(const size_t l, const size_t r)
Allocate a range of entries.
Doubly-linked list (defined in tpl_dynList.H).
T & get_first()
Return the first item of the list.
T & append(const T &item)
T & insert(const T &item)
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
QuadTree - Hierarchical spatial index for 2D points.
Point * insert(Node *&r, const Point &p)
Recursive insert helper.
DynArray< Graph::Node * > nodes
@ Tree
Basic arc (in spanning tree).
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
void print(const DynList< Parc< Net > > &sp)
Print a semi-path to stdout.
void test_map_tree(size_t n)
bool check_list(const L &l)
L create_list(int beg=0, int end=V - 1)
void print_list(const L &l)
Array-based graph implementation.
Dynamic key-value map based on balanced binary search trees.