50#include <gtest/gtest.h>
103 auto root = dfs(g, tree);
113 auto n2 = g.insert_node(2);
114 g.insert_arc(n1, n2);
117 auto root = dfs(g, tree);
127 auto n2 = g.insert_node(2);
128 auto n3 = g.insert_node(3);
129 g.insert_arc(n1, n2);
130 g.insert_arc(n2, n3);
131 g.insert_arc(n3, n1);
134 auto root = dfs(g, tree);
144 auto n2 = g.insert_node(2);
145 auto n3 = g.insert_node(3);
146 auto n4 = g.insert_node(4);
147 auto n5 = g.insert_node(5);
149 g.insert_arc(n1, n2);
150 g.insert_arc(n2, n3);
151 g.insert_arc(n3, n4);
152 g.insert_arc(n4, n5);
155 auto root = dfs(g, tree);
167 for (
int i = 0; i <
N; ++i)
171 for (
int i = 0; i <
N; ++i)
172 for (
int j = i + 1; j <
N; ++j)
176 auto root = dfs(g, tree);
186 auto n2 = g.insert_node(2);
187 auto n3 = g.insert_node(3);
188 g.insert_arc(n1, n2);
189 g.insert_arc(n2, n3);
192 auto tree_node = dfs(g, n2, tree);
212 EXPECT_THROW(dfs(g,
nullptr, tree), std::invalid_argument);
218 auto n2 = g.insert_node(20);
219 auto n3 = g.insert_node(30);
220 g.insert_arc(n1, n2);
221 g.insert_arc(n2, n3);
250 auto root = bfs(g, tree);
260 auto n2 = g.insert_node(2);
261 g.insert_arc(n1, n2);
264 auto root = bfs(g, tree);
274 auto n2 = g.insert_node(2);
275 auto n3 = g.insert_node(3);
276 g.insert_arc(n1, n2);
277 g.insert_arc(n2, n3);
278 g.insert_arc(n3, n1);
281 auto root = bfs(g, tree);
293 for (
int i = 0; i <
N; ++i)
296 for (
int i = 0; i <
N; ++i)
297 for (
int j = i + 1; j <
N; ++j)
301 auto root = bfs(g, tree);
311 auto n2 = g.insert_node(2);
312 auto n3 = g.insert_node(3);
313 g.insert_arc(n1, n2);
314 g.insert_arc(n2, n3);
336 EXPECT_THROW(bfs(g,
nullptr, tree), std::invalid_argument);
342 auto n2 = g.insert_node(20);
343 auto n3 = g.insert_node(30);
344 g.insert_arc(n1, n2);
345 g.insert_arc(n2, n3);
372 for (
int i = 0; i <
N; ++i)
376 for (
int i = 0; i <
N - 1; ++i)
380 for (
int i = 0; i <
N - 10; i += 10)
384 auto root = dfs(g, tree);
396 for (
int i = 0; i <
N; ++i)
399 for (
int i = 0; i <
N - 1; ++i)
402 for (
int i = 0; i <
N - 10; i += 10)
406 auto root = bfs(g, tree);
417template <
typename GraphType>
437template <
typename GraphType>
457 Graph & tree = this->tree;
462 auto root = dfs(g, tree);
473 Graph & tree = this->tree;
483 auto root = dfs(g, tree);
494 Graph & tree = this->tree;
505 Graph & tree = this->tree;
511 EXPECT_THROW(dfs(g,
nullptr, tree), std::invalid_argument);
518 Graph & tree = this->tree;
523 auto root = bfs(g, tree);
534 Graph & tree = this->tree;
544 auto root = bfs(g, tree);
555 Graph & tree = this->tree;
566 Graph & tree = this->tree;
572 EXPECT_THROW(bfs(g,
nullptr, tree), std::invalid_argument);
579 Graph & tree = this->tree;
593 auto root = dfs(g, tree);
604 Graph & tree = this->tree;
618 auto root = bfs(g, tree);
628 ::testing::InitGoogleTest(&
argc,
argv);
Generic directed graph (digraph) wrapper template.
T & append()
Allocate a new entry to the end of array.
Compute a breadth-first spanning tree of a graph.
Compute a depth-first spanning tree of a graph.
Arc for graphs implemented with simple adjacency lists.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Graph class implemented with singly-linked adjacency lists.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
constexpr size_t get_num_arcs() const noexcept
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
::testing::Types< ListGraph, SparseGraph, ArrayGraph > UndirectedGraphTypes
DynArray< Graph::Node * > nodes
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.
Array-based graph implementation.
::testing::Types< ListGraph, ListDigraph, SparseGraph, SparseDigraph, ArrayGraph, ArrayDigraph > GraphTypes
Generic graph and digraph implementations.
Simple graph implementation with adjacency lists.
Spanning tree generation algorithms.
List_Digraph< Graph_Node< int >, Graph_Arc< int > > ListDigraph
TEST_F(DFSSpanningTreeTest, SingleNode)
TYPED_TEST(SpanningTreeAllGraphs, DFSSingleNode)
List_Graph< Graph_Node< int >, Graph_Arc< int > > ListGraph
Array_Graph< Graph_Anode< int >, Graph_Aarc< int > > ArrayGraph
TYPED_TEST_SUITE(SpanningTreeAllGraphs, GraphTypes)
List_SDigraph< Graph_Snode< int >, Graph_Sarc< int > > SparseDigraph
List_SGraph< Graph_Snode< int >, Graph_Sarc< int > > SparseGraph