43# ifndef EUCLIDIAN_GRAPH_COMMON_H
44# define EUCLIDIAN_GRAPH_COMMON_H
50# include <gsl/gsl_rng.h>
89 <<
"Init_P(): width and height must be > 0";
99 std::pair<int, int> q(x,
y);
128 const double dist = std::hypot(
static_cast<double>(
psrc.x -
ptgt.x),
129 static_cast<double>(
psrc.y -
ptgt.y));
181 <<
"gen_random_euclidian_graph(): width and height must be > 0";
183 const auto max_unique =
static_cast<size_t>(
w) *
static_cast<size_t>(
h);
185 <<
"gen_random_euclidian_graph(): requested n exceeds available unique grid points";
192 const int max_offset = std::max(1,
193 static_cast<int>(std::ceil(std::hypot(
static_cast<double>(
w),
194 static_cast<double>(
h)))));
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
#define ah_bad_alloc_if(C)
Throws std::bad_alloc if condition holds.
Dynamic set implemented using AVL binary search trees of type Avl_Tree<Key>.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
Key * search(const Key &key) const
Find an element in the set.
Random undirected graph generator.
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)
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_max_function > > max(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
const long double offset[]
Offset values indexed by symbol string length (bounded by MAX_OFFSET_INDEX)
Graph serialization and deserialization utilities.
Main namespace for Aleph-w library functions.
gsl_rng * rand_gen
Internal RNG handle used by the helper functors in this header.
GT gen_random_euclidian_graph(size_t n, size_t m, int w, int h, unsigned int seed)
DynList< T > maps(const C &c, Op op)
Classic map operation.
Random graph generation utilities.
Arc of graph implemented with double-linked adjacency lists.
void operator()(GT &g, typename GT::Arc *a)
Init_P(const long w, const long h)
Create a node initializer that assigns unique random positions.
void operator()(GT &, typename GT::Node *p)
DynSetAvlTree< std::pair< int, int > > puntos
Simple integer point used as node payload by the helper functors in this header.
void operator()(std::istream &input, GT &, typename GT::Arc *a)
void operator()(std::istream &input, GT &, typename GT::Node *p)
void operator()(std::ostream &output, GT &, typename GT::Arc *a)
void operator()(std::ostream &output, GT &, typename GT::Node *p)
Simple graph implementation with adjacency lists.