graph_generator.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * @file tests/boost_graph/graph_partitioning.hpp
  3. * @author The PARADEVS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * PARADEVS - the multimodeling and simulation environment
  8. * This file is a part of the PARADEVS environment
  9. *
  10. * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #ifndef __TESTS_BOOST_GRAPH_GRAPH_GENERATOR_HPP
  26. #define __TESTS_BOOST_GRAPH_GRAPH_GENERATOR_HPP 1
  27. #include <tests/boost_graph/partitioning/defs.hpp>
  28. #include <tests/boost_graph/partitioning/utils.hpp>
  29. #include <tests/boost_graph/partitioning/graph_build.hpp>
  30. namespace paradevs { namespace tests { namespace boost_graph {
  31. class GraphGenerator
  32. {
  33. public:
  34. GraphGenerator()
  35. { }
  36. virtual void generate(OrientedGraph& go) = 0;
  37. };
  38. class RandomGraphGenerator : public GraphGenerator
  39. {
  40. public:
  41. RandomGraphGenerator(unsigned int edge_number,
  42. std::vector<int> levels,
  43. unsigned int source_number,
  44. unsigned int min_neigh,
  45. unsigned int max_neigh) :
  46. edge_number(edge_number), levels(levels), source_number(source_number),
  47. min_neigh(min_neigh), max_neigh(max_neigh)
  48. { }
  49. virtual void generate(OrientedGraph& go)
  50. {
  51. // const char *texte = new const char();
  52. // texte = "file/data_base/tree/tree_20000.txt";
  53. // Graph_constructor_txt(texte,&go);
  54. //boost::timer t;
  55. build_generator_graph(&go, edge_number, source_number, min_neigh,
  56. max_neigh, levels);
  57. //double t3 = t.elapsed();
  58. //std::cout << "tmp_gen = " << t3 << std::endl;
  59. }
  60. private:
  61. unsigned int edge_number;
  62. std::vector<int> levels;
  63. unsigned int source_number;
  64. unsigned int min_neigh;
  65. unsigned int max_neigh;
  66. };
  67. class RandomGridGraphGenerator : public GraphGenerator
  68. {
  69. public:
  70. RandomGridGraphGenerator( int side,std::vector<std::pair<int,int>> vertex_selection,
  71. Entiers weight_vertex,const char *edge_weight, bool rec) :
  72. side(side), vertex_selection(vertex_selection), weight_vertex(weight_vertex),
  73. edge_weight(edge_weight), rec(rec)
  74. { }
  75. virtual void generate(OrientedGraph& go)
  76. {
  77. /*const char *texte = new const char();
  78. texte = "enregistrement.txt";
  79. Graph_constructor_txt(texte,&go);*/
  80. //boost::timer t;
  81. build_graph_grid(&go, side, vertex_selection, weight_vertex, edge_weight, rec);
  82. //double t3 = t.elapsed();
  83. //std::cout << "tmp_gen = " << t3 << std::endl;
  84. }
  85. private:
  86. int side;
  87. std::vector<std::pair<int,int>> vertex_selection;
  88. Entiers weight_vertex;
  89. const char *edge_weight;
  90. bool rec;
  91. };
  92. class RandomLinkedGraphGenerator : public GraphGenerator
  93. {
  94. public:
  95. RandomLinkedGraphGenerator(unsigned int edge_number,
  96. unsigned int levels,
  97. unsigned int min_neigh,
  98. unsigned int max_neigh) :
  99. edge_number(edge_number), levels(levels),
  100. min_neigh(min_neigh), max_neigh(max_neigh)
  101. { }
  102. virtual void generate(OrientedGraph& go)
  103. {
  104. // const char *texte = new const char();
  105. //texte = "file/data_base/HO_models.txt";
  106. // texte = "file/data_base/linked/linked10000.txt";
  107. // Graph_constructor_txt(texte,&go);
  108. build_generator_graph_linked(&go, edge_number, levels , min_neigh,
  109. max_neigh);
  110. }
  111. private:
  112. unsigned int edge_number;
  113. unsigned int levels;
  114. unsigned int min_neigh;
  115. unsigned int max_neigh;
  116. };
  117. class ArtificialGraphGenerator : public GraphGenerator
  118. {
  119. public:
  120. ArtificialGraphGenerator(unsigned int edge_number) :
  121. edge_number(edge_number)
  122. { }
  123. virtual void generate(OrientedGraph& go)
  124. { build_graph(go, edge_number); }
  125. private:
  126. unsigned int edge_number;
  127. };
  128. class ParcelGraphGenerator : public GraphGenerator
  129. {
  130. public:
  131. ParcelGraphGenerator(uint size_max,
  132. std::string name) :
  133. size_max(size_max), name(name)
  134. { }
  135. virtual void generate(OrientedGraph& go)
  136. {
  137. //const char *texte = new const char();
  138. //texte = "file/data_base/HO_models.txt";
  139. //texte = "file/data_base/linked/linked10000.txt";
  140. //Graph_constructor_txt(texte,&go);
  141. build_parcellaire_graph(&go, size_max, name);
  142. }
  143. private:
  144. uint size_max;
  145. std::string name;
  146. };
  147. class CorsenGraphGenerator : public GraphGenerator
  148. {
  149. public:
  150. CorsenGraphGenerator()
  151. { }
  152. virtual void generate(OrientedGraph& go)
  153. {
  154. //build_corsen_graph(go);
  155. }
  156. };
  157. } } } // namespace paradevs tests boost_graph
  158. #endif