main.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * @file tests/boost_graph/partitioning/main.cpp
  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. #include <tests/boost_graph/partitioning/gggp.hpp>
  26. #include <tests/boost_graph/partitioning/graph_build.hpp>
  27. #include <boost/timer.hpp>
  28. #include <iostream>
  29. using namespace paradevs::tests::boost_graph;
  30. UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
  31. UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
  32. OrientedGraph::vertex_iterator vertexIto, vertexEndo;
  33. OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
  34. int main()
  35. {
  36. boost::timer t;
  37. srand(7266);
  38. UnorientedGraph* g = new UnorientedGraph();
  39. OrientedGraph* go = new OrientedGraph();
  40. UnorientedGraph* graph_origin = new UnorientedGraph();
  41. OrientedGraph* gop = new OrientedGraph();
  42. build_graph(*g, *go);
  43. build_graph(*graph_origin, *gop);
  44. delete gop;
  45. int nbr_parties = 38;
  46. /*EntiersEntiers Partition = Random_partitioning(g,nbr_parties);
  47. for(uint i = 0; i < Partition.size(); i++){
  48. for(uint j = 0; j < Partition.at(i)->size(); j++){
  49. std::cout<<Partition.at(i)->at(j)<<std::endl;
  50. }
  51. std::cout<<std::endl;
  52. }
  53. std::cout<<Partition.size()<<std::endl;*/
  54. Edges edge_partie;
  55. OutputEdgeList outputedgeslist(nbr_parties);
  56. InputEdgeList inputedgelist;
  57. Connections connections;
  58. OrientedGraphs graphs = Multiniveau(38, g, graph_origin, go, nbr_parties,"HEM", "gggp_pond",
  59. "cut_norm", "norm", edge_partie ,
  60. outputedgeslist, inputedgelist,
  61. connections);
  62. std::cout << std::endl;
  63. std::cout << "Sous Graphes :" << std::endl;
  64. for (uint i = 0; i< graphs.size(); i++) {
  65. tie(vertexIto, vertexEndo) = vertices(graphs[i]);
  66. for (; vertexIto != vertexEndo; ++vertexIto) {
  67. std::cout << graphs[i][*vertexIto]._index
  68. << " est connecté avec ";
  69. tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
  70. graphs[i]);
  71. for (; neighbourIto != neighbourEndo; ++neighbourIto)
  72. std::cout << graphs[i][*neighbourIto]._index << " ";
  73. std::cout << " et son poids est de "
  74. << graphs[i][*vertexIto]._weight<<std::endl;
  75. }
  76. std::cout << std::endl;
  77. }
  78. std::clog << "OutputEdgeList :" << std::endl;
  79. for (uint i = 0; i < outputedgeslist.size(); i++) {
  80. for (uint j = 0; j < outputedgeslist.at(i).size(); j++){
  81. std::cout << outputedgeslist.at(i).at(j).first << " "
  82. << outputedgeslist.at(i).at(j).second << std::endl;
  83. }
  84. }
  85. std::cout << std::endl;
  86. std::clog << "InputEdgeList :" << std::endl;
  87. for (uint i = 0; i < inputedgelist.size(); i++) {
  88. for (uint j = 0; j < inputedgelist.at(i).size(); j++){
  89. std::cout << inputedgelist.at(i).at(j).first << " "
  90. << inputedgelist.at(i).at(j).second << std::endl;
  91. }
  92. }
  93. std::cout << std::endl;
  94. std::clog << "Connections :" << std::endl;
  95. for (uint i = 0; i < connections.size(); i++) {
  96. std::cout << "(" << connections.at(i).first.first << ","
  97. << connections.at(i).first.second << ") -> ("
  98. << connections.at(i).second.first << ","
  99. << connections.at(i).second.second << ")"
  100. << std::endl;
  101. }
  102. delete graph_origin;
  103. std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
  104. }