38#include <gtest/gtest.h>
58 std::vector<TestGraph::Node *>
nodes;
66 for (
int i = 0; i < 5; ++i)
81 std::vector<TestGraph::Node *>
nodes;
88 for (
int i = 0; i < 5; ++i)
101 std::vector<TestGraph::Node *>
nodes;
113 for (
int i = 0; i < 7; ++i)
129 std::vector<TestGraph::Node *>
nodes;
137 for (
int i = 0; i < 4; ++i)
151 std::vector<TestDigraph::Node *>
nodes;
160 for (
int i = 0; i < 4; ++i)
161 nodes.push_back(
g.insert_node(i));
189 for (
int i = 0; i < 5; ++i)
265 std::set<int>
level1 = {1, 2, 3};
266 std::set<int>
level2 = {4, 5, 6};
269 for (
int i = 1; i <= 3; ++i)
273 for (
int i = 4; i <= 6; ++i)
386 std::vector<std::pair<int, bool>>
visits;
462 return node_count < 2;
557 size_t count = dfs(node, op);
577 size_t count = bfs(node, op);
592 return static_cast<int>(arc->
get_info()) % 2 == 0;
625 std::vector<TestGraph::Node *>
nodes;
628 for (
int i = 0; i < 5; ++i)
631 for (
int i = 0; i < 4; ++i)
652 std::vector<TestGraph::Node *>
nodes;
654 for (
int i = 0; i < 5; ++i)
657 for (
int i = 0; i < 4; ++i)
673 for (
int i = 0; i < 5; ++i)
684 std::vector<TestGraph::Node *>
nodes;
687 for (
int i = 0; i < 4; ++i)
690 for (
int i = 0; i < 4; ++i)
691 for (
int j = i + 1; j < 4; ++j)
716 std::vector<TestGraph::Node *>
nodes;
721 for (
int i = 0; i <
N; ++i)
724 for (
int i = 0; i <
N - 1; ++i)
736 size_t result = dfs(
nodes[0], op);
745 std::vector<TestGraph::Node *>
nodes;
750 for (
int i = 0; i <
N; ++i)
753 for (
int i = 1; i <
N; ++i)
765 size_t result = bfs(
nodes[0], op);
777 ::testing::InitGoogleTest(&
argc,
argv);
Generic directed graph (digraph) wrapper template.
typename BaseGraph::Node Node
T & insert(const T &item)
Insert a new item by copy.
size_t size() const noexcept
Count the number of elements of the list.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
std::vector< TestGraph::Node * > nodes
std::vector< TestDigraph::Node * > nodes
std::vector< TestGraph::Node * > nodes
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.
std::vector< TestGraph::Node * > nodes
Traverse a graph depth-first or breadth-first and execute a visit function.
size_t exec(typename GT::Node *start, Op &op)
Execute operation op(curr, arc) where curr is the visited node and arc is the incoming arc.
Tree graph for graph_to_tree conversion testing.
std::vector< TestGraph::Node * > nodes
Graph traversal algorithms (DFS, BFS).
TEST_F(GraphTraverseTest, DFSVisitsAllNodes)
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Default filter for filtered iterators on arcs.
Arc of graph implemented with double-linked adjacency lists.
Filtered iterator of adjacent arcs of a node.
bool operator()(typename GT::Arc *arc) const
Generic graph and digraph implementations.