38#include <gtest/gtest.h>
80 std::vector<std::pair<int, int>> pos;
81 pos.reserve(g.vsize());
85 auto * n = it.get_curr();
86 const auto & p = n->get_info();
87 pos.emplace_back(p.x, p.y);
90 std::sort(pos.begin(), pos.end());
96 std::vector<ArcSnapshot>
arcs;
97 arcs.reserve(g.esize());
101 auto * a = it.get_curr();
102 auto * s = g.get_src_node(a);
103 auto * t = g.get_tgt_node(a);
104 const auto &
ps = s->get_info();
105 const auto &
pt = t->get_info();
108 int x2 =
pt.x, y2 =
pt.y;
109 if (std::tie(x2, y2) < std::tie(x1,
y1))
110 std::swap(x1, x2), std::swap(
y1, y2);
112 arcs.push_back({x1,
y1, x2, y2, a->get_info()});
115 std::sort(
arcs.begin(),
arcs.end());
128 constexpr int w = 40;
129 constexpr int h = 30;
136 EXPECT_EQ(std::unique(pos.begin(), pos.end()), pos.end());
139 for (
const auto & [x,
y] : pos)
150 constexpr int w = 60;
151 constexpr int h = 80;
154 const int max_offset = std::max(1,
int(std::ceil(std::hypot(
double(
w),
double(
h)))));
158 auto * a = it.get_curr();
159 auto * s = g.get_src_node(a);
160 auto * t = g.get_tgt_node(a);
161 const auto &
ps = s->get_info();
162 const auto &
pt = t->get_info();
164 const double dist = std::hypot(
double(
ps.x -
pt.x),
double(
ps.y -
pt.y));
165 const double wgt = a->get_info();
177 constexpr int w = 50;
178 constexpr int h = 50;
179 constexpr unsigned seed = 42u;
188 EXPECT_EQ(
g1.vsize(),
g2.vsize()) <<
"Node count should match";
189 EXPECT_EQ(
g1.esize(),
g2.esize()) <<
"Arc count should match";
196 for (
const auto & a1 :
arcs1)
197 for (
const auto & a2 :
arcs2)
198 if (a1.x1 == a2.x1 && a1.y1 == a2.y1 &&
199 a1.x2 == a2.x2 && a1.y2 == a2.y2 &&
200 std::abs(a1.w - a2.w) < 1e-9)
214 ::testing::InitGoogleTest(&
argc,
argv);
bool operator<(const Time &l, const Time &r)
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
Arc for graphs implemented with simple adjacency lists.
size_t size() const noexcept
Count the number of elements of the list.
Graph class implemented with singly-linked adjacency lists.
Filtered iterator on the nodes of a graph.
Common utilities for Euclidean graphs.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y1_function > > y1(const __gmp_expr< T, U > &expr)
DynArray< Graph::Arc * > arcs
Main namespace for Aleph-w library functions.
bool operator==(const DynList< T > &l1, const DynList< T > &l2)
Equality operator for DynList.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Filtered iterator on all the arcs of a graph.
Generic graph and digraph implementations.
Simple graph implementation with adjacency lists.