main.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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/graph/copy.hpp>
  28. #include <boost/timer.hpp>
  29. #include <fstream>
  30. #include <iostream>
  31. using namespace paradevs::tests::boost_graph;
  32. UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
  33. UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
  34. OrientedGraph::vertex_iterator vertexIto, vertexEndo;
  35. OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
  36. int main()
  37. {
  38. boost::timer t;
  39. srand((unsigned)time(NULL));
  40. UnorientedGraph* g = new UnorientedGraph();
  41. OrientedGraph* go = new OrientedGraph();
  42. UnorientedGraph graph_origin;
  43. std::vector<std::string> color;
  44. color.push_back("node [color=lightblue2, style=filled];");
  45. color.push_back("node [color=red, style=filled];");
  46. color.push_back("node [color=limegreen, style=filled];");
  47. color.push_back("node [color=orange, style=filled];");
  48. color.push_back("node [color=yellow2, style=filled];");
  49. color.push_back("node [color=slateblue1, style=filled];");
  50. color.push_back("node [color=plum, style=filled];");
  51. color.push_back("node [color=black, style=filled];");
  52. color.push_back("node [color=dimgrey, style=filled];");
  53. color.push_back("node [color=gold, style=filled];");
  54. color.push_back("node [color=indigo, style=filled];");
  55. color.push_back("node [color=turquoise, style=filled];");
  56. color.push_back("node [color=olive, style=filled];");
  57. color.push_back("node [color=cyan, style=filled];");
  58. color.push_back("node [color=crimson, style=filled];");
  59. color.push_back("node [color=lightsalmon, style=filled];");
  60. int nbr_parties = 4;
  61. Edges edge_partie;
  62. OutputEdgeList outputedgeslist(nbr_parties);
  63. InputEdgeList inputedgelist;
  64. Connections connections;
  65. build_graph(*go, 38);
  66. Entiers niveau;
  67. niveau.push_back(3);
  68. niveau.push_back(2);
  69. niveau.push_back(3);
  70. //build_generator_graph(go, 2000, 10 , 2 , 5 ,niveau);
  71. make_unoriented_graph(*go, *g);
  72. boost::copy_graph(*g, graph_origin);
  73. /*std::ofstream fichier ("../../sortie_graphe/graph_38_4.txt", std::ios::out);
  74. fichier<<"digraph G {"<<std::endl;
  75. tie(vertexIto, vertexEndo) = vertices(*go);
  76. for (; vertexIto != vertexEndo; ++vertexIto) {
  77. fichier<<(*go)[*vertexIto]._index<<"-> {";
  78. tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
  79. *go);
  80. for (; neighbourIto != neighbourEndo; ++neighbourIto){
  81. fichier<<(*go)[*neighbourIto]._index<<";";
  82. }
  83. fichier<<"}"<<std::endl;
  84. }
  85. fichier<<"}";
  86. fichier.close();*/
  87. int niveau_contraction = num_vertices(*g)/1;
  88. OrientedGraphs graphs = Multiniveau(niveau_contraction, g, &graph_origin, go, nbr_parties, niveau_contraction/4,"HEM", "gggp",
  89. "cut", "ratio", edge_partie ,
  90. outputedgeslist, inputedgelist,
  91. connections);
  92. /*for(int i =0; i<graphs.size(); i++){
  93. fichier2<<color.at(i)<<std::endl;
  94. tie(vertexIto, vertexEndo) = vertices(graphs.at(i));
  95. for (; vertexIto != vertexEndo; ++vertexIto) {
  96. fichier2<<(graphs.at(i))[*vertexIto]._index<<"-> {";
  97. //std::cout<<(graphs.at(i))[*vertexIto]._index<<" est connecté avec : ";
  98. tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
  99. graphs.at(i));
  100. for (; neighbourIto != neighbourEndo; ++neighbourIto){
  101. fichier2<<(graphs.at(i))[*neighbourIto]._index<<";";
  102. //std::cout<<(graphs.at(i))[*neighbourIto]._index<<" ";
  103. }
  104. fichier2<<"}"<<std::endl;
  105. //std::cout<<std::endl;
  106. }
  107. fichier2<<std::endl;
  108. //std::cout<<std::endl;
  109. }
  110. fichier2<<"}"<<std::endl;
  111. fichier2.close();
  112. */
  113. delete go;
  114. std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
  115. }