Graph C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Groups Pages
hms_directed_graph.hpp
Go to the documentation of this file.
1 
14 #ifndef HMS_DIRECTED_GRAPH_HPP_INCLUDED
15 #define HMS_DIRECTED_GRAPH_HPP_INCLUDED
16 
17 // Standard Library
18 #include <ctime> // time(), gmtime()
19 #include <cmath>
20 #include <cstdlib> // abort()
21 #include <fstream>
22 #include <iostream>
23 #include <map>
24 #include <random>
25 #include <set>
26 #include <string>
27 #include <vector>
28 // Graph C++ Library
29 #include "base_directed_graph.hpp"
30 #include "hms_directed_vertex.hpp"
32 
34 namespace gcl
35 {
36 
46  class hms_directed_graph : public gcl::base_directed_graph<gcl::hms_directed_vertex>
47  {
48  // ============================================================================================
49  // *** Objects related to the graph.
50  private:
51  // Numbers of hidden variables (in this case 2)
52  const unsigned int nb_hidden_variables;
53  // ============================================================================================
54  // *** Information about the graph.
55  private:
56  std::string geometry;
57  double nb_dimensions;
58  double vertices_density;
59  // std::vector<double> target_avg_hidden_variables; ///< Target values of the average value of hidden variables of vertices.
60  std::vector<std::string> pdf_hidden_variables_type;
61  std::vector< std::vector<double> > pdf_hidden_variables_param;
62  std::string prob_connection_type;
63  std::vector<double> prob_connection_param;
64  std::vector<double> min_hidden_variables;
65  std::vector<double> max_hidden_variables;
66  std::vector<double> avg_hidden_variables;
67  // ============================================================================================
68  // *** Random number generators.
69  std::uniform_real_distribution<double> uniform_01;
70  // ============================================================================================
71  // *** Other parameters
72  const double Pi = 3.1415926535897932384626433832795; // Pi
73  // ============================================================================================
74  // *** Member functions.
75  private:
77  double compute_distance_in_metric_space(std::vector<double> x1, std::vector<double> x2);
78  public:
84  double get_nb_dimensions();
86  void set_metric_space_positions(unsigned int _nb_vertices, std::string _geometry, double _delta, std::mt19937& _engine);
88  // void set_hidden_variables(std::string _pdf_hidden_variables_0_type, std::vector<double> _pdf_hidden_variables_0_param, std::string _pdf_hidden_variables_1_type, std::vector<double> _pdf_hidden_variables_1_param, std::mt19937& _engine);
89  void set_hidden_variables(std::vector<std::vector<double> > _sequence_hidden_variables);
90  // /// Sets the parameter associated to the average degree ("mu").
91  // void set_probability_of_connection(std::string _prob_connection_type, std::vector<double> _prob_connection_param);
93  void create_edges(std::string _prob_connection_type, std::vector<double> _prob_connection_param, std::mt19937& _engine);
97  void write_graph_properties(std::string _name);
99  void write_vertices_properties(std::string _name);
101  void clear();
102  };
103 
104 } // End of namespace gcl.
105 
106 
107 
108 // ================================================================================================
109 // ================================================================================================
111 : nb_hidden_variables(2) //, base_directed_graph()
112 {
113  clear();
114 }
115 
116 // ================================================================================================
117 // ================================================================================================
119 {
120  return nb_dimensions;
121 }
122 
123 // ================================================================================================
124 // ================================================================================================
125 void gcl::hms_directed_graph::set_metric_space_positions(unsigned int _nb_vertices, std::string _geometry, double _vertices_density, std::mt19937& _engine)
126 {
127  // Sets the number of vertices.
128  this->set_nb_vertices(_nb_vertices);
129  // Assigns the name of the vertices.
130  for(unsigned int n(0), nn(this->get_nb_vertices()); n<nn ; ++n)
131  {
132  (*this)(n)->set_name(std::to_string(n));
133  }
134  // Sets the geometry.
135  geometry = _geometry;
136  // Sets the density of vertices in the metric space.
137  vertices_density = _vertices_density;
138  // Randomly assigns position of vertices in the metric space.
139  if( geometry == "S1" )
140  {
141  // Computes the radius of the circle.
142  double radius = this->get_nb_vertices() / (2.0 * Pi * vertices_density);
143  // Sets the number of dimensions of the metric space.
144  nb_dimensions = 1;
145  // Assigns the positions in the metric space.
146  double phi;
147  for(unsigned int n(0), nn(this->get_nb_vertices()); n<nn ; ++n)
148  {
149  phi = 2 * Pi * uniform_01(_engine);
150  (*this)(n)->set_metric_space_position({radius,phi});
151  }
152  }
153  else
154  {
155  std::cout << "The geometry " << geometry << " is not supported." << std::endl;
156  abort();
157  }
158 
159 }
160 
161 // // ================================================================================================
162 // // ================================================================================================
163 // void gcl::hms_directed_graph::set_hidden_variables(std::string _pdf_hidden_variables_0_type, std::vector<double> _pdf_hidden_variables_0_param, std::string _pdf_hidden_variables_1_type, std::vector<double> _pdf_hidden_variables_1_param, std::mt19937& _engine)
164 // {
165 // // Updates the information about the graph.
166 // pdf_hidden_variables_type[0] = _pdf_hidden_variables_0_type;
167 // pdf_hidden_variables_param[0] = _pdf_hidden_variables_0_param;
168 // pdf_hidden_variables_type[1] = _pdf_hidden_variables_1_type;
169 // pdf_hidden_variables_param[1] = _pdf_hidden_variables_1_param;
170 // // // Resizes and sets the initial values of min_hidden_variables, max_hidden_variables and avg_hidden_variables.
171 // // min_hidden_variables.clear();
172 // // min_hidden_variables.resize(nb_hidden_variables,this->get_nb_vertices());
173 // // max_hidden_variables.clear();
174 // // max_hidden_variables.resize(nb_hidden_variables,0);
175 // // avg_hidden_variables.clear();
176 // // avg_hidden_variables.resize(nb_hidden_variables,0);
177 // // Sets the hidden variable of each node.
178 // unsigned int hv_type;
179 // double value;
180 // std::vector<double> hv(nb_hidden_variables);
181 // for(unsigned int n(0), nn(this->get_nb_vertices()); n<nn; ++n)
182 // {
183 // // Hidden variable associated to the in-degree.
184 // hv_type = 0;
185 // if( pdf_hidden_variables_type[hv_type] == "pdf_powerlaw_hardcutoff" )
186 // {
187 // hv[hv_type] = rng::powerlaw_hardcutoff_rand(pdf_hidden_variables_param[hv_type], _engine);
188 // }
189 // else
190 // {
191 // std::cout << "This type of distribution " << pdf_hidden_variables_type[hv_type] << " is not supported." << std::endl;
192 // abort();
193 // }
194 
195 // // Hidden variable associated to the out-degree.
196 // hv_type = 1;
197 // if( pdf_hidden_variables_type[hv_type] == "pdf_powerlaw_hardcutoff" )
198 // {
199 // hv[hv_type] = rng::powerlaw_hardcutoff_rand(pdf_hidden_variables_param[hv_type], _engine);
200 // }
201 // else if( pdf_hidden_variables_type[hv_type] == "out_equal_in" )
202 // {
203 // hv[hv_type] = hv[0];
204 // }
205 // else
206 // {
207 // std::cout << "This type of distribution " << pdf_hidden_variables_type[hv_type] << " is not supported." << std::endl;
208 // abort();
209 // }
210 
211 // // // Analyses the hidden variables.
212 // // for(unsigned int t(0); t<nb_hidden_variables; ++t)
213 // // {
214 // // // Maximal and minimal values.
215 // // if(hv[t] < min_hidden_variables[t])
216 // // min_hidden_variables[t] = hv[t];
217 // // if(hv[t] > max_hidden_variables[t])
218 // // max_hidden_variables[t] = hv[t];
219 // // // Average value (1 of 2).
220 // // avg_hidden_variables[t] += hv[t];
221 // // }
222 
223 // // Sets the values of the hidden variables.
224 // (*this)(n)->set_hidden_variables(hv);
225 // }
226 
227 // // Sets the target for the average value of hidden variables of vertices.
228 // hv_type = 0;
229 // if( pdf_hidden_variables_type[hv_type] == "pdf_powerlaw_hardcutoff" )
230 // target_avg_hidden_variables[hv_type] = rng::powerlaw_hardcutoff_m1(pdf_hidden_variables_param[hv_type]);
231 // hv_type = 1;
232 // if( pdf_hidden_variables_type[hv_type] == "pdf_powerlaw_hardcutoff" )
233 // target_avg_hidden_variables[hv_type] = rng::powerlaw_hardcutoff_m1(pdf_hidden_variables_param[hv_type]);
234 // if( pdf_hidden_variables_type[hv_type] == "out_equal_in" )
235 // target_avg_hidden_variables[hv_type] = target_avg_hidden_variables[0];
236 
237 // if(std::fabs(target_avg_hidden_variables[0]-target_avg_hidden_variables[1]) > 1e-5)
238 // {
239 // std::cout << "Warning, the target average values of the two hidden variables differ by more than 1e-5." << std::endl;
240 // }
241 
242 // // Analyses the hidden variables.
243 // survey_hidden_variables();
244 
245 // // // Average values of the hidden variables (2 of 2).
246 // // for(unsigned int t(0); t<nb_hidden_variables; ++t)
247 // // {
248 // // avg_hidden_variables[t] /= this->get_nb_vertices();
249 // // }
250 // }
251 
252 
253 // ================================================================================================
254 // ================================================================================================
255 void gcl::hms_directed_graph::set_hidden_variables(std::vector<std::vector<double> > _sequence_hidden_variables)
256 {
257  // Verification.
258  if( _sequence_hidden_variables.size() != this->get_nb_vertices() )
259  {
260  std::cout << "The length of the sequence of hidden variables is not equal to the number of vertices." << std::endl;
261  abort();
262  }
263  // Updates the information about the graph.
264  pdf_hidden_variables_type[0] = "pdf_custom_sequence";
265  pdf_hidden_variables_param[0] = {};
266  pdf_hidden_variables_type[1] = "pdf_custom_sequence";
267  pdf_hidden_variables_param[1] = {};
268  // Sets the hidden variable of each node.
269  for(unsigned int n(0), nn(this->get_nb_vertices()); n<nn; ++n)
270  {
271  // Sets the values of the hidden variables.
272  (*this)(n)->set_hidden_variables(_sequence_hidden_variables[n]);
273  }
274  // Analyses the hidden variables.
275  survey_hidden_variables();
276 }
277 
278 // // ================================================================================================
279 // // ================================================================================================
280 // void gcl::hms_directed_graph::set_probability_of_connection(std::string _prob_connection_type, std::vector<double> _prob_connection_param)
281 // {
282 // // Updates the information about the graph.
283 // prob_connection_type = _prob_connection_type;
284 // prob_connection_param = _prob_connection_param;
285 // // Computes the parameter associated to the average degree ("mu").
286 // if( prob_connection_type == "prob_fermi-dirac" )
287 // {
288 // if( prob_connection_param[0] > nb_dimensions )
289 // {
290 // double I_1 = (Pi/prob_connection_param[0]) / std::sin(nb_dimensions * Pi / prob_connection_param[0]);
291 // double mu = ( std::tgamma(nb_dimensions/2.) ) / ( 2 * std::pow(Pi,nb_dimensions/2.) * vertices_density * target_avg_hidden_variables[0] * I_1 );
292 // prob_connection_param.push_back(mu);
293 // }
294 // else
295 // {
296 // std::cout << "The type of connection probability " << prob_connection_type << " is not supported for beta < D." << std::endl;
297 // abort();
298 // }
299 // }
300 // else
301 // {
302 // std::cout << "This type of connection probability " << prob_connection_type << " is not supported." << std::endl;
303 // abort();
304 // }
305 // }
306 
307 // ================================================================================================
308 // ================================================================================================
309 double gcl::hms_directed_graph::compute_distance_in_metric_space(std::vector<double> x1, std::vector<double> x2)
310 {
311  if( geometry == "S1" )
312  {
313  if(std::fabs(x1[0]-x2[0]) < 1e-8)
314  {
315  return x1[0] * ( Pi - std::fabs( Pi - std::fabs( x1[1] - x2[1] ) ) );
316  }
317  else
318  {
319  std::cout << "The two points do not lie on the same circle." << std::endl;
320  abort();
321  }
322  }
323  else
324  {
325  std::cout << "The geometry " << geometry << " is not supported." << std::endl;
326  abort();
327  }
328 }
329 
330 // ================================================================================================
331 // ================================================================================================
333 {
334  // Resizes and sets the initial values of min_hidden_variables, max_hidden_variables and avg_hidden_variables.
335  min_hidden_variables.clear();
336  min_hidden_variables.resize(nb_hidden_variables,this->get_nb_vertices());
337  max_hidden_variables.clear();
338  max_hidden_variables.resize(nb_hidden_variables,0);
339  avg_hidden_variables.clear();
340  avg_hidden_variables.resize(nb_hidden_variables,0);
341 
342  // Loops over every vertices of the graph.
343  std::vector<double> tmp_hidden_variables;
344  for(unsigned int v(0), vv(this->get_nb_vertices()); v<vv; ++v)
345  {
346  tmp_hidden_variables = (*this)(v)->get_hidden_variables();
347  // Analyses the hidden variables.
348  for(unsigned int t(0); t<nb_hidden_variables; ++t)
349  {
350  // Maximal and minimal values.
351  if(tmp_hidden_variables[t] < min_hidden_variables[t])
352  {
353  min_hidden_variables[t] = tmp_hidden_variables[t];
354  }
355  if(tmp_hidden_variables[t] > max_hidden_variables[t])
356  {
357  max_hidden_variables[t] = tmp_hidden_variables[t];
358  }
359  // Average value (1 of 2).
360  avg_hidden_variables[t] += tmp_hidden_variables[t];
361  }
362  }
363  // Average values of the hidden variables (2 of 2).
364  for(unsigned int t(0); t<nb_hidden_variables; ++t)
365  {
366  avg_hidden_variables[t] /= this->get_nb_vertices();
367  }
368 }
369 
370 // ================================================================================================
371 // ================================================================================================
372 void gcl::hms_directed_graph::create_edges(std::string _prob_connection_type, std::vector<double> _prob_connection_param, std::mt19937& _engine)
373 {
374  // Updates the information about the graph.
375  prob_connection_type = _prob_connection_type;
376  prob_connection_param = _prob_connection_param;
377  // Temporary variables.
378  unsigned int tmp_nb_edges(0);
379  double tmp_dist, tmp_chi, tmp_r;
380  std::vector<double> x1, x2, k1, k2;
381 
382  for(unsigned int n1(0), nn(this->get_nb_vertices()); n1<nn ; ++n1)
383  {
384  // Gets the position of the first vertex.
385  x1 = (*this)(n1)->get_metric_space_position();
386  // Gets the hidden variables of the first vertex.
387  k1 = (*this)(n1)->get_hidden_variables();
388 
389  for(unsigned int n2(n1+1); n2<nn; ++n2)
390  {
391  // Gets the position of the first vertex.
392  x2 = (*this)(n2)->get_metric_space_position();
393  // Gets the hidden variables of the first vertex.
394  k2 = (*this)(n2)->get_hidden_variables();
395  // Computes the distance in the metric space between the two vertices.
396  tmp_dist = compute_distance_in_metric_space(x1,x2);
397 
398  // Computes the rescaled distance for the n1 -> n2 edge.
399  tmp_chi = tmp_dist / std::pow(prob_connection_param.back() * k1[id_out_degree] * k2[id_in_degree],1./nb_dimensions);
400  // Computes the probability of connection.
401  if( prob_connection_type == "prob_fermi-dirac" )
402  tmp_r = 1. / (std::pow(tmp_chi,prob_connection_param[0]) + 1);
403  // Creates the edge, if any.
404  if( uniform_01(_engine) < tmp_r )
405  {
406  (*this)(n1)->out_neighbour_insert(gcl::simple_edge(n2));
407  (*this)(n2)->in_neighbour_insert(gcl::simple_edge(n1));
408  ++tmp_nb_edges;
409  }
410 
411  // Computes the rescaled distance for the n2 -> n1 edge.
412  tmp_chi = tmp_dist / std::pow(prob_connection_param.back() * k1[id_in_degree] * k2[id_out_degree],1./nb_dimensions);
413  // Computes the probability of connection.
414  if( prob_connection_type == "prob_fermi-dirac" )
415  tmp_r = 1. / (std::pow(tmp_chi,prob_connection_param[0]) + 1);
416  // Creates the edge, if any.
417  if( uniform_01(_engine) < tmp_r )
418  {
419  (*this)(n2)->out_neighbour_insert(gcl::simple_edge(n1));
420  (*this)(n1)->in_neighbour_insert(gcl::simple_edge(n2));
421  ++tmp_nb_edges;
422  }
423  }
424  }
425  // Sets the number of edges.
426  this->set_nb_edges(tmp_nb_edges);
427  // Analyzes the degrees.
428  this->survey_degrees_distribution();
429 }
430 
431 // ================================================================================================
432 // ================================================================================================
434 {
435  // Streams objects.
436  std::ofstream graph_properties_file;
437  // String objects.
438  std::string graph_properties_filename = _name + "_graph_properties.dat";
439  // Opens the stream and aborts if the operation did not succeed.
440  graph_properties_file.open(graph_properties_filename.c_str(), std::ios_base::out);
441  if( !graph_properties_file.is_open() )
442  {
443  std::cout << "Could not open file: " << _name << "." << std::endl;
444  abort();
445  }
446  // Gets the current date/time.
447  time_t theTime = time(NULL);
448  struct tm *aTime = gmtime(&theTime);
449  int year = aTime->tm_year + 1900;
450  int month = aTime->tm_mon + 1;
451  int day = aTime->tm_mday;
452  int hours = aTime->tm_hour;
453  int minutes = aTime->tm_min;
454  // Writes the properties of the graph.
455  graph_properties_file << "===================================================================================" << std::endl;
456  graph_properties_file << "General information " << std::endl;
457  graph_properties_file << "Type of graph: " << this->get_type_of_graph() << std::endl;
458  graph_properties_file << "Name: " << _name << std::endl;
459  graph_properties_file << "Computed on: " << year << "/";
460  if(month < 10)
461  graph_properties_file << "0";
462  graph_properties_file << month << "/";
463  if(day < 10)
464  graph_properties_file << "0";
465  graph_properties_file << day << " " << hours << ":";
466  if(minutes < 10)
467  graph_properties_file << "0";
468  graph_properties_file << minutes << " UTC" << std::endl;
469  graph_properties_file << "===================================================================================" << std::endl;
470  graph_properties_file << "Parameters" << std::endl;
471  graph_properties_file << "Geometry: " << geometry << std::endl;
472  graph_properties_file << "Number of nodes: " << this->get_nb_vertices() << std::endl;
473  graph_properties_file << "Vertices density: " << vertices_density << std::endl;
474  // if(pdf_hidden_variables_type[0] == "pdf_powerlaw_hardcutoff")
475  // {
476  // graph_properties_file << "PDF hidden variable for in-degrees: power law with hard cut-off" << std::endl;
477  // graph_properties_file << " - exponent: " << pdf_hidden_variables_param[0][0] << std::endl;
478  // graph_properties_file << " - minimum: " << pdf_hidden_variables_param[0][1] << std::endl;
479  // graph_properties_file << " - maximum: " << pdf_hidden_variables_param[0][2] << std::endl;
480  // graph_properties_file << " - average: " << target_avg_hidden_variables[0] << std::endl;
481  // }
482  // if(pdf_hidden_variables_type[1] == "pdf_powerlaw_hardcutoff")
483  // {
484  // graph_properties_file << "PDF hidden variable for out-degrees: power law with hard cut-off" << std::endl;
485  // graph_properties_file << " - exponent: " << pdf_hidden_variables_param[1][0] << std::endl;
486  // graph_properties_file << " - minimum: " << pdf_hidden_variables_param[1][1] << std::endl;
487  // graph_properties_file << " - maximum: " << pdf_hidden_variables_param[1][2] << std::endl;
488  // graph_properties_file << " - average: " << target_avg_hidden_variables[1] << std::endl;
489  // }
490  // if(pdf_hidden_variables_type[1] == "out_equal_in")
491  // {
492  // graph_properties_file << "PDF hidden variable for out-degrees: maximal correlation with in-degree" << std::endl;
493  // }
494  // if(pdf_hidden_variables_type[0] == "pdf_custom_sequence")
495  // {
496  // graph_properties_file << "PDF hidden variable for in-degrees: custom sequence" << std::endl;
497  // }
498  // if(pdf_hidden_variables_type[1] == "pdf_custom_sequence")
499  // {
500  // graph_properties_file << "PDF hidden variable for in-degrees: custom sequence" << std::endl;
501  // }
502  if(prob_connection_type == "prob_fermi-dirac")
503  {
504  graph_properties_file << "Prob. of connection: fermi-dirac" << std::endl;
505  graph_properties_file << " - beta: " << prob_connection_param[0] << std::endl;
506  graph_properties_file << " - mu: " << prob_connection_param[1] << std::endl;
507  }
508  graph_properties_file << "===================================================================================" << std::endl;
509  graph_properties_file << "Hidden variables (including zero-degree vertices)" << std::endl;
510  graph_properties_file << "Related to the in-degree" << std::endl;
511  graph_properties_file << " - minimum: " << min_hidden_variables[id_in_degree] << std::endl;
512  graph_properties_file << " - maximum: " << max_hidden_variables[id_in_degree] << std::endl;
513  graph_properties_file << " - average: " << avg_hidden_variables[id_in_degree] << std::endl;
514  graph_properties_file << "Related to the out-degree" << std::endl;
515  graph_properties_file << " - minimum: " << min_hidden_variables[id_out_degree] << std::endl;
516  graph_properties_file << " - maximum: " << max_hidden_variables[id_out_degree] << std::endl;
517  graph_properties_file << " - average: " << avg_hidden_variables[id_out_degree] << std::endl;
518  graph_properties_file << "===================================================================================" << std::endl;
519  graph_properties_file << "Observables (excluding zero-degree vertices)" << std::endl;
520  graph_properties_file << "Number of nodes: " << this->get_nb_vertices()-this->get_nb_zerodegree_vertices() << std::endl;
521  graph_properties_file << "Number of edges: " << this->get_nb_edges() << std::endl;
522  graph_properties_file << " - reciprocals: " << this->get_nb_reciprocal_edges() << std::endl;
523  graph_properties_file << "In-degree" << std::endl;
524  graph_properties_file << " - minimum (excluding zero): " << this->get_min_in_degree() << std::endl;
525  graph_properties_file << " - maximum: " << this->get_max_in_degree() << std::endl;
526  graph_properties_file << " - average: " << this->get_avg_in_degree() << std::endl;
527  graph_properties_file << "Out-degree" << std::endl;
528  graph_properties_file << " - minimum (excluding zero): " << this->get_min_out_degree() << std::endl;
529  graph_properties_file << " - maximum: " << this->get_max_out_degree() << std::endl;
530  graph_properties_file << " - average: " << this->get_avg_out_degree() << std::endl;
531  // Closes the stream.
532  graph_properties_file.close();
533 }
534 
535 // ================================================================================================
536 // ================================================================================================
538 {
539  // Streams objects.
540  std::ofstream vertices_properties_file;
541  // String objects.
542  std::string vertices_properties_filename = _name + "_vertices_properties.dat";
543  // Opens the stream and aborts if the operation did not succeed.
544  vertices_properties_file.open(vertices_properties_filename.c_str(), std::ios_base::out);
545  if( !vertices_properties_file.is_open() )
546  {
547  std::cout << "Could not open file: " << _name << ". Aborting." << std::endl;
548  abort();
549  }
550  // Writes the properties of each vertex.
551  vertices_properties_file.precision(8);
552  for(unsigned int n(0), nn(this->get_nb_vertices()); n<nn; ++n)
553  {
554  vertices_properties_file << std::fixed << (*this)(n)->get_name() << " ";
555  for(unsigned int t(0), tt(nb_dimensions+1); t<tt; ++t)
556  vertices_properties_file << std::fixed << (*this)(n)->get_metric_space_position()[t] << " ";
557  for(unsigned int t(0), tt(nb_hidden_variables); t<tt; ++t)
558  vertices_properties_file << std::fixed << (*this)(n)->get_hidden_variables()[t] << " ";
559  vertices_properties_file << std::fixed << (*this)(n)->get_out_degree() << " ";
560  vertices_properties_file << std::fixed << (*this)(n)->get_in_degree() << " ";
561  vertices_properties_file << std::fixed << (*this)(n)->get_nb_reciprocal_edges() << std::endl;
562  }
563  // Closes the stream.
564  vertices_properties_file.close();
565 }
566 
567 // ================================================================================================
568 // ================================================================================================
570 {
571  // Reintializes the variables inherited from the class base_directed_graph.
572  base_directed_graph_clear();
573  // Sets the type of the graph.
574  this->set_type_of_graph("HMS directed graph");
575  // Resets the geometry.
576  geometry = "00";
577  // Resets the number of dimensions of the metric space.
578  nb_dimensions = 0;
579  // // Resets the target values of the average value of hidden variables of vertices.
580  // target_avg_hidden_variables.clear();
581  // target_avg_hidden_variables.resize(nb_hidden_variables,0);
582  // Resets parameters for the hidden variables.
583  pdf_hidden_variables_type.clear();
584  pdf_hidden_variables_type.resize(nb_hidden_variables);
585  pdf_hidden_variables_param.clear();
586  pdf_hidden_variables_param.resize(nb_hidden_variables);
587  // Resets the parameters for the connection probability.
588  prob_connection_type = "00";
589  prob_connection_param.clear();
590  // Resets the density of vertices.
591  vertices_density = 0;
592  // Resets the statistics about the hidden variables.
593  min_hidden_variables.clear();
594  min_hidden_variables.resize(nb_hidden_variables);
595  max_hidden_variables.clear();
596  max_hidden_variables.resize(nb_hidden_variables);
597  avg_hidden_variables.clear();
598  avg_hidden_variables.resize(nb_hidden_variables);
599 }
600 
601 
602 
603 #endif // HMS_DIRECTED_GRAPH_HPP_INCLUDED
Class of the attributes of a simple edge.
Definition: edge_attributes.hpp:24
void clear()
Reinitializes the graph.
Definition: hms_directed_graph.hpp:569
Virtual template base class for directed graph objects.
Definition: base_directed_graph.hpp:37
void survey_hidden_variables()
Computes the quantities related to the degrees distribution.
Definition: hms_directed_graph.hpp:332
void write_graph_properties(std::string _name)
Exports the graph's properties.
Definition: hms_directed_graph.hpp:433
Class for vertices in random directed graphs embedded in a hidden metric space.
void create_edges(std::string _prob_connection_type, std::vector< double > _prob_connection_param, std::mt19937 &_engine)
Creates the edges of the graph.
Definition: hms_directed_graph.hpp:372
Class for random directed graphs embedded in a hidden metric space.
Definition: hms_directed_graph.hpp:46
void set_hidden_variables(std::vector< std::vector< double > > _sequence_hidden_variables)
Sets the hidden variables of vertices.
Definition: hms_directed_graph.hpp:255
void set_metric_space_positions(unsigned int _nb_vertices, std::string _geometry, double _delta, std::mt19937 &_engine)
Sets the metric space position.
Definition: hms_directed_graph.hpp:125
hms_directed_graph()
Constructor.
Definition: hms_directed_graph.hpp:110
Random number generators and related functions for various distributions.
void write_vertices_properties(std::string _name)
Exports the vertices' properties.
Definition: hms_directed_graph.hpp:537
double get_nb_dimensions()
Returns the number of dimensions.
Definition: hms_directed_graph.hpp:118
Virtual base class for directed graphs.
~hms_directed_graph()
Destructor.
Definition: hms_directed_graph.hpp:82