graph_partitioning.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 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_PARTITIONING_HPP
  26. #define __TESTS_BOOST_GRAPH_GRAPH_PARTITIONING_HPP 1
  27. #include <tests/boost_graph/graph_defs.hpp>
  28. #include <tests/boost_graph/partitioning/graph_build.hpp>
  29. #include <tests/boost_graph/partitioning/gggp.hpp>
  30. #include <boost/graph/copy.hpp>
  31. namespace paradevs { namespace tests { namespace boost_graph {
  32. class PartitioningGraphBuilder
  33. {
  34. public:
  35. PartitioningGraphBuilder(int cn, std::string pmn, int cc, bool ccf) :
  36. cluster_number(cn), partitioning_method_name(pmn),
  37. contraction_coef(cc), contraction_coef_flag(ccf)
  38. { }
  39. void build(OrientedGraphs& graphs,
  40. InputEdgeList& input_edges,
  41. OutputEdgeList& output_edges,
  42. Connections& parent_connections)
  43. {
  44. srand((unsigned)time(NULL));
  45. //srand(7266);
  46. UnorientedGraph* g = new UnorientedGraph();
  47. OrientedGraph go;
  48. UnorientedGraph graph_origin;
  49. // internal examples
  50. // {
  51. // build_graph(*g, go);
  52. // boost::copy_graph(*g, graph_origin);
  53. // }
  54. // corsen examples
  55. {
  56. build_corsen_graph(go);
  57. make_unoriented_graph(go, *g);
  58. boost::copy_graph(*g, graph_origin);
  59. }
  60. Edges edge_partie;
  61. Connections connections;
  62. output_edges = OutputEdgeList(cluster_number);
  63. if (contraction_coef_flag) {
  64. graphs = Multiniveau(num_vertices(*g) / contraction_coef,
  65. g, &graph_origin, &go,
  66. cluster_number, "HEM",
  67. partitioning_method_name,
  68. "cut_norm", "norm", edge_partie ,
  69. output_edges, input_edges,
  70. parent_connections);
  71. } else {
  72. graphs = Multiniveau(contraction_coef, g, &graph_origin, &go,
  73. cluster_number, "HEM",
  74. partitioning_method_name,
  75. "cut_norm", "norm", edge_partie ,
  76. output_edges, input_edges,
  77. parent_connections);
  78. }
  79. }
  80. private:
  81. int cluster_number;
  82. std::string partitioning_method_name;
  83. int contraction_coef;
  84. bool contraction_coef_flag;
  85. };
  86. class CorsenFlatGraphBuilder
  87. {
  88. public:
  89. CorsenFlatGraphBuilder()
  90. { }
  91. void build(OrientedGraphs& graphs, InputEdgeList& /* input_edges */,
  92. OutputEdgeList& /* output_edges */,
  93. Connections& /* parent_connections */)
  94. {
  95. OrientedGraph graph;
  96. build_corsen_graph(graph);
  97. graphs.push_back(graph);
  98. }
  99. };
  100. } } } // namespace paradevs tests boost_graph
  101. #endif