graph_generator.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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/graph_defs.hpp>
  28. #include <tests/boost_graph/partitioning/defs.hpp>
  29. #include <tests/boost_graph/partitioning/utils.hpp>
  30. #include <tests/boost_graph/partitioning/graph_build.hpp>
  31. namespace paradevs { namespace tests { namespace boost_graph {
  32. class GraphGenerator
  33. {
  34. public:
  35. GraphGenerator()
  36. { }
  37. virtual void generate(OrientedGraph& go) = 0;
  38. };
  39. class RandomGraphGenerator : public GraphGenerator
  40. {
  41. public:
  42. RandomGraphGenerator(unsigned int edge_number,
  43. std::vector<int> levels,
  44. unsigned int source_number,
  45. unsigned int min_neigh,
  46. unsigned int max_neigh) :
  47. edge_number(edge_number), levels(levels), source_number(source_number),
  48. min_neigh(min_neigh), max_neigh(max_neigh)
  49. { }
  50. virtual void generate(OrientedGraph& go)
  51. {
  52. /*const char *texte = new const char();
  53. texte = "enregistrement.txt";
  54. Graph_constructor_txt(texte,&go);*/
  55. //boost::timer t;
  56. build_generator_graph(&go, edge_number, source_number, min_neigh,
  57. max_neigh, levels);
  58. //double t3 = t.elapsed();
  59. //std::cout << "tmp_gen = " << t3 << std::endl;
  60. }
  61. private:
  62. unsigned int edge_number;
  63. std::vector<int> levels;
  64. unsigned int source_number;
  65. unsigned int min_neigh;
  66. unsigned int max_neigh;
  67. };
  68. class RandomGridGraphGenerator : public GraphGenerator
  69. {
  70. public:
  71. RandomGridGraphGenerator( int side,std::vector<std::pair<int,int>> vertex_selection,
  72. Entiers weight_vertex,const char *edge_weight, bool rec) :
  73. side(side), vertex_selection(vertex_selection), weight_vertex(weight_vertex),
  74. edge_weight(edge_weight), rec(rec)
  75. { }
  76. virtual void generate(OrientedGraph& go)
  77. {
  78. /*const char *texte = new const char();
  79. texte = "enregistrement.txt";
  80. Graph_constructor_txt(texte,&go);*/
  81. //boost::timer t;
  82. build_graph_grid(&go, side, vertex_selection, weight_vertex, edge_weight, rec);
  83. //double t3 = t.elapsed();
  84. //std::cout << "tmp_gen = " << t3 << std::endl;
  85. }
  86. private:
  87. int side;
  88. std::vector<std::pair<int,int>> vertex_selection;
  89. Entiers weight_vertex;
  90. const char *edge_weight;
  91. bool rec;
  92. };
  93. class RandomLinkedGraphGenerator : public GraphGenerator
  94. {
  95. public:
  96. RandomLinkedGraphGenerator(unsigned int edge_number,
  97. unsigned int levels,
  98. unsigned int min_neigh,
  99. unsigned int max_neigh) :
  100. edge_number(edge_number), levels(levels),
  101. min_neigh(min_neigh), max_neigh(max_neigh)
  102. { }
  103. virtual void generate(OrientedGraph& go)
  104. {
  105. build_generator_graph_linked(&go, edge_number, levels , min_neigh,
  106. max_neigh);
  107. }
  108. private:
  109. unsigned int edge_number;
  110. unsigned int levels;
  111. unsigned int min_neigh;
  112. unsigned int max_neigh;
  113. };
  114. class ArtificialGraphGenerator : public GraphGenerator
  115. {
  116. public:
  117. ArtificialGraphGenerator(unsigned int edge_number) :
  118. edge_number(edge_number)
  119. { }
  120. virtual void generate(OrientedGraph& go)
  121. { build_graph(go, edge_number); }
  122. private:
  123. unsigned int edge_number;
  124. };
  125. class CorsenGraphGenerator : public GraphGenerator
  126. {
  127. public:
  128. CorsenGraphGenerator()
  129. { }
  130. virtual void generate(OrientedGraph& go)
  131. {
  132. //build_corsen_graph(go);
  133. }
  134. };
  135. } } } // namespace paradevs tests boost_graph
  136. #endif