32#include <gtest/gtest.h>
38TEST(GridTest, BasicCreation) {
53TEST(GridTest, InvalidDimensions) {
57 EXPECT_THROW(build(g, 1, 10), std::length_error);
58 EXPECT_THROW(build(g, 10, 1), std::length_error);
60 EXPECT_NO_THROW(build(g, 2, 2));
64TEST(GridTest, CustomOperations) {
68 void operator()(
decltype(g)& ,
decltype(g)
::Node* n,
size_t row,
size_t col) {
74 void operator()(
decltype(g)& ,
decltype(g)
::Arc* a,
size_t ,
size_t ) {
85 for (
auto it = g.
get_node_it(); it.has_curr(); it.next()) {
86 sum_info += it.get_curr()->get_info();
93 EXPECT_EQ(sum_info, 909);
96 for (
auto it = g.
get_arc_it(); it.has_curr(); it.next()) {
97 arc_sum += it.get_curr()->get_info();
106 EXPECT_EQ(arc_sum, 20);
WeightedDigraph::Node Node
Functor to build a 2D grid graph with 8-connectivity.
Graph implemented with double-linked adjacency lists.
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
auto get_arc_it() const noexcept
Obtains an iterator to the arc of graph.
constexpr size_t get_num_arcs() const noexcept
Return the number of arcs of the graph.
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
2D grid graph generation with 8-connectivity.
Main namespace for Aleph-w library functions.
Arc of graph implemented with double-linked adjacency lists.
Generic graph and digraph implementations.