utils.hpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /**
  2. * @file tests/boost_graph/partitioning/utils.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_PARTITIONING_UTILS_H
  26. #define TESTS_BOOST_GRAPH_PARTITIONING_UTILS_H 1
  27. #include <tests/boost_graph/partitioning/defs.hpp>
  28. #include <boost/graph/copy.hpp>
  29. namespace paradevs { namespace tests { namespace boost_graph {
  30. void Global_Neigh_community(UnorientedGraph *g,
  31. const EntiersEntiers &Partition,
  32. Entiers *community, int vertex,
  33. int comm_in);
  34. OrientedGraphs Graph_Partition(const EntiersEntiers &Partition,
  35. OrientedGraph *go,
  36. UnorientedGraph *g,
  37. OutputEdgeList &outputedgelist,
  38. InputEdgeList &inputedgelist,
  39. Connections &connections);
  40. void List_edge_partie(Entiers *Partie, OrientedGraph *go,
  41. Edges &edge_partie,
  42. OutputEdges &outputedgespartie);
  43. void construire_graph(UnorientedGraph *g, OrientedGraph *graph);
  44. double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g,
  45. double &vol, std::string name);
  46. std::vector<double> modif_cut_tmp(UnorientedGraph *g,
  47. EntiersEntiers &Partition,
  48. std::vector<std::vector<double> > tabe_cut,
  49. int vertexs, int comm_in, Entiers community,
  50. double cut, std::string name);
  51. double Calcul_poids(Entiers *partie, UnorientedGraph *g);
  52. bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition,
  53. Entiers &part);
  54. void Affinage_equilibrage_charge(UnorientedGraph *g,
  55. EntiersEntiers &Partition);
  56. Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition,
  57. int vertex, int comm_in);
  58. void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
  59. Entiers &community, int val, double &cut,
  60. std::string name);
  61. void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition,
  62. double &cut, std::string name);
  63. void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit);
  64. bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg,
  65. ListEntiersEntiers &liste_corr, int val_reduc,
  66. int &val_cpt);
  67. bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg,
  68. ListEntiersEntiers &liste_corr, int val_reduc,
  69. int &val_cpt);
  70. bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
  71. ListEntiersEntiers &liste_corr, int val_reduc,
  72. int &val_cpt);
  73. bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg,
  74. ListEntiersEntiers &liste_corr,
  75. int val_reduc, int &val_cpt);
  76. bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg,
  77. ListEntiersEntiers &liste_corr,
  78. int val_reduc,
  79. int &val_cpt);
  80. Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,
  81. const Entiers &random_vertices);
  82. int rand_fini(int a, int b);
  83. int recherche_val2(const std::vector<float> &tab,float val);
  84. int recherche_val_double(const std::vector<double> &tab,double val);
  85. int recherche_val(const std::vector<int> &tab,int val);
  86. int dichotomie(const Entiers &tab,int i);
  87. void suprim_val(Entiers &tab,int i);
  88. bool In_tab(const Entiers &tab, int val);
  89. bool In_tab_dichotomie(const Entiers &tab, int val);
  90. double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,
  91. std::string name);
  92. void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
  93. int community_out,int community_in,int val,
  94. double &cut);
  95. void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g);
  96. int Cout_coupe(Entiers P,int val, UnorientedGraph &g);
  97. double Cout_coupe_pond(Entiers P,int val, UnorientedGraph &g);
  98. int In_community_dichotomie(const EntiersEntiers &part, int val);
  99. double Degree(UnorientedGraph &g , int node);
  100. double Cluster_Degree(UnorientedGraph &g , const Entiers &cluster);
  101. void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& uog);
  102. void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g);
  103. double modif_Cout_coupe(const Entiers &P, int val, double cut,
  104. UnorientedGraph *g);
  105. double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster);
  106. double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1,
  107. Entiers *cluster2, int index_cluster1,
  108. UnorientedGraph &g,std::string name);
  109. void Text_generator_graph(const char *texte, OrientedGraph *go);
  110. void Graph_constructor_txt(const char* text, OrientedGraph * Og);
  111. int decimal(int valeur);
  112. double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition,
  113. int partie, int node, std::string name);
  114. std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g,
  115. const EntiersEntiers &Partition, std::string name);
  116. void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition,
  117. double &cut, std::string name, double poids_moy);
  118. void Modif_vector_diff_cut_ratio(UnorientedGraph *g,
  119. const EntiersEntiers &Partition,
  120. std::vector<std::vector<int>> &Diff_vector,
  121. int recalcul1, int recalcul2, std::string name);
  122. double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition,
  123. int in, int out, int node, double ratio);
  124. std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g,
  125. const EntiersEntiers &Partition, std::string name);
  126. void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g,
  127. const EntiersEntiers &Partition,
  128. std::vector<int> &Diff_vector, int node, std::string name);
  129. void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition,
  130. double &cut, std::string name, double poids_moy);
  131. double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd,
  132. int node, double ratio);
  133. double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part,
  134. int node, std::string name);
  135. EntiersEntiers Spectral_Partition(const char* text);
  136. void Adjacent_Matrix_Txt(UnorientedGraph *g, const char* text);
  137. void Weight_Matrix_Txt(UnorientedGraph *g, const char* text);
  138. void Plot_UnorientedGraph(UnorientedGraph *g, const char* text);
  139. void Plot_OrientedGraph(OrientedGraph *g, const char* text);
  140. void Affichage_OrientedGraph(OrientedGraph *go);
  141. void Affichage_UnorientedGraph(UnorientedGraph *g);
  142. Entiers Liste_adjacence_tests(UnorientedGraph &g, int vertexs,
  143. const Entiers &Index_Vertex);
  144. void Plot_UnorientedGraph_All(UnorientedGraph *g,
  145. const EntiersEntiers &Partition,
  146. const char* text, bool Color);
  147. void Plot_OrientedGraph_All(OrientedGraph *go,
  148. const EntiersEntiers &Partition,
  149. const char* text, bool Color);
  150. double Total_weight_edges(UnorientedGraph *g);
  151. bool Est_voisin(UnorientedGraph *g, int vertex, int vertex_select);
  152. double In_modularity(UnorientedGraph *g , const Entiers &cluster);
  153. double Modularity(UnorientedGraph *g,const EntiersEntiers &part);
  154. bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg,
  155. ListEntiersEntiers &liste_corr, int val_reduc,
  156. int &val_cpt);
  157. void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2,
  158. std::vector<std::pair<int,int>> &connection,
  159. std::vector<double> &connection_weight);
  160. } } } // namespace paradevs tests boost_graph
  161. #endif