1 # ifndef EUCLIDIAN_GRAPH_COMMON_H
2 # define EUCLIDIAN_GRAPH_COMMON_H
4 # include <tpl_sgraph.H>
6 # include <random_graph.H>
15 extern gsl_rng * rand_gen ;
24 Init_P(
unsigned long w,
unsigned long h)
30 void operator () (GT &,
typename GT::Node * p)
35 x = gsl_rng_uniform_int(rand_gen, H);
36 y = gsl_rng_uniform_int(rand_gen, W);
37 std::pair<int,int> q(x, y);
38 if (puntos.search(q) != NULL)
45 My_P & my_p = p->get_info();
56 Init_Arc(
int max) : max_offset(max) { }
58 void operator () (GT & g,
typename GT::Arc * a)
60 typename GT::Node * src = g.get_src_node(a);
61 typename GT::Node * tgt = g.get_tgt_node(a);
63 My_P & psrc = src->get_info();
64 My_P & ptgt = tgt->get_info();
66 float dist = hypot(psrc.x - ptgt.x, psrc.y - ptgt.y);
68 int offset = gsl_rng_uniform_int(rand_gen, max_offset);
70 a->get_info() = dist + offset;
77 void operator () (ostream & output, GT &,
typename GT::Node * p)
79 output << p->get_info().x <<
" " << p->get_info().y << endl;
86 void operator () (istream & input, GT &,
typename GT::Node * p)
88 input >> p->get_info().x;
89 input >> p->get_info().y;
96 void operator () (ostream & output, GT &,
typename GT::Arc * a)
98 output << a->get_info() << endl;
105 void operator () (istream & input, GT &,
typename GT::Arc * a)
107 input >> a->get_info();
112 template <
class GT>
inline
113 GT gen_random_euclidian_graph(
size_t n,
size_t m,
int w,
int h,
116 rand_gen = gsl_rng_alloc (gsl_rng_mt19937);
117 gsl_rng_set(rand_gen, seed % gsl_rng_max(rand_gen));
123 (seed, initp, initarc) (n, m);
125 gsl_rng_free(rand_gen);
134 # endif // EUCLIDIAN_GRAPH_COMMON_H
Definition: euclidian-graph-common.H:18
Definition: euclidian-graph-common.H:94
Definition: tpl_dynSetTree.H:1126
Definition: euclidian-graph-common.H:103
Definition: euclidian-graph-common.H:84
Definition: euclidian-graph-common.H:75
Definition: random_graph.H:321
Definition: euclidian-graph-common.H:52
Definition: euclidian-graph-common.H:10