1 #ifndef __MINLCA_UTILS_GENERATORS_GEOMETRIC_HH
2 #define __MINLCA_UTILS_GENERATORS_GEOMETRIC_HH
4 #include <lemon/smart_graph.h>
5 #include <lemon/random.h>
20 template<
typename BaseGraph = lemon::SmartGraph>
28 TEMPLATE_GRAPH_TYPEDEFS(Graph);
31 typedef typename Graph::template NodeMap<lemon::dim2::Point<double>> Coords;
40 template<
typename Number =
int>
42 : Base(
seed), _coords(*this)
49 : Base(r), _coords(*this)
68 this->reserveNode(_n);
70 for (
int i = 0; i <
_n; ++i) {
71 Node v = this->addNode();
72 _coords[v] =
_r->disc();
75 for (
int i = 0; i <
_n; ++i) {
76 Node u = this->nodeFromId(i);
78 for (
int j = i + 1; j <
_n; ++j) {
79 Node v = this->nodeFromId(j);
81 if ((_coords[v] - _coords[u]).normSquare() < _rad_sq) {
91 lemon::dim2::Point<double>
coord(
int _n
Number of vertices.
lemon::dim2::Point< double > coord(const Node &v) const
Retrieve coordinates for a vertex.
RandomGeometric(lemon::Random &r)
Constructor with custom random number generator.
virtual void generate()
Generate graph.
Class defining random geometric graphs.
lemon::Random * _r
Random number generator.
void seed(Number seed)
Change the random number generator seed.
Contains base definitions for defining particular random graphs.
Default namespace Default namespace for MinLCA algorithms.
Graph & init(int n, double radSq)
Initialise the generator.
RandomGeometric(Number seed=0)
Constructor with seed.
Coords _coords
Coordinates of the vertices.
double _rad_sq
Square of the radius.
const Coords & coords() const
Retrieve all the coordinates.
Base class for random graph generators.