浏览代码

Mise à jour des méthodes de contraction, d'affinage et de tirage otpimal. Divers aéliorations de fonction, optimisation du temps d'exécution.

totofeh 11 年之前
父节点
当前提交
85c2a806e3

+ 36 - 3
src/tests/boost_graph/graph_builder.hpp

@@ -342,8 +342,8 @@ public:
         texte = "enregistrement.txt";
         texte = "enregistrement.txt";
         Graph_constructor_txt(texte, &graph);*/
         Graph_constructor_txt(texte, &graph);*/
         OrientedGraph graph;
         OrientedGraph graph;
-        unsigned int edge_number = 6000;
-        std::vector<int> levels = {5, 4, 3, 2 };
+        unsigned int edge_number = 200;
+        std::vector<int> levels = {/*5,4,*/ 3, 2 };
         
         
         unsigned int source_number = edge_number/100*1;
         unsigned int source_number = edge_number/100*1;
         unsigned int min_neigh = 2;
         unsigned int min_neigh = 2;
@@ -351,6 +351,7 @@ public:
 
 
         build_generator_graph(&graph,edge_number,source_number,min_neigh,max_neigh,levels);
         build_generator_graph(&graph,edge_number,source_number,min_neigh,max_neigh,levels);
         graphs.push_back(graph);
         graphs.push_back(graph);
+
     }
     }
 
 
 };
 };
@@ -373,8 +374,9 @@ public:
         const char *texte = new const char();
         const char *texte = new const char();
         texte = "enregistrement.txt";
         texte = "enregistrement.txt";
         Graph_constructor_txt(texte, &graph);*/
         Graph_constructor_txt(texte, &graph);*/
+        
         OrientedGraph graph;
         OrientedGraph graph;
-        unsigned int edge_number = 6000;
+        unsigned int edge_number = 5000;
         unsigned int levels = 60;
         unsigned int levels = 60;
         
         
         unsigned int min_neigh = 2;
         unsigned int min_neigh = 2;
@@ -386,6 +388,37 @@ public:
 
 
 };
 };
 
 
+class RandomGridFlatGraphBuilder
+{
+public:
+    RandomGridFlatGraphBuilder()
+    { }
+
+    void build(OrientedGraphs& graphs, InputEdgeList& ,
+               OutputEdgeList& ,
+               Connections& )
+    {
+        
+        OrientedGraph graph;
+        unsigned int side = 90;
+        std::vector<std::pair<int,int>> vertex_selection;
+        std::pair<int,int> tmp;
+        tmp.first = 0;
+		tmp.second = 3;
+        vertex_selection.push_back(tmp);
+        Entiers weight_vertex;
+        weight_vertex.push_back(1);
+        const char *edge_weight;
+        edge_weight = "../../sortie_graphe/tests_grid.txt";
+        bool rec = false;
+        
+		
+		build_graph_grid(&graph, side, vertex_selection,  weight_vertex, edge_weight, rec);;
+        graphs.push_back(graph);
+    }
+
+};
+
 
 
 } } } // namespace paradevs tests boost_graph
 } } } // namespace paradevs tests boost_graph
 
 

+ 2 - 2
src/tests/boost_graph/graph_defs.hpp

@@ -32,7 +32,7 @@
 namespace paradevs { namespace tests { namespace boost_graph {
 namespace paradevs { namespace tests { namespace boost_graph {
 
 
 enum DynamicsType {
 enum DynamicsType {
-    TOP_PIXEL = 0, NORMAL_PIXEL
+	TOP_PIXEL = 0, NORMAL_PIXEL
 };
 };
 
 
 struct VertexProperties
 struct VertexProperties
@@ -58,7 +58,7 @@ struct EdgeProperties
     { }
     { }
 };
 };
 
 
-typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS,
+typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::bidirectionalS,//boost::directedS,
                                 VertexProperties, EdgeProperties> OrientedGraph;
                                 VertexProperties, EdgeProperties> OrientedGraph;
 typedef std::vector < OrientedGraph > OrientedGraphs;
 typedef std::vector < OrientedGraph > OrientedGraphs;
 
 

+ 34 - 0
src/tests/boost_graph/graph_generator.hpp

@@ -60,8 +60,12 @@ public:
         /*const char *texte = new const char();
         /*const char *texte = new const char();
         texte = "enregistrement.txt";
         texte = "enregistrement.txt";
         Graph_constructor_txt(texte,&go);*/
         Graph_constructor_txt(texte,&go);*/
+       //boost::timer t; 
+	   
        build_generator_graph(&go, edge_number, source_number, min_neigh,
        build_generator_graph(&go, edge_number, source_number, min_neigh,
                               max_neigh, levels);
                               max_neigh, levels);
+       //double t3 = t.elapsed();
+	   //std::cout << "tmp_gen = " << t3 << std::endl;
     }
     }
 
 
 private:
 private:
@@ -72,6 +76,36 @@ private:
     unsigned int max_neigh;
     unsigned int max_neigh;
 };
 };
 
 
+class RandomGridGraphGenerator : public GraphGenerator
+{
+public:
+    RandomGridGraphGenerator( int side,std::vector<std::pair<int,int>> vertex_selection,
+							  Entiers weight_vertex,const char *edge_weight, bool rec) :
+        side(side), vertex_selection(vertex_selection), weight_vertex(weight_vertex),
+        edge_weight(edge_weight), rec(rec)
+    { }
+
+    virtual void generate(OrientedGraph& go)
+    {
+        /*const char *texte = new const char();
+        texte = "enregistrement.txt";
+        Graph_constructor_txt(texte,&go);*/
+       //boost::timer t; 
+	   
+       build_graph_grid(&go, side, vertex_selection,  weight_vertex, edge_weight, rec);
+       //double t3 = t.elapsed();
+	   //std::cout << "tmp_gen = " << t3 << std::endl;
+    }
+
+private:
+		int side;
+		std::vector<std::pair<int,int>> vertex_selection;
+		Entiers weight_vertex;
+		const char *edge_weight;
+		bool rec;
+};
+
+
 class RandomLinkedGraphGenerator : public GraphGenerator
 class RandomLinkedGraphGenerator : public GraphGenerator
 {
 {
 public:
 public:

+ 4 - 0
src/tests/boost_graph/graph_manager.hpp

@@ -446,6 +446,8 @@ public:
                             parent_connections);
                             parent_connections);
 
 
         // build coordinators (graphs)
         // build coordinators (graphs)
+        //boost::timer t; 
+
         for (unsigned int i = 0; i < graphs.size(); ++i) {
         for (unsigned int i = 0; i < graphs.size(); ++i) {
             Coordinator* coordinator = 0;
             Coordinator* coordinator = 0;
             std::ostringstream ss;
             std::ostringstream ss;
@@ -497,6 +499,8 @@ public:
                         ss_in.str());
                         ss_in.str());
             }
             }
         }
         }
+        //double t3 = t.elapsed();
+        //std::cout << "tmp_constr = " << t3 << std::endl;
     }
     }
 
 
     virtual ~HeapHierarchicalGraphManager()
     virtual ~HeapHierarchicalGraphManager()

+ 2 - 4
src/tests/boost_graph/graph_partitioning.hpp

@@ -53,13 +53,11 @@ public:
 		std::cout<<"**"<<cluster_number<<"**"<<std::endl;
 		std::cout<<"**"<<cluster_number<<"**"<<std::endl;
         UnorientedGraph* g = new UnorientedGraph();
         UnorientedGraph* g = new UnorientedGraph();
         OrientedGraph go;
         OrientedGraph go;
-        UnorientedGraph graph_origin;
         std::vector<double> Cut;
         std::vector<double> Cut;
 
 
         generator.generate(go);
         generator.generate(go);
 
 
         make_unoriented_graph(go, *g);
         make_unoriented_graph(go, *g);
-        boost::copy_graph(*g, graph_origin);
 
 
         Edges edge_partie;
         Edges edge_partie;
         Connections connections;
         Connections connections;
@@ -68,14 +66,14 @@ public:
 
 
         if (contraction_coef_flag) {
         if (contraction_coef_flag) {
             graphs = Multiniveau(num_vertices(*g) / contraction_coef,
             graphs = Multiniveau(num_vertices(*g) / contraction_coef,
-                                 g, &graph_origin, &go,
+                                 g, &go,
                                  cluster_number,10, "HEM",
                                  cluster_number,10, "HEM",
                                  partitioning_method_name,
                                  partitioning_method_name,
                                  "diff", "ratio", edge_partie ,
                                  "diff", "ratio", edge_partie ,
                                  output_edges, input_edges,
                                  output_edges, input_edges,
                                  parent_connections,false, Cut, 2);
                                  parent_connections,false, Cut, 2);
         } else {
         } else {
-            graphs = Multiniveau(contraction_coef, g, &graph_origin, &go,
+            graphs = Multiniveau(contraction_coef, g, &go,
                                  cluster_number,10, "HEM",
                                  cluster_number,10, "HEM",
                                  partitioning_method_name,
                                  partitioning_method_name,
                                  "diff", "ratio", edge_partie ,
                                  "diff", "ratio", edge_partie ,

+ 276 - 362
src/tests/boost_graph/partitioning/gggp.cpp

@@ -52,7 +52,7 @@ void ggp(UnorientedGraph *g, Entiers *sommetsSource,
             if(Partition.at(i)->size() == tmp)
             if(Partition.at(i)->size() == tmp)
             {
             {
 				sommetsSource->clear();
 				sommetsSource->clear();
-				for(int id = 0; id < Partition.at(i)->size();id++){
+				for(uint id = 0; id < Partition.at(i)->size();id++){
 					sommetsSource->push_back(Partition.at(i)->at(id));
 					sommetsSource->push_back(Partition.at(i)->at(id));
 				}
 				}
 				index_partition = i;
 				index_partition = i;
@@ -86,7 +86,7 @@ void ggp(UnorientedGraph *g, Entiers *sommetsSource,
 		suprim_val(*sommetsSource,rand);
 		suprim_val(*sommetsSource,rand);
 	}
 	}
 	
 	
-    int cpt = 0;
+    uint cpt = 0;
     while(poids<poids_max && sommetsSource->size()>1)
     while(poids<poids_max && sommetsSource->size()>1)
     {
     {
         if(cpt<sommetsDestination->size()){
         if(cpt<sommetsDestination->size()){
@@ -164,7 +164,7 @@ void Transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Ent
 
 
 void Tirage_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, const std::string &name, double &poids, double &cut){
 void Tirage_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, const std::string &name, double &poids, double &cut){
 	double diff = -100.;
 	double diff = -100.;
-	int tmp_tir;
+	uint tmp_tir;
 	while(diff != 0){
 	while(diff != 0){
 		tmp_tir = sommetsSource->at(rand_fini(0,sommetsSource->size()));
 		tmp_tir = sommetsSource->at(rand_fini(0,sommetsSource->size()));
 		diff = Diff_cut_ratio_bissection(g, sommetsSource, tmp_tir, name);
 		diff = Diff_cut_ratio_bissection(g, sommetsSource, tmp_tir, name);
@@ -183,14 +183,14 @@ bool Best_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource
 									  const std::string &name, double &poids, double poids_max, double PC, int stop, int &cpt, double &cut){
 									  const std::string &name, double &poids, double poids_max, double PC, int stop, int &cpt, double &cut){
     Liste_Voisin(*sommetsDestination,sommets_adj,*g);
     Liste_Voisin(*sommetsDestination,sommets_adj,*g);
     //sort(sommets_adj.begin(), sommets_adj.end());
     //sort(sommets_adj.begin(), sommets_adj.end());
-	if(sommets_adj.size() == 0 & cpt<stop & sommetsSource->size()>1)
+	if((sommets_adj.size() == 0) & (cpt<stop) & (sommetsSource->size()>1))
 	{
 	{
 		cpt++;
 		cpt++;
 		//std::cout<<"*** Passage 1 ***"<<std::endl;
 		//std::cout<<"*** Passage 1 ***"<<std::endl;
 		if(poids < (poids_max - poids_max*PC/100)){
 		if(poids < (poids_max - poids_max*PC/100)){
 			//std::cout<<"*** Passage 1a ***"<<std::endl;
 			//std::cout<<"*** Passage 1a ***"<<std::endl;
 			Tirage_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, name, poids, cut);
 			Tirage_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, name, poids, cut);
-			if(poids < (poids_max - poids_max*PC/100) & sommetsSource->size()>1){
+			if((poids < (poids_max - poids_max*PC/100)) & (sommetsSource->size()>1)){
 				Best_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj,
 				Best_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj,
 												name, poids, poids_max, PC, stop, cpt, cut);	
 												name, poids, poids_max, PC, stop, cpt, cut);	
 			}else{			
 			}else{			
@@ -203,7 +203,7 @@ bool Best_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource
 		}
 		}
 		
 		
 	}
 	}
-	else if (sommets_adj.size() == 0 & cpt>=stop){
+	else if ((sommets_adj.size() == 0) & (cpt>=stop)){
 		//std::cout<<"*** Passage 2 ***"<<std::endl;
 		//std::cout<<"*** Passage 2 ***"<<std::endl;
 		return true;
 		return true;
 	}else if (sommetsSource->size()==1){
 	}else if (sommetsSource->size()==1){
@@ -231,11 +231,11 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDesti
             tailles.push_back(Partition.at(i)->size());
             tailles.push_back(Partition.at(i)->size());
         }
         }
         uint tmp=*max_element(tailles.begin(),tailles.end());
         uint tmp=*max_element(tailles.begin(),tailles.end());
-        for(int i=0; i<Partition.size();i++){
+        for(uint i=0; i<Partition.size();i++){
             if(Partition.at(i)->size()==tmp)
             if(Partition.at(i)->size()==tmp)
             {
             {
 				sommetsSource->clear();
 				sommetsSource->clear();
-				for(int id = 0; id < Partition.at(i)->size();id++){
+				for(uint id = 0; id < Partition.at(i)->size();id++){
 					sommetsSource->push_back(Partition.at(i)->at(id));
 					sommetsSource->push_back(Partition.at(i)->at(id));
 				}
 				}
 				index_partition = i;
 				index_partition = i;
@@ -323,7 +323,7 @@ else{
 void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
 void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
              const std::string &nom_cut, int nbr_tirage, const std::string &nom_strat, int distance)
              const std::string &nom_cut, int nbr_tirage, const std::string &nom_strat, int distance)
 {
 {
-	/*std::vector<std::string> color;
+	std::vector<std::string> color;
 	color.push_back("[color=blue2, fontcolor=blue2];");
 	color.push_back("[color=blue2, fontcolor=blue2];");
 	color.push_back("[color=red, fontcolor=red];");
 	color.push_back("[color=red, fontcolor=red];");
 	color.push_back("[color=green, fontcolor=green];");
 	color.push_back("[color=green, fontcolor=green];");
@@ -339,12 +339,12 @@ void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
 	color.push_back("[color=cyan, fontcolor=cyan];");
 	color.push_back("[color=cyan, fontcolor=cyan];");
 	color.push_back("[color=purple1, fontcolor=purpule1];");
 	color.push_back("[color=purple1, fontcolor=purpule1];");
 	color.push_back("[color=crimson, fontcolor=crimson];");
 	color.push_back("[color=crimson, fontcolor=crimson];");
-	color.push_back("[color=black, fontcolor=black];");*/
+	color.push_back("[color=black, fontcolor=black];");
 	
 	
 	UnorientedGraph copy_graph;
 	UnorientedGraph copy_graph;
 	boost::copy_graph(*g,copy_graph);
 	boost::copy_graph(*g,copy_graph);
 	
 	
-	/*std::vector<char* > nom;
+	std::vector<char* > nom;
 	char * tmp_nom1 = new char();
 	char * tmp_nom1 = new char();
 	tmp_nom1 = "../../sortie_graphe/Tests/Graphes/Evolution_bissection/bissection_1.txt";
 	tmp_nom1 = "../../sortie_graphe/Tests/Graphes/Evolution_bissection/bissection_1.txt";
 	nom.push_back(tmp_nom1);
 	nom.push_back(tmp_nom1);
@@ -375,7 +375,7 @@ void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
 	char * tmp_nom10 = new char();
 	char * tmp_nom10 = new char();
 	tmp_nom10= "../../sortie_graphe/Tests/Graphes/Evolution_bissection/bissection_10.txt";
 	tmp_nom10= "../../sortie_graphe/Tests/Graphes/Evolution_bissection/bissection_10.txt";
 	nom.push_back(tmp_nom10);
 	nom.push_back(tmp_nom10);
-	int cpt = 0;*/
+	int cpt = 0;
 	
 	
 	for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
 	for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
     {
     {
@@ -391,7 +391,7 @@ void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
 				Optimisation_method_neighbour_distance(g,part,j,nbr_tirage, distance, nom_cut, nom_strat);
 				Optimisation_method_neighbour_distance(g,part,j,nbr_tirage, distance, nom_cut, nom_strat);
 			}
 			}
 			
 			
-	    		/*std::ofstream GRAPH2 (nom.at(cpt), std::ios::out);
+	    		std::ofstream GRAPH2 (nom.at(cpt), std::ios::out);
 				GRAPH2<<"graph G {"<<std::endl;   
 				GRAPH2<<"graph G {"<<std::endl;   
 				tie(vertexIt, vertexEnd) = vertices(copy_graph);
 				tie(vertexIt, vertexEnd) = vertices(copy_graph);
 				for (; vertexIt != vertexEnd; ++vertexIt) {
 				for (; vertexIt != vertexEnd; ++vertexIt) {
@@ -415,7 +415,7 @@ void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
 				GRAPH2<<"}";	
 				GRAPH2<<"}";	
 				GRAPH2.close();
 				GRAPH2.close();
 				
 				
-				cpt ++;*/
+				cpt ++;
         }
         }
     }
     }
 }
 }
@@ -573,6 +573,8 @@ void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
     }
     }
 }
 }
 
 
+
+
 EntiersEntiers Random_partitioning(UnorientedGraph *g,
 EntiersEntiers Random_partitioning(UnorientedGraph *g,
                                 uint nbr_parties)
                                 uint nbr_parties)
 {
 {
@@ -612,7 +614,6 @@ EntiersEntiers Random_partitioning(UnorientedGraph *g,
 
 
 OrientedGraphs Multiniveau(uint niveau_contraction,
 OrientedGraphs Multiniveau(uint niveau_contraction,
                            UnorientedGraph *g,
                            UnorientedGraph *g,
-                           UnorientedGraph *graph_origin,
                            OrientedGraph *go,
                            OrientedGraph *go,
                            int nbr_parties,
                            int nbr_parties,
                            int nbr_tirage,
                            int nbr_tirage,
@@ -624,373 +625,283 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
                            OutputEdgeList& outputedgelist,
                            OutputEdgeList& outputedgelist,
                            InputEdgeList& inputedgelist,
                            InputEdgeList& inputedgelist,
                            Connections& connections, bool rec,
                            Connections& connections, bool rec,
-                           std::vector<double> &Cut, int distance)
-{
-	std::vector<std::string> color;
-	if(rec == true){
-		color.push_back("[color=blue2, fontcolor=blue2];");
-		color.push_back("[color=red, fontcolor=red];");
-		color.push_back("[color=green, fontcolor=green];");
-		color.push_back("[color=yellow, fontcolor=yellow2];");
-		color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
-		color.push_back("[color=turquoise, fontcolor=turquoise];");
-		color.push_back("[color=orange, fontcolor=orange];");
-		color.push_back("[color=olivedrab, fontcolor=olivedrab];");
-		color.push_back("[color=indigo, fontcolor=indigo];");
-		color.push_back("[color=gold, fontcolor=gold];");
-		color.push_back("[color=slateblue2, fontcolor=slateblue2];");
-		color.push_back("[color=dimgrey, fontcolor=dimgrey];");
-		color.push_back("[color=cyan, fontcolor=cyan];");
-		color.push_back("[color=purple1, fontcolor=purpule1];");
-		color.push_back("[color=crimson, fontcolor=crimson];");
-		color.push_back("[color=black, fontcolor=black];");
-    }
-    
-    boost::timer t; 
-    
+                           std::vector<double> &Cut /*Paramètre à vérifier*/, int distance)
+{   
+    boost::timer t;    
     EntiersEntiers Partition;
     EntiersEntiers Partition;
     Entiers *part = new Entiers();
     Entiers *part = new Entiers();
     Base_Graph baseg;
     Base_Graph baseg;
     baseg.push_back(g);
     baseg.push_back(g);
     ListEntiersEntiers liste_corr;
     ListEntiersEntiers liste_corr;
+    OrientedGraphs Graphes;
     uint cpt =0;
     uint cpt =0;
-
     int val_cpt = num_vertices(*g);
     int val_cpt = num_vertices(*g);
-    bool stop = false;
-
-    if (niveau_contraction == val_cpt) {
-        stop = true;
-    }
-
-    while(stop != true)
-    {
-    	if(contraction == "HEM")
-    		stop = contraction_HEM(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
-    	else
-    		stop = contraction_Random_Maching(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
-        cpt++;
-    }
-    
-    if(rec == true){
-		std::ofstream GRAPHp ("../../sortie_graphe/Tests/Graphes/Evolution_bissection/poids_graphe.txt", std::ios::out);
-		GRAPHp<<"Poids du graphe contracté : "<<std::endl;   
-		tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-1));
-		for (; vertexIt != vertexEnd; ++vertexIt) {
-			GRAPHp<<(*baseg.at(baseg.size()-1))[*vertexIt]._index<<" --> "<<(*baseg.at(baseg.size()-1))[*vertexIt]._weight<<std::endl;;
-		}   
-		
-		GRAPHp<<"}";	
-		GRAPHp.close();
-	}
-
-    double t2 = t.elapsed();
-    std::cout << "Contraction duration : " << t2 << " seconds" << std::endl;
     
     
-    for(int i = 0; i<num_vertices(*baseg.at(baseg.size() - 1)); i++){
-		part->push_back(i);
-	}
-	Partition.push_back(part);
+    if(niveau_contraction != val_cpt){
+			
+	    bool stop = false;
 	
 	
-	UnorientedGraph copy_graph;
-	boost::copy_graph(*baseg.at(baseg.size()-1),copy_graph);
+	    while(stop != true)
+	    {
+	    	if(contraction == "HEM")
+				stop = contraction_HEM_degree(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
+	    		//stop = contraction_HEM(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
+	    	else
+	    		stop = contraction_Random_Maching(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
+	        cpt++;
+	    }
 	
 	
-	if(rec == true){
-		std::ofstream GRAPH ("../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/contraction_final.txt", std::ios::out);
-		GRAPH<<"graph G {"<<std::endl;   
+		/*std::cout<<"Graphe contracté : "<<std::endl;
 		tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-1));
 		tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-1));
 		for (; vertexIt != vertexEnd; ++vertexIt) {
 		for (; vertexIt != vertexEnd; ++vertexIt) {
-			GRAPH<<(*baseg.at(baseg.size()-1))[*vertexIt]._index<<" -- {";
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-					*baseg.at(baseg.size()-1));
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				if((*baseg.at(baseg.size()-1))[*neighbourIt]._index>(*baseg.at(baseg.size()-1))[*vertexIt]._index)
-					GRAPH<<(*baseg.at(baseg.size()-1))[*neighbourIt]._index<<";";
-			}
-			GRAPH<<"}"<<std::endl;
-		}   
+		std::cout << (*baseg.at(baseg.size()-1))[*vertexIt]._index
+				<< " est connecté avec ";
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+				*baseg.at(baseg.size()-1));
+		for (; neighbourIt != neighbourEnd; ++neighbourIt)
+			std::cout << (*baseg.at(baseg.size()-1))[*neighbourIt]._index << " ";
+		std::cout << " et son poids est de "
+				<< (*baseg.at(baseg.size()-1))[*vertexIt]._weight<<std::endl;
+				}
+		std::cout << std::endl;*/
+	    
+	    if(rec == true){
+			std::ofstream GRAPHp ("../../sortie_graphe/Tests/Graphes/Evolution_bissection/poids_graphe.txt", std::ios::out);
+			GRAPHp<<"Poids du graphe contracté : "<<std::endl;   
+			tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-1));
+			for (; vertexIt != vertexEnd; ++vertexIt) {
+				GRAPHp<<(*baseg.at(baseg.size()-1))[*vertexIt]._index<<" --> "<<(*baseg.at(baseg.size()-1))[*vertexIt]._weight<<std::endl;;
+			}   
+			GRAPHp<<"}";	
+			GRAPHp.close();
+		}
+	
+	    //double t2 = t.elapsed();
+	    //std::cout << "C : " << t2 << " ; ";
+	    
+	    for(uint i = 0; i<num_vertices(*baseg.at(baseg.size() - 1)); i++){
+			part->push_back(i);
+		}
+		Partition.push_back(part);
 		
 		
-		GRAPH<<"}";	
-		GRAPH.close();
-	}
-    
-    if(type_methode == "gggp" || type_methode == "ggp"){
-		bissectionRec(baseg.at(baseg.size()-1),Partition,nbr_parties,type_cut,nbr_tirage,type_methode, distance);
-		double tcut = Cut_cluster(Partition,copy_graph,type_cut);
-		/*std::cout<<tcut<<std::endl;
-		std::cout<<"Meilleur coût de coupe : "<<best_cut<<std::endl;
-		std::cout<<std::endl;*/
-    }
-    else
-    	Partition = Random_partitioning(baseg.at(baseg.size()-1),nbr_parties);
-    
-    double t3 = t.elapsed();
-    std::cout << "Partitioning duration : " << (t3 - t2) << " seconds" << std::endl;
-    
-    if(rec == true){
-		std::ofstream GRAPH3 ("../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/contraction_final_partition.txt", std::ios::out);
-		GRAPH3<<"graph G {"<<std::endl;   
-		tie(vertexIt, vertexEnd) = vertices(copy_graph);
-		for (; vertexIt != vertexEnd; ++vertexIt) {
-			GRAPH3<<(copy_graph)[*vertexIt]._index<<" -- {";
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-			copy_graph);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				if((copy_graph)[*neighbourIt]._index>(copy_graph)[*vertexIt]._index)
-				GRAPH3<<(copy_graph)[*neighbourIt]._index<<";";
-			}
-			GRAPH3<<"}"<<std::endl;
-		}   
+		UnorientedGraph copy_graph;
+		boost::copy_graph(*baseg.at(baseg.size()-1),copy_graph);
 		
 		
-		for(uint k=0; k<Partition.size(); k++){
-			for(uint j=0; j<Partition.at(k)->size(); j++)
-			{
-	     		GRAPH3<<(copy_graph)[Partition.at(k)->at(j)]._index<<color.at(k)<<std::endl;
-			}
+		if(rec == true){
+			Plot_UnorientedGraph_All(baseg.at(baseg.size()-1),Partition,"../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/contraction_final.txt", false);
+		}
+	    
+	    if(type_methode == "gggp" || type_methode == "ggp"){
+			bissectionRec(baseg.at(baseg.size()-1),Partition,nbr_parties,type_cut,nbr_tirage,type_methode, distance);
+	    }
+	    else
+	    	Partition = Random_partitioning(baseg.at(baseg.size()-1),nbr_parties);
+	    
+	    //double t3 = t.elapsed();
+	    //std::cout << "P : " << (t3 - t2) << " ; ";
+	    
+	    if(rec == true){
+			Plot_UnorientedGraph_All(&copy_graph,Partition,"../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/contraction_final_partition.txt", true);
+		}
+				
+		double poids_moy = 0.;
+		for(uint i =0; i < Partition.size(); i++){
+			poids_moy += Cluster_Weight(copy_graph,*Partition.at(i));
+		}
+		poids_moy/=Partition.size();
+		
+		poids_moy = -1;
+		
+		/*poids_moy = -1 implique un respect du poids faible*/
+		
+	    ListEntiersEntiers::iterator lit(liste_corr.end());
+	    bool proj;
+	    uint taille_list = liste_corr.size();
+	    if(liste_corr.size()==0){
+	    	taille_list = 1;
+	    	proj = true;
+	    }
+	    else{
+	    	lit--;
+	    	proj = false;
 	    }
 	    }
 	
 	
-		GRAPH3<<"}";	
-		GRAPH3.close();
-	}
-			
-	double poids_moy = 0.;
-	for(uint i =0; i < Partition.size(); i++){
-		poids_moy += Cluster_Weight(copy_graph,*Partition.at(i));
-	}
-	poids_moy/=Partition.size();
-	
-	poids_moy = -1;
-	
-	/*poids_moy = -1 implique un respect du poids faible*/
+		//std::cout<<"Nombre de contraction : "<<taille_list<<std::endl;
+		std::vector<const char* > nom;
+		std::vector<const char* > nom_a;
+		if(rec == true){
+			const char * tmp_nom1 = new const char();
+			tmp_nom1 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_1.txt";
+			nom.push_back(tmp_nom1);
+			const char * tmp_nom_a1 = new const char();
+			tmp_nom_a1 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_1.txt";
+			nom_a.push_back(tmp_nom_a1);
+			const char * tmp_nom2 = new const char();
+			tmp_nom2 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_2.txt";
+			nom.push_back(tmp_nom2);
+			const char * tmp_nom_a2 = new const char();
+			tmp_nom_a2 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_2.txt";
+			nom_a.push_back(tmp_nom_a2);
+			const char * tmp_nom3 = new const char();
+			tmp_nom3= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_3.txt";
+			nom.push_back(tmp_nom3);
+			const char * tmp_nom_a3 = new const char();
+			tmp_nom_a3 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_3.txt";
+			nom_a.push_back(tmp_nom_a3);
+			const char * tmp_nom4 = new const char();
+			tmp_nom4= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_4.txt";
+			nom.push_back(tmp_nom4);
+			const char * tmp_nom_a4 = new const char();
+			tmp_nom_a4 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_4.txt";
+			nom_a.push_back(tmp_nom_a4);
+			const char * tmp_nom5 = new const char();
+			tmp_nom5= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_5.txt";
+			nom.push_back(tmp_nom5);
+			const char * tmp_nom_a5 = new const char();
+			tmp_nom_a5 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_5.txt";
+			nom_a.push_back(tmp_nom_a5);
+			const char * tmp_nom6 = new const char();
+			tmp_nom6= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_6.txt";
+			nom.push_back(tmp_nom6);
+			const char * tmp_nom_a6 = new const char();
+			tmp_nom_a6 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_6.txt";
+			nom_a.push_back(tmp_nom_a6);
+			const char * tmp_nom7 = new const char();
+			tmp_nom7= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_7.txt";
+			nom.push_back(tmp_nom7);
+			const char * tmp_nom_a7 = new const char();
+			tmp_nom_a7 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_7.txt";
+			nom_a.push_back(tmp_nom_a7);
+			const char * tmp_nom8 = new const char();
+			tmp_nom8= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_8.txt";
+			nom.push_back(tmp_nom8);
+			const char * tmp_nom_a8 = new const char();
+			tmp_nom_a8 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_8.txt";
+			nom_a.push_back(tmp_nom_a8);
+			const char * tmp_nom9 = new const char();
+			tmp_nom9= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_9.txt";
+			nom.push_back(tmp_nom9);
+			const char * tmp_nom_a9 = new const char();
+			tmp_nom_a9 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_9.txt";
+			nom_a.push_back(tmp_nom_a9);
+			const char * tmp_nom10 = new const char();
+			tmp_nom10= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_10.txt";
+			nom.push_back(tmp_nom10);
+			const char * tmp_nom_a10 = new const char();
+			tmp_nom_a10 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_10.txt";
+			nom_a.push_back(tmp_nom_a10);
+			const char * tmp_nom11 = new const char();
+			tmp_nom11= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_11.txt";
+			nom.push_back(tmp_nom11);
+			const char * tmp_nom_a11 = new const char();
+			tmp_nom_a11 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_11.txt";
+			nom_a.push_back(tmp_nom_a11);
+			const char * tmp_nom12 = new const char();
+			tmp_nom12= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_12.txt";
+			nom.push_back(tmp_nom12);
+			const char * tmp_nom_a12 = new const char();
+			tmp_nom_a12 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_12.txt";
+			nom_a.push_back(tmp_nom_a12);
+			const char * tmp_nom13 = new const char();
+			tmp_nom13= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_13.txt";
+			nom.push_back(tmp_nom13);
+			const char * tmp_nom_a13 = new const char();
+			tmp_nom_a13 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_13.txt";
+			nom_a.push_back(tmp_nom_a13);
+			const char * tmp_nom14 = new const char();
+			tmp_nom14= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_14.txt";
+			nom.push_back(tmp_nom14);
+			const char * tmp_nom_a14 = new const char();
+			tmp_nom_a14 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_14.txt";
+			nom_a.push_back(tmp_nom_a14);
+			const char * tmp_nom15 = new const char();
+			tmp_nom15= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_15.txt";
+			nom.push_back(tmp_nom15);
+			const char * tmp_nom_a15 = new const char();
+			tmp_nom_a15 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_15.txt";
+			nom_a.push_back(tmp_nom_a15);
+			const char * tmp_nom16 = new const char();
+			tmp_nom16= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_16.txt";
+			nom.push_back(tmp_nom16);
+			const char * tmp_nom_a16 = new const char();
+			tmp_nom_a16 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_16.txt";
+			nom_a.push_back(tmp_nom_a16);
+		}
+	    for(uint y =0; y<taille_list;y++){
+	    	if(proj != true){
+	    		projection(Partition,lit);
+	    		if(rec == true){
+					Plot_UnorientedGraph_All(baseg.at(baseg.size()-2-y),Partition,nom.at(y), true);
+				}
 	
 	
-    ListEntiersEntiers::iterator lit(liste_corr.end());
-    bool proj;
-    uint taille_list = liste_corr.size();
-    if(liste_corr.size()==0){
-    	taille_list = 1;
-    	proj = true;
-    }
-    else{
-    	lit--;
-    	proj = false;
-    }
-
-	//std::cout<<"Nombre de contraction : "<<taille_list<<std::endl;
-	std::vector<char* > nom;
-	std::vector<char* > nom_a;
-	if(rec == true){
-		char * tmp_nom1 = new char();
-		tmp_nom1 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_1.txt";
-		nom.push_back(tmp_nom1);
-		char * tmp_nom_a1 = new char();
-		tmp_nom_a1 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_1.txt";
-		nom_a.push_back(tmp_nom_a1);
-		char * tmp_nom2 = new char();
-		tmp_nom2 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_2.txt";
-		nom.push_back(tmp_nom2);
-		char * tmp_nom_a2 = new char();
-		tmp_nom_a2 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_2.txt";
-		nom_a.push_back(tmp_nom_a2);
-		char * tmp_nom3 = new char();
-		tmp_nom3= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_3.txt";
-		nom.push_back(tmp_nom3);
-		char * tmp_nom_a3 = new char();
-		tmp_nom_a3 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_3.txt";
-		nom_a.push_back(tmp_nom_a3);
-		char * tmp_nom4 = new char();
-		tmp_nom4= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_4.txt";
-		nom.push_back(tmp_nom4);
-		char * tmp_nom_a4 = new char();
-		tmp_nom_a4 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_4.txt";
-		nom_a.push_back(tmp_nom_a4);
-		char * tmp_nom5 = new char();
-		tmp_nom5= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_5.txt";
-		nom.push_back(tmp_nom5);
-		char * tmp_nom_a5 = new char();
-		tmp_nom_a5 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_5.txt";
-		nom_a.push_back(tmp_nom_a5);
-		char * tmp_nom6 = new char();
-		tmp_nom6= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_6.txt";
-		nom.push_back(tmp_nom6);
-		char * tmp_nom_a6 = new char();
-		tmp_nom_a6 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_6.txt";
-		nom_a.push_back(tmp_nom_a6);
-		char * tmp_nom7 = new char();
-		tmp_nom7= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_7.txt";
-		nom.push_back(tmp_nom7);
-		char * tmp_nom_a7 = new char();
-		tmp_nom_a7 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_7.txt";
-		nom_a.push_back(tmp_nom_a7);
-		char * tmp_nom8 = new char();
-		tmp_nom8= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_8.txt";
-		nom.push_back(tmp_nom8);
-		char * tmp_nom_a8 = new char();
-		tmp_nom_a8 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_8.txt";
-		nom_a.push_back(tmp_nom_a8);
-		char * tmp_nom9 = new char();
-		tmp_nom9= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_9.txt";
-		nom.push_back(tmp_nom9);
-		char * tmp_nom_a9 = new char();
-		tmp_nom_a9 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_9.txt";
-		nom_a.push_back(tmp_nom_a9);
-		char * tmp_nom10 = new char();
-		tmp_nom10= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_10.txt";
-		nom.push_back(tmp_nom10);
-		char * tmp_nom_a10 = new char();
-		tmp_nom_a10 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_10.txt";
-		nom_a.push_back(tmp_nom_a10);
-		char * tmp_nom11 = new char();
-		tmp_nom11= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_11.txt";
-		nom.push_back(tmp_nom11);
-		char * tmp_nom_a11 = new char();
-		tmp_nom_a11 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_11.txt";
-		nom_a.push_back(tmp_nom_a11);
-		char * tmp_nom12 = new char();
-		tmp_nom12= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_12.txt";
-		nom.push_back(tmp_nom12);
-		char * tmp_nom_a12 = new char();
-		tmp_nom_a12 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_12.txt";
-		nom_a.push_back(tmp_nom_a12);
-		char * tmp_nom13 = new char();
-		tmp_nom13= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_13.txt";
-		nom.push_back(tmp_nom13);
-		char * tmp_nom_a13 = new char();
-		tmp_nom_a13 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_13.txt";
-		nom_a.push_back(tmp_nom_a13);
-		char * tmp_nom14 = new char();
-		tmp_nom14= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_14.txt";
-		nom.push_back(tmp_nom14);
-		char * tmp_nom_a14 = new char();
-		tmp_nom_a14 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_14.txt";
-		nom_a.push_back(tmp_nom_a14);
-		char * tmp_nom15 = new char();
-		tmp_nom15= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_15.txt";
-		nom.push_back(tmp_nom15);
-		char * tmp_nom_a15 = new char();
-		tmp_nom_a15 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_15.txt";
-		nom_a.push_back(tmp_nom_a15);
-		char * tmp_nom16 = new char();
-		tmp_nom16= "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_16.txt";
-		nom.push_back(tmp_nom16);
-		char * tmp_nom_a16 = new char();
-		tmp_nom_a16 = "../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/projection_partition_affine_16.txt";
-		nom_a.push_back(tmp_nom_a16);
-	}
-    for(uint y =0; y<taille_list;y++){
-    	if(proj != true){
-    		projection(Partition,lit);
-    		
-    		if(rec == true){
-	    		std::ofstream GRAPH2 (nom.at(y), std::ios::out);
-				GRAPH2<<"graph G {"<<std::endl;   
-				tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-2-y));
-				for (; vertexIt != vertexEnd; ++vertexIt) {
-					GRAPH2<<(*baseg.at(baseg.size()-2-y))[*vertexIt]._index<<" -- {";
-					tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-	    			*baseg.at(baseg.size()-2-y));
-					for (; neighbourIt != neighbourEnd; ++neighbourIt){
-						if((*baseg.at(baseg.size()-2-y))[*neighbourIt]._index>(*baseg.at(baseg.size()-2-y))[*vertexIt]._index)
-							GRAPH2<<(*baseg.at(baseg.size()-2-y))[*neighbourIt]._index<<";";
-					}
-					GRAPH2<<"}"<<std::endl;
-				}   
+	    		double cut = Cut_cluster(Partition,*baseg.at(baseg.size()-2-y),type_cut);
+	    		//std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
+	    		if(choix_affinage == "charge")
+	    			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
+	    		else if(choix_affinage == "locale"){
+	    			Affinage_recherche_locale(baseg.at(baseg.size()-2-y),Partition,cut,type_cut);}
+	    		else	
+	    			Affinache_gain_diff(baseg.at(baseg.size()-2-y), Partition, cut, type_cut, poids_moy);
+				//std::cout<<"Cout de coupe après affinage : "<<cut<<std::endl;
 				
 				
-				for(uint k=0; k<Partition.size(); k++){
-					for(uint j=0; j<Partition.at(k)->size(); j++)
-					{
-						GRAPH2<<(*baseg.at(baseg.size()-2-y))[Partition.at(k)->at(j)]._index<<color.at(k)<<std::endl;
-					}
+				if(rec == true){
+					Plot_UnorientedGraph_All(baseg.at(baseg.size()-2-y),Partition,nom_a.at(y), true);
 				}
 				}
-	    
-				GRAPH2<<"}";	
-				GRAPH2.close();
-			}
-
-    		double cut = Cut_cluster(Partition,*baseg.at(baseg.size()-2-y),type_cut);
-    		//std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
-    		if(choix_affinage == "charge")
-    			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
-    		else if(choix_affinage == "locale"){
-    			Affinage_recherche_locale(baseg.at(baseg.size()-2-y),Partition,cut,type_cut);}
-    		else	
-    			Affinache_gain_diff(baseg.at(baseg.size()-2-y), Partition, cut, type_cut, poids_moy);
-			//std::cout<<"Cout de coupe après affinage : "<<cut<<std::endl;
-			
-			if(rec == true){
-	    		std::ofstream GRAPH4 (nom_a.at(y), std::ios::out);
-				GRAPH4<<"graph G {"<<std::endl;   
-				tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-2-y));
-				for (; vertexIt != vertexEnd; ++vertexIt) {
-					GRAPH4<<(*baseg.at(baseg.size()-2-y))[*vertexIt]._index<<" -- {";
-					tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-	    			*baseg.at(baseg.size()-2-y));
-					for (; neighbourIt != neighbourEnd; ++neighbourIt){
-						if((*baseg.at(baseg.size()-2-y))[*neighbourIt]._index>(*baseg.at(baseg.size()-2-y))[*vertexIt]._index)
-							GRAPH4<<(*baseg.at(baseg.size()-2-y))[*neighbourIt]._index<<";";
-					}
-					GRAPH4<<"}"<<std::endl;
-				}   
 				
 				
-				for(uint k=0; k<Partition.size(); k++){
-					for(uint j=0; j<Partition.at(k)->size(); j++)
-					{
-						GRAPH4<<(*baseg.at(baseg.size()-2-y))[Partition.at(k)->at(j)]._index<<color.at(k)<<std::endl;
-					}
-				}
+	    		lit--;
+	    	}
+	
+	    }
+	    
+	    //double t4 = t.elapsed();
+	    //std::cout << "A : " << (t4 - t3) << std::endl;
+	    //std::cout << "Temps total : " << t4  << " seconds" << std::endl;
 	    
 	    
-				GRAPH4<<"}";	
-				GRAPH4.close();
+	   /*std::cout<<"Partition : "<<std::endl;
+		for(int x =0; x<Partition.size(); x++){
+			std::cout<<"*"<<x<<"* ";
+			for(int y =0; y<Partition.at(x)->size();y++){
+				std::cout<<Partition.at(x)->at(y)<<" ";
 			}
 			}
-			
-    		lit--;
-    	}
-    	else{
-    		//std::cout<<"Pas de projection "<<std::endl;
-    	}
-
-    }
-    
-    double t4 = t.elapsed();
-    std::cout << "Affinage duration : " << (t4 - t3) << " seconds" << std::endl;
-    
-    /*std::cout<<"Partition : "<<std::endl;
-	for(int x =0; x<Partition.size(); x++){
-		std::cout<<"*"<<x<<"* ";
-		for(int y =0; y<Partition.at(x)->size();y++){
-			std::cout<<Partition.at(x)->at(y)<<" ";
+			std::cout<<std::endl;
 		}
 		}
 		std::cout<<std::endl;
 		std::cout<<std::endl;
-	}
-	std::cout<<std::endl;*/
+		
+		for(uint i =0; i < Partition.size(); i++){
+			std::cout<<"Poids partie "<<i<<" : "<<Cluster_Weight(*g,*Partition.at(i))<<std::endl;
+		}*/
+				
+		double best_cut = Cut_cluster(Partition,*g,type_cut);
+		//std::cout<<"Fct Obj : "<<best_cut<<std::endl;
+		Cut.push_back(best_cut);
+		
+		Graphes = Graph_Partition(Partition, go, g, outputedgelist,
+	                                             inputedgelist, connections);
+	                                             
+	}else{
+		for(uint i = 0; i<num_vertices(*g); i++){
+			part->push_back(i);
+		}
+		Partition.push_back(part);
+	
+		UnorientedGraph *copie_g = new UnorientedGraph();
+		boost::copy_graph(*g,*copie_g);
+	    if(type_methode == "gggp" || type_methode == "ggp"){
+			bissectionRec(copie_g,Partition,nbr_parties,type_cut,nbr_tirage,type_methode, distance);
+		}
+		else
+			Partition = Random_partitioning(copie_g,nbr_parties);
 			
 			
-	double best_cut = Cut_cluster(Partition,*graph_origin,type_cut);
-	Cut.push_back(best_cut);
-
-    OrientedGraphs Graphes = Graph_Partition(Partition, go, graph_origin, outputedgelist,
+		double best_cut = Cut_cluster(Partition,*g,type_cut);
+		//std::cout<<"Fct Obj : "<<best_cut<<std::endl;
+		Cut.push_back(best_cut);
+		
+		Graphes = Graph_Partition(Partition, go, copie_g, outputedgelist,
                                              inputedgelist, connections);
                                              inputedgelist, connections);
-	
+	}
+    
 	if(rec == true){
 	if(rec == true){
-	    std::ofstream fichier2 ("../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/résultat_partitionnement.txt", std::ios::out);
-	    fichier2<<"digraph G {"<<std::endl;   
-	    tie(vertexIto, vertexEndo) = vertices(*go);
-	    for (; vertexIto != vertexEndo; ++vertexIto) {
-			fichier2<<(*go)[*vertexIto]._index<<"-> {";
-	    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-	    			*go);
-	    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-	    		fichier2<<(*go)[*neighbourIto]._index<<";";
-	    	}
-	    	fichier2<<"}"<<std::endl;
-		}
-	    
-	    for(uint k=0; k<Partition.size(); k++){
-			for(uint j=0; j<Partition.at(k)->size(); j++)
-			{
-	     		fichier2<<Partition.at(k)->at(j)<<color.at(k)<<std::endl;
-			}
-	    }   
-	    
-		fichier2<<"}";	
-		fichier2.close();
+		Plot_OrientedGraph(go,Partition,"../../sortie_graphe/Tests/Graphes/txt/Niveau_contraction/résultat_partitionnement.txt", true);
 	}
 	}
 
 
     for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
     for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
@@ -1015,6 +926,9 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
         delete *it;
         delete *it;
         *it = NULL;
         *it = NULL;
     }
     }
+    
+    //double t5 = t.elapsed();
+    //std::cout << "Devs : " << (t5 - t4)<<std::endl;
     return Graphes;
     return Graphes;
 }
 }
 
 
@@ -1027,11 +941,11 @@ void Optimisation_method_neighbour(UnorientedGraph *g, EntiersEntiers &Partition
 	double cut = 1000000000.;
 	double cut = 1000000000.;
 	//boost::copy_graph(*g,*copy_g_ref);
 	//boost::copy_graph(*g,*copy_g_ref);
 
 
-	for (int i=0 ; i<Partition.at(index_partition)->size() ; i++)
+	for (uint i=0 ; i<Partition.at(index_partition)->size() ; i++)
 		Random_list_vertices.push_back(i);
 		Random_list_vertices.push_back(i);
-	for (int j=0 ; j<Partition.at(index_partition)->size()-1 ; j++) {
-		int rand_pos = rand()%(Partition.at(index_partition)->size()-j)+j;
-		int tmp      = Random_list_vertices[j];
+	for (uint j=0 ; j<Partition.at(index_partition)->size()-1 ; j++) {
+		uint rand_pos = rand()%(Partition.at(index_partition)->size()-j)+j;
+		uint tmp      = Random_list_vertices[j];
 		Random_list_vertices[j] = Random_list_vertices[rand_pos];
 		Random_list_vertices[j] = Random_list_vertices[rand_pos];
 		Random_list_vertices[rand_pos] = tmp;
 		Random_list_vertices[rand_pos] = tmp;
 	}
 	}
@@ -1053,7 +967,7 @@ void Optimisation_method_neighbour(UnorientedGraph *g, EntiersEntiers &Partition
 		//boost::copy_graph(*g,*copy_g);
 		//boost::copy_graph(*g,*copy_g);
 
 
 		/*Recopie de la partie faisant l'objet de la bissection */
 		/*Recopie de la partie faisant l'objet de la bissection */
-		for(int t=0; t<Partition.at(index_partition)->size();t++){
+		for(uint t=0; t<Partition.at(index_partition)->size();t++){
 			tmp_part->push_back(Partition.at(index_partition)->at(t));
 			tmp_part->push_back(Partition.at(index_partition)->at(t));
 		}
 		}
 		
 		
@@ -1122,7 +1036,7 @@ void Optimisation_method_neighbour_distance(UnorientedGraph *g, EntiersEntiers &
 	int val;
 	int val;
 
 
 	std::list<int> vertex_list;
 	std::list<int> vertex_list;
-	for(int verx =0; verx<Partition.at(index_partition)->size(); verx++){
+	for(uint verx =0; verx<Partition.at(index_partition)->size(); verx++){
 		vertex_list.push_back(Partition.at(index_partition)->at(verx));
 		vertex_list.push_back(Partition.at(index_partition)->at(verx));
 	}
 	}
 	
 	
@@ -1159,7 +1073,7 @@ void Optimisation_method_neighbour_distance(UnorientedGraph *g, EntiersEntiers &
 		double new_cut;
 		double new_cut;
 
 
 		//Recopie de la partie faisant l'objet de la bissection 
 		//Recopie de la partie faisant l'objet de la bissection 
-		for(int t=0; t<Partition.at(index_partition)->size();t++){
+		for(uint t=0; t<Partition.at(index_partition)->size();t++){
 			tmp_part->push_back(Partition.at(index_partition)->at(t));
 			tmp_part->push_back(Partition.at(index_partition)->at(t));
 		}
 		}
 		
 		

+ 1 - 1
src/tests/boost_graph/partitioning/gggp.hpp

@@ -50,7 +50,7 @@ void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
 EntiersEntiers Random_partitioning(UnorientedGraph *g,
 EntiersEntiers Random_partitioning(UnorientedGraph *g,
                                 uint nbr_parties);
                                 uint nbr_parties);
 
 
-OrientedGraphs Multiniveau(uint niveau_contraction, UnorientedGraph *g, UnorientedGraph *graph_origin,
+OrientedGraphs Multiniveau(uint niveau_contraction, UnorientedGraph *g,
                            OrientedGraph *go, int nbr_parties, int nbr_tirage,
                            OrientedGraph *go, int nbr_parties, int nbr_tirage,
                            std::string contraction,
                            std::string contraction,
                            std::string type_methode,
                            std::string type_methode,

+ 82 - 0
src/tests/boost_graph/partitioning/graph_build.cpp

@@ -918,9 +918,91 @@ void build_generator_graph_linked(OrientedGraph *go, int nbr_vertex, int nbr_cou
 			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
 			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
 		}
 		}
 	}
 	}
+}
+
+void build_graph_grid(OrientedGraph *go, int side, std::vector<std::pair<int,int>> vertex_selection, Entiers weight_vertex,const char *edge_weight, bool rec){
+	int nbr_vertex = side*side;
+	std::vector<vertex_to> Vertexs;
+	for(int i =0; i<nbr_vertex; i++){
+		vertex_to vo = boost::add_vertex(*go);
+		Vertexs.push_back(vo);
+	}
+	
+	if(rec == true){
+		std::ofstream fichier (edge_weight, std::ios::out);
+		for(int i = 0; i<side; i++){
+			for(int j = 0; j<side-1; j++){
+				boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
+				fichier<<i*side+j<<" "<<i*side+j+1<<" "<<1<<" "<<std::endl;
+			}
+		}
+		
+		for(int i = 0; i<side-1; i++){
+			for(int j = 0; j<side; j++){
+				boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
+				fichier<<i*side+j<<" "<<(i+1)*side+j<<" "<<1<<" "<<std::endl;
+			}
+		}
+		fichier.close();
+	}else{
+		for(int i = 0; i<side; i++){
+			for(int j = 0; j<side-1; j++){
+				boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
+			}
+		}
+		
+		for(int i = 0; i<side-1; i++){
+			for(int j = 0; j<side; j++){
+				boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
+			}
+		}
+	}
+		
+	(*go)[0] = VertexProperties(0, 1, TOP_PIXEL);
+	for(uint i = 1; i<num_vertices(*go); i++){
+			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
+	}
+	
+	for(int ind=0; ind<vertex_selection.size(); ind++){
+		for(int ind_i = vertex_selection.at(ind).first; ind_i<vertex_selection.at(ind).second+1; ind_i++){
+			if(ind_i != 0)
+				(*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), NORMAL_PIXEL);
+			else
+				(*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), TOP_PIXEL);
+		}
+	}
 	
 	
+	if(rec == false){
+		std::ifstream fichier (edge_weight, std::ios::in);
+		
+		if(fichier){
+			bool found;
+			edge_to e1;
+			int edge1, edge2;
+			double edge_weight;
+			int lines = std::count(std::istreambuf_iterator<char>( fichier ),std::istreambuf_iterator<char>(),'\n' );
+			//std::cout<<lines<<std::endl;
+			int cpt =0;
+			int length;
+			fichier.seekg(0, std::ios::beg);
+			while(cpt < lines){
+			fichier >> edge1 >> edge2 >> edge_weight;
+			tie(e1,found)=edge(vertex(edge1,*go),vertex(edge2,*go),*go);
+			(*go)[e1] = EdgeProperties(edge_weight);
+			//std::cout<<edge1<<" "<<edge2<<" "<<edge_weight<<std::endl;
+			length = fichier.tellg();
+			fichier.seekg(length+1, std::ios::beg);
+			cpt++;
+			}
+			
+		}else{
+			std::cerr<<"Bugggggg du fichier txt !!!! "<<std::endl;
+		}
+		fichier.close();
+	}
 	
 	
 }
 }
 
 
+/*Vérification de la pondération + vérification des poids de la contraction + vérification de la structure de contraction*/
 
 
 } } } // namespace paradevs tests boost_graph
 } } } // namespace paradevs tests boost_graph

+ 2 - 0
src/tests/boost_graph/partitioning/graph_build.hpp

@@ -29,12 +29,14 @@
 
 
 #include <tests/boost_graph/partitioning/defs.hpp>
 #include <tests/boost_graph/partitioning/defs.hpp>
 #include <tests/boost_graph/partitioning/utils.hpp>
 #include <tests/boost_graph/partitioning/utils.hpp>
+#include <fstream>
 namespace paradevs { namespace tests { namespace boost_graph {
 namespace paradevs { namespace tests { namespace boost_graph {
 
 
 void build_graph(OrientedGraph& og, unsigned int edge_number);
 void build_graph(OrientedGraph& og, unsigned int edge_number);
 void build_generator_graph(OrientedGraph *go, int nbr_vertex, int nbr_source, int nbr_v_min, int nbr_v_max,const std::vector<int> &niveau);
 void build_generator_graph(OrientedGraph *go, int nbr_vertex, int nbr_source, int nbr_v_min, int nbr_v_max,const std::vector<int> &niveau);
 void build_generator_graph_linked(OrientedGraph *go, int nbr_vertex, int nbr_couche, int nbr_v_min, int nbr_v_max);
 void build_generator_graph_linked(OrientedGraph *go, int nbr_vertex, int nbr_couche, int nbr_v_min, int nbr_v_max);
 void build_graph_cyclique(OrientedGraph& og);
 void build_graph_cyclique(OrientedGraph& og);
+void build_graph_grid(OrientedGraph *go, int side,std::vector<std::pair<int,int>> vertex_selection, Entiers weight_vertex,const char *edge_weight, bool rec);
 //void build_corsen_graph(OrientedGraph& graph);
 //void build_corsen_graph(OrientedGraph& graph);
 
 
 } } } // namespace paradevs tests boost_graph;
 } } } // namespace paradevs tests boost_graph;

+ 195 - 238
src/tests/boost_graph/partitioning/main.cpp

@@ -42,300 +42,257 @@ OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
 
 
 int main()
 int main()
 {
 {
-    boost::timer t;
-
+	boost::timer t;
     srand((unsigned)time(NULL));
     srand((unsigned)time(NULL));
 
 
-	/*std::vector<std::pair < double, int >> tab_diff;
-	
-	for(int i =0; i<5; i++){
-		std::pair<double, int> diff(rand_fini(0,15)+0.426,i);
-		tab_diff.push_back(diff);
-		std::cout<<tab_diff.at(i).first<<" "<<tab_diff.at(i).second<<std::endl;
-	}
-	std::cout<<std::endl;
-	sort(tab_diff.begin(),tab_diff.end());
-	for(int i =0; i<5; i++){
-		std::cout<<tab_diff.at(i).first<<" "<<tab_diff.at(i).second<<std::endl;
-	}
-	
-	std::vector<int> Diff;
-	for(int i =0; i<tab_diff.size(); i++){
-		Diff.push_back(tab_diff.at(i).second);
-	}
-	
-	for(int i =0; i<tab_diff.size(); i++){
-		std::cout<<Diff.at(i)<<std::endl;
-	}*/
-	
-    OrientedGraph* go = new OrientedGraph();
-    /*UnorientedGraph graph_origin;
-    build_graph(*go, 11);
+    OrientedGraph *go = new OrientedGraph();
+    std::string type_cut = "ratio";
+    
+    int nbr_sommets = 1000;
+    int nbr_sources = nbr_sommets/100*1; // 1% des sommets sont des sources
+    Entiers niveau = {4,3,2};
+    //int nbr_couches = 150;//nbr_sommets*3/100;
+    
+    build_graph(*go, 38);
+    //build_generator_graph(go, nbr_sommets, nbr_sources , 2 , 5 ,niveau);
+    /*std::vector<std::pair<int,int>> vertex_selection;
+    std::pair<int,int> tmp;
+    tmp.first = 0;
+	tmp.second = 3;
+    vertex_selection.push_back(tmp);
+    Entiers weight_vertex;
+    weight_vertex.push_back(1);
+    const char *texte = new const char();
+    texte = "../../sortie_graphe/tests_grid.txt";
+    build_graph_grid(go, floor(sqrt(1000)), vertex_selection, weight_vertex,texte,true);*/
+    bool Spectrale = false;
     
     
+    /*EntiersEntiers toto;
+    Affichage_OrientedGraph(go);
+    Plot_OrientedGraph_All(go,toto,"../../sortie_graphe/Tests/Graphes/Contraction/txt/graphe.txt", false);
     UnorientedGraph *g = new UnorientedGraph();
     UnorientedGraph *g = new UnorientedGraph();
 	make_unoriented_graph(*go, *g);
 	make_unoriented_graph(*go, *g);
+	UnorientedGraph *copy_graphe = new UnorientedGraph();
+	boost::copy_graph(*g,*copy_graphe);
+	Base_Graph baseg1, baseg2;
+	ListEntiersEntiers liste_corr1, liste_corr2;
+	int val_cpt = num_vertices(*g);
+	int val_cpt2 = num_vertices(*g);
+	baseg1.push_back(g);
+	baseg2.push_back(copy_graphe);*/
 	
 	
-    EntiersEntiers Partition;
-    Entiers *part1 = new Entiers();
-    Entiers *part2 = new Entiers();
-    for(uint i = 0; i<11; i ++){
-		part1->push_back(i);
-	}
-    Partition.push_back(part1);
-    
-	int node = 1;
-	int index = 0;
-    gggp_pond(g, part1, part2, Partition, node, index, "cut", 2);
-    Partition.push_back(part2);
-    
-    double cut = Cut_cluster(Partition, *g, "cut");
-    
-    for(int x =0; x<Partition.size(); x++){
-		std::cout<<"** ";
-		for(int y =0; y<Partition.at(x)->size();y++){
-			std::cout<<Partition.at(x)->at(y)<<" ";
-		}
-		std::cout<<std::endl;
-	}
-	std::cout<<std::endl;
+	/*std::vector<const char* > nom;
+	const char * tmp_nom1 = new const char();
+	tmp_nom1 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_0.txt";
+	nom.push_back(tmp_nom1);
+	const char * tmp_nom2 = new const char();
+	tmp_nom2 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_1.txt";
+	nom.push_back(tmp_nom2);
+	const char * tmp_nom3 = new const char();
+	tmp_nom3 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_2.txt";
+	nom.push_back(tmp_nom3);
+	const char * tmp_nom4 = new const char();
+	tmp_nom4 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_3.txt";
+	nom.push_back(tmp_nom4);
+	const char * tmp_nom5 = new const char();
+	tmp_nom5= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_4.txt";
+	nom.push_back(tmp_nom5);
+	const char * tmp_nom6 = new const char();
+	tmp_nom6= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_5.txt";
+	nom.push_back(tmp_nom6);
+	const char * tmp_nom7 = new const char();
+	tmp_nom7= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_6.txt";
+	nom.push_back(tmp_nom7);
+	const char * tmp_nom8 = new const char();
+	tmp_nom8= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_7.txt";
+	nom.push_back(tmp_nom8);
+	const char * tmp_nom9 = new const char();
+	tmp_nom9= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_8.txt";
+	nom.push_back(tmp_nom9);
+	const char * tmp_nom10 = new const char();
+	tmp_nom10= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_9.txt";
+	nom.push_back(tmp_nom10);
 	
 	
-	std::cout<<"cut : "<<cut<<std::endl;
+	std::vector<const char* > noma;
+	const char * tmp_noma1 = new const char();
+	tmp_noma1 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_0n.txt";
+	noma.push_back(tmp_noma1);
+	const char * tmp_noma2 = new const char();
+	tmp_noma2 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_1n.txt";
+	noma.push_back(tmp_noma2);
+	const char * tmp_noma3 = new const char();
+	tmp_noma3 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_2n.txt";
+	noma.push_back(tmp_noma3);
+	const char * tmp_noma4 = new const char();
+	tmp_noma4 = "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_3n.txt";
+	noma.push_back(tmp_noma4);
+	const char * tmp_noma5 = new const char();
+	tmp_noma5= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_4n.txt";
+	noma.push_back(tmp_noma5);
+	const char * tmp_noma6 = new const char();
+	tmp_noma6= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_5n.txt";
+	noma.push_back(tmp_noma6);
+	const char * tmp_noma7 = new const char();
+	tmp_noma7= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_6n.txt";
+	noma.push_back(tmp_noma7);
+	const char * tmp_noma8 = new const char();
+	tmp_noma8= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_7n.txt";
+	noma.push_back(tmp_noma8);
+	const char * tmp_noma9 = new const char();
+	tmp_noma9= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_8n.txt";
+	noma.push_back(tmp_noma9);
+	const char * tmp_noma10 = new const char();
+	tmp_noma10= "../../sortie_graphe/Tests/Graphes/Contraction/txt/niveau_9n.txt";
+	noma.push_back(tmp_noma10);
 	
 	
-	for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
+	std::cout<<"Contraction "<<std::endl;
+    double t1 = t.elapsed();
+    std::cout<<"temps construction : "<<t1<<std::endl;
+    
+	bool truc1 = false;
+	int cpt = 0;
+    while(truc1 != true)
     {
     {
-        delete *it;
-        *it = NULL;
+    	truc1 = contraction_HEM(baseg2.at(cpt), baseg2, liste_corr2, 100, val_cpt2);
+        cpt++;
+        std::cout<<num_vertices(*baseg2.at(cpt))<<std::endl;
+        //Plot_UnorientedGraph_All(baseg2.at(cpt),toto,noma.at(cpt), true);
+        double poids_total = Total_weight_edges(baseg2.at(cpt));
+        std::cout<<"Contraction "<<cpt<<"  Poids Total : "<<poids_total<<std::endl;
     }
     }
+   
+    double t2 = t.elapsed();
+    std::cout<<"temps HEM : "<<t2-t1<<std::endl;
     
     
-    EntiersEntiers Partition2;
-	Entiers *part3 = new Entiers();
-    Entiers *part4 = new Entiers();
+    bool truc2 = false;
+	cpt = 0;
+	
+	while(truc2 != true)
+    {
+    	truc2 = contraction_HEM_degree(baseg1.at(cpt), baseg1, liste_corr1, 100, val_cpt);
+        cpt++;
+        std::cout<<num_vertices(*baseg1.at(cpt))<<std::endl;
+        //Plot_UnorientedGraph_All(baseg1.at(cpt),toto,nom.at(cpt), true);
+        double poids_total = Total_weight_edges(baseg1.at(cpt));
+        std::cout<<"Contraction "<<cpt<<"  Poids Total : "<<poids_total<<std::endl;
+    }
     
     
-    for(uint i = 0; i<11; i ++){
-		part3->push_back(i);
-	}
-    Partition2.push_back(part3);
-
-    gggp_pond(g, part3, part4, Partition2, node, index, "ratio", 2);
-    Partition2.push_back(part4);
+    double t3 = t.elapsed();
+    std::cout<<"temps HEM tests: "<<t3-t2<<std::endl; 
     
     
-	cut = Cut_cluster(Partition2, *g, "ratio");
+    int size = baseg1.size();
+    std::cout<<"taille de la base de graphe : "<<size<<std::endl;
     
     
-    for(int x =0; x<Partition2.size(); x++){
-		std::cout<<"** ";
-		for(int y =0; y<Partition2.at(x)->size();y++){
-			std::cout<<Partition2.at(x)->at(y)<<" ";
-		}
-		std::cout<<std::endl;
-	}
-	std::cout<<std::endl;
-	
-	std::cout<<"cut : "<<cut<<std::endl;
-	
-	for(EntiersEntiers::iterator it = Partition2.begin(); it != Partition2.end(); it++)
+    for(Base_Graph::iterator it = baseg1.begin(); it != baseg1.end(); it++)
     {
     {
         delete *it;
         delete *it;
         *it = NULL;
         *it = NULL;
-    }*/
-
-    std::vector<std::string> color;
-    color.push_back("node [color=lightblue2, style=filled];");
-    color.push_back("node [color=red, style=filled];");
-    color.push_back("node [color=limegreen, style=filled];");
-    color.push_back("node [color=plum, style=filled];");
-    color.push_back("node [color=orange, style=filled];");
-    color.push_back("node [color=yellow2, style=filled];");
-    color.push_back("node [color=slateblue1, style=filled];");
-    color.push_back("node [color=plum, style=filled];");
-    color.push_back("node [color=black, style=filled];");
-    color.push_back("node [color=dimgrey, style=filled];");
-    color.push_back("node [color=gold, style=filled];");
-    color.push_back("node [color=indigo, style=filled];");
-    color.push_back("node [color=turquoise, style=filled];");
-    color.push_back("node [color=olive, style=filled];");
-    color.push_back("node [color=cyan, style=filled];");
-    color.push_back("node [color=crimson, style=filled];");
-    color.push_back("node [color=lightsalmon, style=filled];");
-    
+    }
     
     
-    int nbr_sommets = 10000;
-    int nbr_sources = nbr_sommets/100*1; // 1% des sommets sont des sources
-    Entiers niveau = {5,4,3,2};
+    for(Base_Graph::iterator it2 = baseg2.begin(); it2 != baseg2.end(); it2++)
+    {
+        delete *it2;
+        *it2 = NULL;
+    } 	
     
     
-    //build_graph(*go, 38);
-    //build_generator_graph(go, nbr_sommets, nbr_sources , 2 , 3 ,niveau);
-    build_generator_graph_linked(go, nbr_sommets, 100 , 2, 3);
+    //build_generator_graph_linked(go, nbr_sommets, nbr_couches , 2, 3);
     //build_graph_cyclique(*go);
     //build_graph_cyclique(*go);
     //const char *texte = new const char();
     //const char *texte = new const char();
     //texte = "../../sortie_graphe/enregistrement_100.txt";
     //texte = "../../sortie_graphe/enregistrement_100.txt";
     //Text_generator_graph(texte,go);
     //Text_generator_graph(texte,go);
     //Graph_constructor_txt(texte, go);
     //Graph_constructor_txt(texte, go);
     
     
-    std::ofstream fichier ("../../sortie_graphe/Tests/Graphes/txt/graph_linked_200_30.txt", std::ios::out);
-    fichier<<"digraph G {"<<std::endl;
+   	/*bool found;
+	edge_to e1;
+    
     tie(vertexIto, vertexEndo) = vertices(*go);
     tie(vertexIto, vertexEndo) = vertices(*go);
     for (; vertexIto != vertexEndo; ++vertexIto) {
     for (; vertexIto != vertexEndo; ++vertexIto) {
-    	fichier<<(*go)[*vertexIto]._index<<"-> {";
-    	//std::cout<<(*go)[*vertexIto]._index<<" -> ";
+    	std::cout<<(*go)[*vertexIto]._index<<" -> ";
     	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
     	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
     			*go);
     			*go);
     	for (; neighbourIto != neighbourEndo; ++neighbourIto){
     	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-    		fichier<<(*go)[*neighbourIto]._index<<";";
-    		//std::cout<<(*go)[*neighbourIto]._index<<" ";
+			tie(e1,found)=edge(vertex(*vertexIto,*go),vertex(*neighbourIto,*go),*go);
+    		std::cout<<(*go)[*neighbourIto]._index<<" p = "<<(*go)[e1]._weight<<std::endl;	
     	}
     	}
-    	fichier<<"}"<<std::endl;
-    	//std::cout<<std::endl;
     }
     }
-	fichier<<"}";
-	fichier.close();
-	//std::cout<<std::endl;
-	
-
-	int nbr_parties = 50;
-	int niveau_contraction = num_vertices(*go)/50;
-	std::vector<double> Cut;
-	int nbr_tirage = 20;
+	std::cout<<std::endl;*/
 	
 	
-	for(uint i =0; i<nbr_tirage; i++){
-	Edges edge_partie;
-	OutputEdgeList outputedgeslist(nbr_parties);
-	InputEdgeList inputedgelist;
-	Connections connections;
+	/*** Comparaison des méthodes par étude du ratio de coupe ***/
+	/*if(Spectrale == true){
 	UnorientedGraph *g = new UnorientedGraph();
 	UnorientedGraph *g = new UnorientedGraph();
-	UnorientedGraph graph_origin;
 	make_unoriented_graph(*go, *g);
 	make_unoriented_graph(*go, *g);
-	boost::copy_graph(*g, graph_origin);
-
-	OrientedGraphs graphs = Multiniveau(niveau_contraction, g, &graph_origin, go, nbr_parties, 10,"HEM", "gggp",
-									"diff", "ratio", edge_partie ,
-									outputedgeslist, inputedgelist,
-									connections,false,Cut,2);  	
-									//std::cout<<std::endl;
-									//std::cout<<std::endl;				
-	}
+	EntiersEntiers Partition2;
 	
 	
-	//std::ofstream fichier_cut ("../../sortie_graphe/Tests/Cut/cut_s200_nc10_d0_c1_t10_p8_gggp.txt", std::ios::out);
-	double moy = 0.;
+	Affichage_UnorientedGraph(g);
 	
 	
-	for(int cpt = 0; cpt <Cut.size(); cpt ++){
-		//if(cpt!=Cut.size()-1)
-			//fichier_cut<<Cut.at(cpt)<<";";
-		//else
-			//fichier_cut<<Cut.at(cpt);
-		moy += Cut.at(cpt);
-		//std::cout<<Cut.at(cpt)<<std::endl;
-	}
-	//fichier_cut.close();
+	Partition2 = Spectral_Partition("../../Classif_R/Graphe/txt/Partition2.txt");
+	Plot_OrientedGraph(go,Partition2,"../../Classif_R/Graphe/txt/Spectral_Partition.txt", true);
+	Plot_OrientedGraph(go,Partition2,"../../Classif_R/Graphe/txt/toto.txt", false);*/
 	
 	
-	moy/= Cut.size();
-	std::cout<<moy<<std::endl;
+	/*std::cout<<"Partition2 : "<<std::endl;
+	for(int x =0; x<Partition2.size(); x++){
+		std::cout<<"*"<<x<<"* ";
+		for(int y =0; y<Partition2.at(x)->size();y++){
+			std::cout<<Partition2.at(x)->at(y)<<" ";
+		}
+		std::cout<<std::endl;
+	}
+	std::cout<<std::endl;*/
 	
 	
-    /*int nbr_parties = 20;
-    int nbr_sommets = 200;
-    int nbr_sources = nbr_sommets/100*1; // 1% des sommets sont des sources
-    const char *texte = new const char();
-    texte = "../../sortie_graphe/enregistrement_200.txt";
-    
-
-
-    //build_graph(*go, 38);
-    Entiers niveau = {2,2};
-    
-    //build_generator_graph(go, nbr_sommets, nbr_sources , 2 , 3 ,niveau);
-    
+	/*std::string type_cut = "ratio";
+    double best_cut = Cut_cluster(Partition2,*g,type_cut);
+    std::cout<<"Ratio cut Spectrale : "<<best_cut<<std::endl;
+    std::cout<<std::endl;
+	}*/
+	/*** ***/
 
 
-    //Text_generator_graph(texte,go);
-    Graph_constructor_txt(texte, go);
-	
-    //make_unoriented_graph(*go, *g);
-    
-    std::ofstream fichier ("../../sortie_graphe/Tests/arbre_s200_n22_tests.txt", std::ios::out);
-    fichier<<"digraph G {"<<std::endl;
-    tie(vertexIto, vertexEndo) = vertices(*go);
-    for (; vertexIto != vertexEndo; ++vertexIto) {
-    	fichier<<(*go)[*vertexIto]._index<<"-> {";
-    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-    			*go);
-    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-    		fichier<<(*go)[*neighbourIto]._index<<";";
-    	}
-    	fichier<<"}"<<std::endl;
-    }
-	fichier<<"}";
-	fichier.close();
-	
+	int nbr_parties = 4;
+	int niveau_contraction = num_vertices(*go)/2;
 	std::vector<double> Cut;
 	std::vector<double> Cut;
-	int niveau_contraction = num_vertices(*go)/1;
+	int nbr_tirage = 2;
 	
 	
-	for(uint i =0; i<500; i++){
+	for(uint i =1; i<nbr_tirage; i++){
 		Edges edge_partie;
 		Edges edge_partie;
 		OutputEdgeList outputedgeslist(nbr_parties);
 		OutputEdgeList outputedgeslist(nbr_parties);
 		InputEdgeList inputedgelist;
 		InputEdgeList inputedgelist;
 		Connections connections;
 		Connections connections;
-		UnorientedGraph *g = new UnorientedGraph();
-		make_unoriented_graph(*go, *g);
-		boost::copy_graph(*g, graph_origin);
-    
-		OrientedGraphs graphs = Multiniveau(niveau_contraction, g, &graph_origin, go, nbr_parties, 20,"HEM", "ggp",
-                                        "cut", "ratio", edge_partie ,
-                                        outputedgeslist, inputedgelist,
-                                        connections,Cut,4);  
-                                        
+		if(Spectrale == false){
+			UnorientedGraph *g = new UnorientedGraph();
+			make_unoriented_graph(*go, *g);
+			Adjacent_Matrix_Txt(g,"../../Classif_R/Graphe/txt/Madj.txt");
+			Weight_Matrix_Txt(g,"../../Classif_R/Graphe/txt/Mwei.txt");
+			OrientedGraphs graphs = Multiniveau(niveau_contraction, g, go, nbr_parties, 10 ,"HEM", "gggp",
+										"diff", type_cut, edge_partie ,
+										outputedgeslist, inputedgelist,
+										connections,true,Cut,2);  	
+										std::cout<<std::endl;
+		}else{
+			UnorientedGraph *g = new UnorientedGraph();
+			make_unoriented_graph(*go, *g);
+			OrientedGraphs graphs = Multiniveau(niveau_contraction, g, go, nbr_parties, num_vertices(*go)*2/100,"HEM", "gggp",
+										"diff", type_cut, edge_partie ,
+										outputedgeslist, inputedgelist,
+										connections,true,Cut,2);  	
+										std::cout<<std::endl;
+		}
 	}
 	}
-	
-	std::ofstream fichier_cut ("../../sortie_graphe/Tests/Cut/cut_s200_n22_d4-20_c1_t500_p20_ggp.txt", std::ios::out);
+	//std::ofstream fichier_cut ("../../sortie_graphe/Tests/Cut/cut_s200_nc10_d0_c1_t10_p8_gggp.txt", std::ios::out);
 	double moy = 0.;
 	double moy = 0.;
 	
 	
 	for(int cpt = 0; cpt <Cut.size(); cpt ++){
 	for(int cpt = 0; cpt <Cut.size(); cpt ++){
-		if(cpt!=Cut.size()-1)
-			fichier_cut<<Cut.at(cpt)<<";";
-		else
-			fichier_cut<<Cut.at(cpt);
+		//if(cpt!=Cut.size()-1)
+			//fichier_cut<<Cut.at(cpt)<<";";
+		//else
+			//fichier_cut<<Cut.at(cpt);
 		moy += Cut.at(cpt);
 		moy += Cut.at(cpt);
 		//std::cout<<Cut.at(cpt)<<std::endl;
 		//std::cout<<Cut.at(cpt)<<std::endl;
 	}
 	}
-	fichier_cut.close();
+	//fichier_cut.close();
 	
 	
 	moy/= Cut.size();
 	moy/= Cut.size();
-
-	
-	double etendu = *max_element(Cut.begin(),Cut.end()) - *min_element(Cut.begin(),Cut.end());
+	std::cout<<"Critère : "<<moy<<std::endl;
 	
 	
-	std::cout<<std::endl;
-	std::cout<<" *** Partitionnement en "<<nbr_parties<<" parties d'un graphe de taille "<<2000<<" *** "<<std::endl;
-	std::cout<<std::endl;
-	std::cout<<" === 1 tirage === "<<std::endl;
-	std::cout<<"Cout de coupe min : "<<*min_element(Cut.begin(),Cut.end())<<" "<<"Cout de coupe max : "<<*max_element(Cut.begin(),Cut.end())<<std::endl;
-	std::cout<<"Cout de coupe normalisé moyen : "<<moy<<std::endl;
-	std::cout<<"Étendu du coût de coupe : "<<etendu<<std::endl;
-    std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
-	std::cout << std::endl;*/
-	
-	     
-   /*for(int i =0; i<graphs.size(); i++){
-	    fichier2<<color.at(i)<<std::endl; C
-		tie(vertexIto, vertexEndo) = vertices(graphs.at(i));
-		for (; vertexIto != vertexEndo; ++vertexIto) {
-			fichier2<<(graphs.at(i))[*vertexIto]._index<<"-> {";
-			//std::cout<<(graphs.at(i))[*vertexIto]._index<<" est connecté avec : ";
-			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-					graphs.at(i));
-			for (; neighbourIto != neighbourEndo; ++neighbourIto){
-				fichier2<<(graphs.at(i))[*neighbourIto]._index<<";";
-				//std::cout<<(graphs.at(i))[*neighbourIto]._index<<" ";
-			}
-			fichier2<<"}"<<std::endl;
-			//std::cout<<std::endl;
-		}
-		fichier2<<std::endl;
-		//std::cout<<std::endl;
-	}
-	fichier2<<"}"<<std::endl;
-	fichier2.close();
-	
-
-
-	delete go;*/
+	delete go;
 	
 	
 	std::cout << "Duration : " << t.elapsed()/nbr_tirage << " seconds" << std::endl;
 	std::cout << "Duration : " << t.elapsed()/nbr_tirage << " seconds" << std::endl;
 	return 0;
 	return 0;

+ 1326 - 90
src/tests/boost_graph/partitioning/utils.cpp

@@ -56,6 +56,12 @@ struct myclass3
 	{ return i->size() > j->size(); }
 	{ return i->size() > j->size(); }
 } myobject_taille;
 } myobject_taille;
 
 
+struct myclass4
+{
+    bool operator() (int i, int j, UnorientedGraph *g)
+    { return (*g)[i]._weight > (*g)[j]._weight; }
+} mon_poids;
+
 /**
 /**
  * Fonction de verification de la connexité d'un graphe
  * Fonction de verification de la connexité d'un graphe
  * @param *g : adresse d'un graphe de type boost graphe undirected
  * @param *g : adresse d'un graphe de type boost graphe undirected
@@ -97,7 +103,7 @@ bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition, Entiers &part)
      * alors le graphe est connexe
      * alors le graphe est connexe
      */
      */
 
 
-    int val;
+    uint val;
     Entiers sommets;
     Entiers sommets;
 
 
     if(part.size()==1)
     if(part.size()==1)
@@ -105,7 +111,7 @@ bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition, Entiers &part)
     else
     else
         val=rand_fini(0,part.size()-1); //tirage aléatoire d'un sommets
         val=rand_fini(0,part.size()-1); //tirage aléatoire d'un sommets
 
 
-    int vertex = part.at(val);
+    uint vertex = part.at(val);
     sommets.push_back(vertex); //ajout du sommets à la lsite des sommets parcouru
     sommets.push_back(vertex); //ajout du sommets à la lsite des sommets parcouru
 
 
     /*
     /*
@@ -705,23 +711,788 @@ void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g, Entie
 				delete *it;
 				delete *it;
 				*it = NULL;
 				*it = NULL;
 			}
 			}
-			Partition = new_partition;
-			cut = coupe;
+			Partition = new_partition;
+			cut = coupe;
+		}
+		else
+		{
+			for(EntiersEntiers::iterator it = new_partition.begin(); it != new_partition.end(); it++)
+			{
+				delete *it;
+				*it = NULL;
+			}
+		}
+	}
+}
+
+bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Random_list_vertices;//, Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++)
+		Random_list_vertices.push_back(i);
+		//Index_Vertex.push_back(i);
+	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
+		int rand_pos = rand()%(nbr_vertex-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+	 
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
+	//std::cout<<std::endl;
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Random_list_vertices[i]; // Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<vertexs<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'index le plus petit
+				 */
+				double poids_a = 0.;
+				int best_vertexs = -1;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					if((*gtmp)[e1]._weight>poids_a){
+						best_vertexs = liste_voisin[j];
+						poids_a = (*gtmp)[e1]._weight;
+					}
+				}
+
+
+				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Random_list_vertices[i]=-1;
+				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
+				val_cpt--;
+				// std::cout<<val_cpt<<std::endl;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(i));
+				tableau_de_correspondance->push_back(couple);
+				Random_list_vertices[i]=-1;
+			}
+
+
+
+			/*std::cout<<"Poids noeud graphe contracté : "<<std::endl;
+			tie(vertexIt, vertexEnd) = vertices(*gtmp);
+			for (; vertexIt != vertexEnd; ++vertexIt) {
+				std::cout << (*gtmp)[*vertexIt]._index
+						<< " -> ";
+				std::cout << (*gtmp)[*vertexIt]._weight<<" ; ";
+			}
+			std::cout << std::endl;*/
+		}
+
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j <nbr_vertex; j++){
+				if(Random_list_vertices[j] !=-1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(j));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	// std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	// std::clog<<"Affichage avant tri "<<std::endl;
+	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
+	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+	// 	}
+	// 	std::cout<<"\n"<<std::endl;
+	// }
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+
+	// std::clog<<"Tableau de correspondance "<<std::endl;
+	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
+	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+	// 	}
+	// 	std::cout<<"\n"<<std::endl;
+	// }
+
+	liste_corr.push_back(tableau_de_correspondance);
+	// std::cout<<"\n"<<std::endl;
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+/*** Problème de segmentation avec cette méthode !!!  ***/
+bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Random_list_vertices, Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++){
+		Random_list_vertices.push_back(i);
+		Index_Vertex.push_back(i);}
+	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
+		int rand_pos = rand()%(nbr_vertex-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+	 
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
+	//std::cout<<std::endl;
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<vertexs<<" ça place est : "<<Random_list_vertices.at(i)<<" place : "<<i<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'index le plus petit
+				 */
+				double poids_a = -1.;
+				int best_vertexs = -1;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					if((*gtmp)[e1]._weight>poids_a){
+						best_vertexs = liste_voisin[j];
+						poids_a = (*gtmp)[e1]._weight;
+					}
+				}
+
+
+				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+				}
+				
+				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+				Index_Vertex.at(best_vertexs)=-1;
+				val_cpt--;
+				//std::cout<<std::endl;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(vertexs);
+				tableau_de_correspondance->push_back(couple);
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+			}
+
+
+
+			/*std::cout<<"Poids noeud graphe contracté : "<<std::endl;
+			tie(vertexIt, vertexEnd) = vertices(*gtmp);
+			for (; vertexIt != vertexEnd; ++vertexIt) {
+				std::cout << (*gtmp)[*vertexIt]._index
+						<< " -> ";
+				std::cout << (*gtmp)[*vertexIt]._weight<<" ; ";
+			}
+			std::cout << std::endl;*/
+		}
+
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j < nbr_vertex; j++){
+				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Index_Vertex.at(Random_list_vertices.at(j)));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	// std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	// std::clog<<"Affichage avant tri "<<std::endl;
+	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
+	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+	// 	}
+	// 	std::cout<<"\n"<<std::endl;
+	// }
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+
+	// std::clog<<"Tableau de correspondance "<<std::endl;
+	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
+	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+	// 	}
+	// 	std::cout<<"\n"<<std::endl;
+	// }
+
+	liste_corr.push_back(tableau_de_correspondance);
+	// std::cout<<"\n"<<std::endl;
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Random_list_vertices, Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++){
+		Random_list_vertices.push_back(i);
+		Index_Vertex.push_back(i);}
+	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
+		int rand_pos = rand()%(nbr_vertex-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+	 
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<Random_list_vertices.at(i)<<" place : "<<i<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'index le plus petit
+				 */
+				double poids_a = -1.;
+				int best_vertexs = -1;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					if((*gtmp)[e1]._weight>poids_a){
+						best_vertexs = liste_voisin[j];
+						poids_a = (*gtmp)[e1]._weight;
+					}
+				}
+
+				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				
+				/* Sélection  du sommet possedant un degrès maximum */
+				std::pair<double,int> couple1, couple2, best_min, best_max;
+				couple1.first = Degree(*gtmp,vertexs);
+				couple1.second = vertexs;
+				couple2.first = Degree(*gtmp,best_vertexs);
+				couple2.second = best_vertexs;
+				best_min = std::min(couple1,couple2);
+				best_max = std::max(couple1,couple2);
+				int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+				
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+				
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+						neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+						neigh_vertex_delete.push_back(*neighbourIt);
+				}
+				
+				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+				
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+				Index_Vertex.at(best_vertexs)=-1;
+				val_cpt--;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(vertexs);
+				tableau_de_correspondance->push_back(couple);
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+			}
+		}
+
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j < nbr_vertex; j++){
+				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Index_Vertex.at(Random_list_vertices.at(j)));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	 
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+	liste_corr.push_back(tableau_de_correspondance);
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+	
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+		
+}
+
+bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	std::vector<double> vertex_degree;
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	int cpt = nbr_vertex;
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	/*for (uint i=0 ; i<nbr_vertex ; i++){
+		Random_list_vertices.push_back(i);
+		Index_Vertex.push_back(i);}
+	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
+		int rand_pos = rand()%(nbr_vertex-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}*/
+	
+	for (uint i=0 ; i<nbr_vertex ; i++){
+		Index_Vertex.push_back(i);
+		vertex_degree.push_back(Degree(*g,i));
+	}
+	
+	while(cpt != 0){
+		double max_weight = *std::max_element(vertex_degree.begin(),vertex_degree.end());
+		int vertexs, compteur;
+		//std::cout<<"max_weight : "<<max_weight<<std::endl;
+		//Entiers Vertex_select;
+		for(uint id = 0; id <vertex_degree.size(); id++){
+			if(vertex_degree.at(id) == max_weight){
+				compteur = id;
+				vertexs = Index_Vertex.at(id);
+				break;
+			}	
+		}
+		//std::cout<<"min : "<<max_weight<<" - compteur : "<<(*gtmp)[compteur]._index;
+		
+		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<compteur<<std::endl;
+		Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+		if(liste_voisin.size() != 0){
+			/*
+			 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+			 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+			 * le même poids, on selectionne le sommet d'index le plus petit
+			 */
+			std::vector<double> Neight_weight, Best_neight;
+			int best_vertexs;
+			for(uint j=0;j<liste_voisin.size();j++){
+				tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+				Neight_weight.push_back((*gtmp)[e1]._weight);
+			}
+			
+			max_weight = *std::max_element(Neight_weight.begin(),Neight_weight.end());
+			for(uint j=0;j<liste_voisin.size();j++){
+				if(Neight_weight.at(j) == max_weight)
+					Best_neight.push_back(liste_voisin.at(j));
+			}
+			
+			if(Best_neight.size() > 1){
+				int ind;
+				double deg =1000000000;
+				double tmp_deg;
+				for(uint j=0;j<Best_neight.size();j++){
+					tmp_deg = Degree(*gtmp,Best_neight.at(j));
+					if(tmp_deg < deg){
+						deg = tmp_deg;
+						ind = j;
+					}
+				}
+				best_vertexs = Best_neight.at(ind);
+			}else{
+				best_vertexs = Best_neight.at(0);
+			}
+			
+			//std::cout<<" -> "<<(*gtmp)[best_vertexs]._index;
+			Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+			
+			/* Sélection  du sommet possedant un degrès maximum */
+			std::pair<double,int> couple1, couple2, best_min, best_max;
+			couple1.first = Degree(*gtmp,vertexs);
+			couple1.second = vertexs;
+			couple2.first = Degree(*gtmp,best_vertexs);
+			couple2.second = best_vertexs;
+			best_min = std::min(couple1,couple2);
+			best_max = std::max(couple1,couple2);
+			int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
+			//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+			int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
+			//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+			sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+			/*
+			 * On ajoute au tableau "couple" le couple de sommet à fusionner
+			 */
+			couple->push_back(vertex_save);
+			couple->push_back(vertex_delete);
+			tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+			remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+			
+			Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+			Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+			
+			/*
+			 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+			 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+			 * du processus]
+			 */
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+			}
+
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+			
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+			}
+			
+			sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+			sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+			
+			/*
+			 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+			 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+			 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+			 */
+			for(uint j=0;j<neigh_vertex_delete.size();j++){
+				if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
+					tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+					tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+					(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+					remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+				}
+				else
+				{
+					tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+					add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+					remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+				}
+			}
+
+			(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+			/*
+			 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+			 */
+			Index_Vertex.at(compteur)=-1;
+			vertex_degree.at(compteur)=-1;
+			Index_Vertex.at(best_vertexs)=-1;
+			vertex_degree.at(best_vertexs)=-1;
+			val_cpt--;
+			cpt -= 2;
+			//std::cout<<" ** "<<std::endl;
+			//std::cout<<cpt<<std::endl;
 		}
 		}
-		else
-		{
-			for(EntiersEntiers::iterator it = new_partition.begin(); it != new_partition.end(); it++)
-			{
-				delete *it;
-				*it = NULL;
+		else{
+			/*
+			 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+			 * alors on l'ajoute à la liste de correspondance des sommets et on
+			 * le verrouille
+			 */
+			Entiers *couple = new Entiers();
+			couple->push_back(vertexs);
+			tableau_de_correspondance->push_back(couple);
+			Index_Vertex.at(compteur)=-1;
+			vertex_degree.at(compteur)=-1;
+			cpt --;
+			//std::cout<<" * "<<std::endl;
+		}
+
+		if(val_cpt == val_reduc){
+			for(uint j=0; j < nbr_vertex; j++){
+				if(Index_Vertex.at(j) != -1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Index_Vertex.at(j));
+				tableau_de_correspondance->push_back(couple);}
 			}
 			}
+			break;
 		}
 		}
 	}
 	}
+
+	//std::cout<<"cpt : "<<cpt<<std::endl;
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	 
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+	liste_corr.push_back(tableau_de_correspondance);
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+	
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
 }
 }
 
 
-bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
-	UnorientedGraph *gtmp = new UnorientedGraph(*g);
-	Entiers Random_list_vertices; // Initialisation du tableau de sommets rangés aléatoirements
+bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Random_list_vertices, Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
 	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
 	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
 	edge_t e1,e2; // Iterateurs sur les arcs
 	edge_t e1,e2; // Iterateurs sur les arcs
 	bool found;
 	bool found;
@@ -731,8 +1502,9 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
 	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
 	 * aléatoirement afin de simuler un tirage aléatoire
 	 * aléatoirement afin de simuler un tirage aléatoire
 	 */
 	 */
-	for (uint i=0 ; i<nbr_vertex ; i++)
+	for (uint i=0 ; i<nbr_vertex ; i++){
 		Random_list_vertices.push_back(i);
 		Random_list_vertices.push_back(i);
+		Index_Vertex.push_back(i);}
 	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
 	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
 		int rand_pos = rand()%(nbr_vertex-j)+j;
 		int rand_pos = rand()%(nbr_vertex-j)+j;
 		int tmp      = Random_list_vertices[j];
 		int tmp      = Random_list_vertices[j];
@@ -743,33 +1515,97 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 	/*
 	/*
 	 * Pour chaque sommet non verrouiller faire ....
 	 * Pour chaque sommet non verrouiller faire ....
 	 */
 	 */
+	 
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
 	for(uint i=0; i<nbr_vertex; i++){
 	for(uint i=0; i<nbr_vertex; i++){
-		int vertexs = Random_list_vertices[i];
-		//std::cout<<"Le sommet tiré est : "<<vertexs<<std::endl;
+		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<Random_list_vertices.at(i)<<" place : "<<i<<std::endl;
 		if(vertexs!=-1){
 		if(vertexs!=-1){
-			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
+			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+			sort(liste_voisin.begin(),liste_voisin.end());
 			if(liste_voisin.size()!=0){
 			if(liste_voisin.size()!=0){
 				/*
 				/*
 				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
 				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
 				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
 				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
 				 * le même poids, on selectionne le sommet d'index le plus petit
 				 * le même poids, on selectionne le sommet d'index le plus petit
 				 */
 				 */
-				double poids_a = 0.;
-				int best_vertexs = -1;
+				/*std::cout<<"Le sommet tiré a des voisins "<<std::endl; 
+				for(uint id = 0; id<liste_voisin.size(); id++){
+					std::cout<<(*gtmp)[liste_voisin.at(id)]._index<<" "; 
+				}
+				std::cout<<std::endl;*/
+				double poids_a = -1.;
+				std::vector<double> adjacent_weight;
+				//std::cout<<"adjacent_weight"<<std::endl;
 				for(uint j=0;j<liste_voisin.size();j++){
 				for(uint j=0;j<liste_voisin.size();j++){
 					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
 					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
-					if((*gtmp)[e1]._weight>poids_a){
-						best_vertexs = liste_voisin[j];
-						poids_a = (*gtmp)[e1]._weight;
+					adjacent_weight.push_back((*gtmp)[e1]._weight);
+					//std::cout<<(*gtmp)[e1]._weight<<" ";
+				}
+				//std::cout<<std::endl;
+				//std::cout<<"Top *"<<std::endl;
+				double max_weight = *std::max_element(adjacent_weight.begin(),adjacent_weight.end());
+				//std::cout<<"max_weight : "<<max_weight<<std::endl;
+				Entiers Vertex_select;
+				for(uint id = 0; id <adjacent_weight.size(); id++){
+					if(adjacent_weight.at(id) == max_weight)
+						Vertex_select.push_back(liste_voisin.at(id));
+				}
+				
+				int index = 0;
+				if(Vertex_select.size()>1){
+					//std::cout<<"Top **"<<std::endl;
+					for(uint id = 0; id<Vertex_select.size(); id++){
+						suprim_val(liste_voisin,Vertex_select.at(id)); /*** modification possible ***/
+					}
+					
+					//std::cout<<"Top ***"<<std::endl;
+					adjacent_weight.clear();
+					for(uint id_Vs = 0; id_Vs<Vertex_select.size(); id_Vs++){
+						double neigh_weight = 0.;
+						for(uint id_Lv = 0; id_Lv<liste_voisin.size(); id_Lv++){
+							//std::cout<<"Top ***!"<<std::endl;
+							bool rep = Est_voisin(gtmp,liste_voisin.at(id_Lv),Vertex_select.at(id_Vs));
+							if(rep == true){
+								tie(e1,found)=edge(vertex(Vertex_select.at(id_Vs),*gtmp),vertex(liste_voisin.at(id_Lv),*gtmp),*gtmp);
+								//std::cout<<"Top ***!!"<<std::endl;
+								//std::cout<<e1<<std::endl;
+								//std::cout<<"Top ***!!!"<<std::endl;
+								neigh_weight += (*gtmp)[e1]._weight;
+							}
+							//std::cout<<"Top ***!!!!"<<std::endl;
+						}
+						adjacent_weight.push_back(neigh_weight);
+					}
+					
+					//std::cout<<"Top ****"<<std::endl;
+					max_weight = *std::max_element(adjacent_weight.begin(),adjacent_weight.end());
+					for(uint id = 0; id <adjacent_weight.size(); id++){
+						if(adjacent_weight.at(id) == max_weight){
+							index = id;	
+							break;
+						}
 					}
 					}
 				}
 				}
 
 
-
-				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
-				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'index le plus grand (qui sera détruit)
-				//std::cout<<"sommet détruit : "<<vertex_delete<<std::endl;
-				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
-				//std::cout<<"sommet sauvé : "<<vertex_save<<std::endl;
+				//std::cout<<"Index "<<index<<std::endl;
+				//std::cout<<"Top *****"<<std::endl;
+				int best_vertexs = Vertex_select.at(index);
+				//std::cout<<"Index "<<best_vertexs<<std::endl;
+				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				
+				/* Sélection  du sommet possedant un degrès maximum */
+				std::pair<double,int> couple1, couple2, best_min, best_max;
+				couple1.first = Degree(*gtmp,vertexs);
+				couple1.second = vertexs;
+				couple2.first = Degree(*gtmp,best_vertexs);
+				couple2.second = best_vertexs;
+				best_min = std::min(couple1,couple2);
+				best_max = std::max(couple1,couple2);
+				int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
 
 
 				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
 				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
 				/*
 				/*
@@ -780,32 +1616,35 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
 				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
 
 
 				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
 				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
-
+				
 				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
 				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
 				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
 				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
-
+				
 				/*
 				/*
 				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
 				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
 				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
 				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
 				 * du processus]
 				 * du processus]
 				 */
 				 */
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
 				for (; neighbourIt != neighbourEnd; ++neighbourIt){
 				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_save.push_back(*neighbourIt);
+						neigh_vertex_save.push_back(*neighbourIt);
 				}
 				}
 
 
 				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
 				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
 				for (; neighbourIt != neighbourEnd; ++neighbourIt){
 				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_delete.push_back(*neighbourIt);
+						neigh_vertex_delete.push_back(*neighbourIt);
 				}
 				}
-
+				
+				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+				
 				/*
 				/*
 				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
 				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
 				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
 				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
 				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
 				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
 				 */
 				 */
 				for(uint j=0;j<neigh_vertex_delete.size();j++){
 				for(uint j=0;j<neigh_vertex_delete.size();j++){
-					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
+					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
 						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
 						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
 						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
 						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
 						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
 						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
@@ -823,10 +1662,9 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 				/*
 				/*
 				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
 				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
 				 */
 				 */
-				Random_list_vertices[i]=-1;
-				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+				Index_Vertex.at(best_vertexs)=-1;
 				val_cpt--;
 				val_cpt--;
-				// std::cout<<val_cpt<<std::endl;
 			}
 			}
 			else{
 			else{
 				/*
 				/*
@@ -834,33 +1672,23 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 				 * alors on l'ajoute à la liste de correspondance des sommets et on
 				 * alors on l'ajoute à la liste de correspondance des sommets et on
 				 * le verrouille
 				 * le verrouille
 				 */
 				 */
+				//std::cout<<"Le sommet tiré est isolé "<<std::endl; 
 				Entiers *couple = new Entiers();
 				Entiers *couple = new Entiers();
-				couple->push_back(Random_list_vertices.at(i));
+				couple->push_back(vertexs);
 				tableau_de_correspondance->push_back(couple);
 				tableau_de_correspondance->push_back(couple);
-				Random_list_vertices[i]=-1;
-			}
-
-
-
-			/*std::cout<<"Graphe contracté : "<<std::endl;
-			tie(vertexIt, vertexEnd) = vertices(*gtmp);
-			for (; vertexIt != vertexEnd; ++vertexIt) {
-				std::cout << (*gtmp)[*vertexIt]._index
-						<< " est connecté avec ";
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-						*gtmp);
-				for (; neighbourIt != neighbourEnd; ++neighbourIt)
-					std::cout << (*gtmp)[*neighbourIt]._index << " ";
-				std::cout << " et son poids est de "
-						<< (*gtmp)[*vertexIt]._weight<<std::endl;
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
 			}
 			}
-			std::cout << std::endl;*/
+		}else{
+			//std::cout<<"Le sommet est bloqué "<<std::endl;
+			//std::cout<<" ça place est : "<<Random_list_vertices.at(i)<<" valeur : "<<Index_Vertex.at(Random_list_vertices.at(i))<<std::endl;
 		}
 		}
+
 		if(val_cpt == val_reduc){
 		if(val_cpt == val_reduc){
-			for(uint j=i+1; j <nbr_vertex; j++){
-				if(Random_list_vertices[j] !=-1){
+			//std::cout<<"Taille obtenue !"<<std::endl;
+			for(uint j=i+1; j < nbr_vertex; j++){
+				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
 				Entiers *couple = new Entiers();
 				Entiers *couple = new Entiers();
-				couple->push_back(Random_list_vertices.at(j));
+				couple->push_back(vertexs);
 				tableau_de_correspondance->push_back(couple);}
 				tableau_de_correspondance->push_back(couple);}
 			}
 			}
 			break;
 			break;
@@ -868,38 +1696,21 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 	}
 	}
 
 
 	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
 	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
-	// std::cout<<"\n"<<std::endl;
+
 	/*
 	/*
 	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
 	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
 	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
 	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
 	 * des sommets
 	 * des sommets
 	 */
 	 */
+	 
 	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
 	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
-		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
 		remove_vertex(sommets_a_detruire[j],*gtmp);
 		remove_vertex(sommets_a_detruire[j],*gtmp);
 	}
 	}
 
 
-	// std::clog<<"Affichage avant tri "<<std::endl;
-	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
-	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
-	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
-	// 	}
-	// 	std::cout<<"\n"<<std::endl;
-	// }
 	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
 	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
-
-	// std::clog<<"Tableau de correspondance "<<std::endl;
-	// for(uint k = 0;k<tableau_de_correspondance->size();k++){
-	// 	for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
-	// 		std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
-	// 	}
-	// 	std::cout<<"\n"<<std::endl;
-	// }
-
 	liste_corr.push_back(tableau_de_correspondance);
 	liste_corr.push_back(tableau_de_correspondance);
-	// std::cout<<"\n"<<std::endl;
 	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
 	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
-
+	
 	if(val_cpt == val_reduc)
 	if(val_cpt == val_reduc)
 		return true;
 		return true;
 	else
 	else
@@ -907,6 +1718,17 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 
 
 }
 }
 
 
+bool Est_voisin(UnorientedGraph *g, int vertex, int vertex_select){
+	bool reponse = false;
+	
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		if(*neighbourIt == vertex_select)
+			reponse = true;
+	}
+	return reponse;
+}
+
 bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
 bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
 	UnorientedGraph *gtmp = new UnorientedGraph();
 	UnorientedGraph *gtmp = new UnorientedGraph();
 	*gtmp=*g;
 	*gtmp=*g;
@@ -1087,6 +1909,16 @@ Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,const Entiers &random_ve
 	return liste_voisin;
 	return liste_voisin;
 }
 }
 
 
+Entiers Liste_adjacence_tests(UnorientedGraph &g, int vertexs,const Entiers &Index_Vertex){ // a revoir !!!!
+	Entiers liste_voisin;
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs, g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		if(Index_Vertex.at(*neighbourIt)!=-1)
+			liste_voisin.push_back(*neighbourIt);
+	}
+	return liste_voisin;
+}
+
 int rand_fini(int a, int b){
 int rand_fini(int a, int b){
 	return rand()%(b-a)+a;
 	return rand()%(b-a)+a;
 }
 }
@@ -1473,22 +2305,23 @@ double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, Entiers *
 	return cpt;
 	return cpt;
 }
 }
 
 
-/*double In_modularity(UnorientedGraph &g , const Entiers &cluster){
-	property_map<UnorientedGraph,edge_weight_t>::type poids_arc=get(edge_weight_t(),g);
+double In_modularity(UnorientedGraph *g , const Entiers &cluster){
+	//property_map<UnorientedGraph,edge_weight_t>::type poids_arc=get(edge_weight_t(),g);
 	edge_t e1;
 	edge_t e1;
 	bool found;
 	bool found;
 	int val=0;
 	int val=0;
 
 
 	for(uint i=0;i<cluster.size();i++){
 	for(uint i=0;i<cluster.size();i++){
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster[i],g);
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i),*g);
 		for (; neighbourIt != neighbourEnd; ++neighbourIt){
 		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
+			tie(e1,found)=edge(vertex(cluster[i],*g),vertex(*neighbourIt,*g),*g);
 			if(In_tab(cluster,*neighbourIt)==1)
 			if(In_tab(cluster,*neighbourIt)==1)
-				val+=get(poids_arc,e1);
+				val+=(*g)[e1]._weight;
+				//val+=get(poids_arc,e1);
 		}
 		}
 	}
 	}
 	return val/2.;
 	return val/2.;
-}*/
+}
 
 
 /**
 /**
  *
  *
@@ -1506,15 +2339,15 @@ double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, Entiers *
  * @return
  * @return
  */
  */
 
 
-/*double Modularity(UnorientedGraph &g,const EntiersEntiers &part) {
+double Modularity(UnorientedGraph *g,const EntiersEntiers &part){
   double q  = 0.;
   double q  = 0.;
-  int tmp=num_edges(g);
+  int tmp=num_edges(*g);
   for(uint i=0;i<part.size();i++){
   for(uint i=0;i<part.size();i++){
-	  q+=In_modularity(g,*part[i])/tmp-(Cluster_Degree(g,*part[i])/(2*tmp))*(Cluster_Degree(g,*part[i])/(2*tmp));
+	  q+=In_modularity(g,*part.at(i))/tmp-(Cluster_Degree(*g,*part.at(i))/(2*tmp))*(Cluster_Degree(*g,*part.at(i))/(2*tmp));
   	}
   	}
 
 
   return q;
   return q;
-}*/
+}
 
 
 /**
 /**
  *
  *
@@ -2032,16 +2865,23 @@ void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &
 		//std::cout<<"Boucle d'ammélioration "<<std::endl;
 		//std::cout<<"Boucle d'ammélioration "<<std::endl;
 		old_cut = cut;
 		old_cut = cut;
 		sort(Partition.begin(), Partition.end(), myobject_taille);
 		sort(Partition.begin(), Partition.end(), myobject_taille);
+		/*for(uint i=0;i<Partition.size();i++){
+			std::cout<<Partition.at(i)->size()<<std::endl;
+		}*/
 		std::vector<std::vector<int>> diff_vector;
 		std::vector<std::vector<int>> diff_vector;
 		diff_vector = Vector_diff_cut_ratio(g, Partition, name);
 		diff_vector = Vector_diff_cut_ratio(g, Partition, name);
 		
 		
+		/*for(uint i = 0; i<diff_vector.size(); i++){
+			std::cout<<diff_vector.at(i)<<std::endl;
+		}*/
+		
 		for(uint indice = 0; indice < diff_vector.size(); indice ++){
 		for(uint indice = 0; indice < diff_vector.size(); indice ++){
 			if(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1){
 			if(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1){
 				//for(uint i = 0; i < diff_vector.at(indice).size(); i++){
 				//for(uint i = 0; i < diff_vector.at(indice).size(); i++){
 				int i =0;
 				int i =0;
 				while(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1 && i < diff_vector.at(indice).size() && 
 				while(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1 && i < diff_vector.at(indice).size() && 
 				Cluster_Weight(*g,*Partition.at(indice)) > (poids_moy-poids_moy/Partition.size())){
 				Cluster_Weight(*g,*Partition.at(indice)) > (poids_moy-poids_moy/Partition.size())){
-					//std::cout<<"Sommet de départ : "<< diff_vector.at(indice).at(i) <<" dans "<<indice<<std::endl;
+					//std::cout<<"Sommet de départ : "<< (*g)[diff_vector.at(indice).at(i)]._index <<" dans "<<indice<<std::endl;
 					Entiers neigh_part;
 					Entiers neigh_part;
 					neigh_part = Neigh_community(g, Partition, diff_vector.at(indice).at(i), indice);
 					neigh_part = Neigh_community(g, Partition, diff_vector.at(indice).at(i), indice);
 					int best_neigh_part = neigh_part.at(0);
 					int best_neigh_part = neigh_part.at(0);
@@ -2290,6 +3130,402 @@ double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, int node, do
 	
 	
 	//std::cout<<"Nouveau ratio : " <<new_ratio<<std::endl;
 	//std::cout<<"Nouveau ratio : " <<new_ratio<<std::endl;
 	return new_ratio;
 	return new_ratio;
+}
+
+EntiersEntiers Spectral_Partition(const char* text){
+	//Traitement initial
+	EntiersEntiers Partition;
+	std::ifstream fichier (text, std::ios::in);
+	if(fichier){
+		int lines = std::count(std::istreambuf_iterator<char>( fichier ),
+		std::istreambuf_iterator<char>(),'\n' );
+		std::cout<<"Nombre de ligne : "<<lines<<std::endl;
+		/*** Récupération du dernier caractère ***/
+		
+		/*** Création des paramétres contenant les informations ***/
+		 
+		int nmax_vertex;
+		fichier.seekg(0, std::ios::beg);
+		fichier >> nmax_vertex;
+		std::cout<<"nmax_vertex : "<<nmax_vertex<<std::endl;
+		int nmax_size = decimal(nmax_vertex) + 1;
+		
+		/*** Récupération des informations ***/
+		int cpt = 1;
+		int length;
+		fichier.seekg(nmax_size, std::ios::beg);
+		while(cpt < lines){
+		Entiers *part = new Entiers();
+		for(uint i =0; i<nmax_vertex; i++){
+		 	int edge;
+			fichier >> edge;
+			if(edge != -1)
+				part->push_back(edge);
+		}
+		Partition.push_back(part);
+		length = fichier.tellg();
+		fichier.seekg(length+1, std::ios::beg);
+		cpt++;
+		}
+	}else{
+		std::cerr << "Impossible d'ouvrir le fichier dans Spectral_Partition !" << std::endl;
+	}
+	
+	return(Partition);
+}
+
+void Adjacent_Matrix_Txt(UnorientedGraph *g, const char* text){
+	std::ofstream GRAPH4 (text, std::ios::out);
+	if(GRAPH4){
+		tie(vertexIt, vertexEnd) = vertices(*g);
+		edge_t e1;
+		bool found;
+		
+		for (; vertexIt != vertexEnd; ++vertexIt) {
+			int cpt = 0;
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+			*g);
+			for(int i = cpt; i<num_vertices(*g); i++){
+				if(i == *neighbourIt){
+					tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
+					GRAPH4<<(*g)[e1]._weight<<" ";
+					cpt = *neighbourIt +1;
+					++neighbourIt;
+					if(*neighbourIt == *neighbourEnd){
+						for(int j = cpt; j<num_vertices(*g); j++)
+							GRAPH4<<0<<" ";
+						break;
+					}
+				}else{
+					GRAPH4<<0<<" ";
+				}
+			}
+			GRAPH4<<std::endl;
+		}   
+			
+		GRAPH4.close();
+	}else
+		 std::cerr << "Impossible d'ouvrir le fichier dans Adjacent_Matrix_Txt !" << std::endl;
+}
+
+void Weight_Matrix_Txt(UnorientedGraph *g, const char* text){
+	std::ofstream GRAPH4 (text, std::ios::out);  
+	if(GRAPH4){
+		for (int i =0 ; i<num_vertices(*g); i++) {
+			GRAPH4<<(*g)[i]._weight<<" ";
+		}   
+			
+		GRAPH4.close();
+	}else
+		 std::cerr << "Impossible d'ouvrir le fichier dans Weight_Matrix_Txt !" << std::endl;
+}
+
+void Plot_OrientedGraph(OrientedGraph *go, const EntiersEntiers &Partition, const char* text, bool Color){
+	if(Partition.size()<16){
+		std::vector<std::string> color;
+		color.push_back("[color=blue2, fontcolor=blue2];");
+		color.push_back("[color=red, fontcolor=red];");
+		color.push_back("[color=green, fontcolor=green];");
+		color.push_back("[color=turquoise, fontcolor=turquoise];");
+		color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
+		color.push_back("[color=indigo, fontcolor=indigo];");
+		color.push_back("[color=yellow, fontcolor=yellow2];");
+		color.push_back("[color=orange, fontcolor=orange];");
+		color.push_back("[color=olivedrab, fontcolor=olivedrab];");
+		color.push_back("[color=gold, fontcolor=gold];");
+		color.push_back("[color=slateblue2, fontcolor=slateblue2];");
+		color.push_back("[color=dimgrey, fontcolor=dimgrey];");
+		color.push_back("[color=cyan, fontcolor=cyan];");
+		color.push_back("[color=purple1, fontcolor=purpule1];");
+		color.push_back("[color=crimson, fontcolor=crimson];");
+		color.push_back("[color=black, fontcolor=black];");
+		
+		std::ofstream fichier2 (text, std::ios::out);
+	    fichier2<<"digraph G {"<<std::endl;   
+	    tie(vertexIto, vertexEndo) = vertices(*go);
+	    for (; vertexIto != vertexEndo; ++vertexIto) {
+			fichier2<<(*go)[*vertexIto]._index<<"-> {";
+	    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+	    			*go);
+	    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+	    		fichier2<<(*go)[*neighbourIto]._index<<";";
+	    	}
+	    	fichier2<<"}"<<std::endl;
+		}
+	    
+	    if(Color == true){
+			for(uint k=0; k<Partition.size(); k++){
+				for(uint j=0; j<Partition.at(k)->size(); j++)
+				{
+					fichier2<<Partition.at(k)->at(j)<<color.at(k)<<std::endl;
+				}
+			}  
+		} 
+	    
+		fichier2<<"}";	
+		fichier2.close();
+		
+	}else{
+		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
+	}
+}
+
+void Plot_UnorientedGraph(UnorientedGraph *g, const EntiersEntiers &Partition, const char* text, bool Color){	
+	if(Partition.size()<16){
+		std::vector<std::string> color;
+		color.push_back("[color=blue2, fontcolor=blue2];");
+		color.push_back("[color=red, fontcolor=red];");
+		color.push_back("[color=green, fontcolor=green];");
+		color.push_back("[color=turquoise, fontcolor=turquoise];");
+		color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
+		color.push_back("[color=indigo, fontcolor=indigo];");
+		color.push_back("[color=yellow, fontcolor=yellow2];");
+		color.push_back("[color=orange, fontcolor=orange];");
+		color.push_back("[color=olivedrab, fontcolor=olivedrab];");
+		color.push_back("[color=gold, fontcolor=gold];");
+		color.push_back("[color=slateblue2, fontcolor=slateblue2];");
+		color.push_back("[color=dimgrey, fontcolor=dimgrey];");
+		color.push_back("[color=cyan, fontcolor=cyan];");
+		color.push_back("[color=purple1, fontcolor=purpule1];");
+		color.push_back("[color=crimson, fontcolor=crimson];");
+		color.push_back("[color=black, fontcolor=black];");
+		
+		std::ofstream GRAPH2 (text, std::ios::out);
+		GRAPH2<<"graph G {"<<std::endl;   
+		tie(vertexIt, vertexEnd) = vertices(*g);
+		for (; vertexIt != vertexEnd; ++vertexIt) {
+			GRAPH2<<(*g)[*vertexIt]._index<<" -- {";
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index)
+					GRAPH2<<(*g)[*neighbourIt]._index<<";";
+			}
+			GRAPH2<<"}"<<std::endl;
+		}   
+		
+		if(Color == true){
+			for(uint k=0; k<Partition.size(); k++){
+				for(uint t=0; t<Partition.at(k)->size(); t++)
+				{
+					GRAPH2<<(*g)[Partition.at(k)->at(t)]._index<<color.at(k)<<std::endl;
+				}
+			}
+		}
+
+		GRAPH2<<"}";	
+		GRAPH2.close();
+	}else{
+		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
+	}
+}
+
+void Plot_UnorientedGraph_All(UnorientedGraph *g, const EntiersEntiers &Partition, const char* text, bool Color){
+	edge_t e1;
+	bool found;
+	
+	if(Partition.size()<16){
+		std::ofstream GRAPH2 (text, std::ios::out);
+		GRAPH2<<"graph G {"<<std::endl;   
+		tie(vertexIt, vertexEnd) = vertices(*g);
+		for (; vertexIt != vertexEnd; ++vertexIt) {
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
+					tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
+					GRAPH2<<(*g)[*vertexIt]._index<<" -- "<<(*g)[*neighbourIt]._index<<" [label="<<(*g)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;}
+			}
+		}   
+		
+		if(Color == true){
+			std::vector<std::string> color;
+			color.push_back(", color=blue2, fontcolor=blue2];");
+			color.push_back(", color=red, fontcolor=red];");
+			color.push_back(", color=green, fontcolor=green];");
+			color.push_back(", color=turquoise, fontcolor=turquoise];");
+			color.push_back(", color=saddlebrown, fontcolor=saddlebrown];");
+			color.push_back(", color=indigo, fontcolor=indigo];");
+			color.push_back(", color=yellow, fontcolor=yellow2];");
+			color.push_back(", color=orange, fontcolor=orange];");
+			color.push_back(", color=olivedrab, fontcolor=olivedrab];");
+			color.push_back(", color=gold, fontcolor=gold];");
+			color.push_back(", color=slateblue2, fontcolor=slateblue2];");
+			color.push_back(", color=dimgrey, fontcolor=dimgrey];");
+			color.push_back(", color=cyan, fontcolor=cyan];");
+			color.push_back(", color=purple1, fontcolor=purpule1];");
+			color.push_back(", color=crimson, fontcolor=crimson];");
+			color.push_back(", color=black, fontcolor=black];");
+			for(uint k=0; k<Partition.size(); k++){
+				for(uint t=0; t<Partition.at(k)->size(); t++)
+				{
+					GRAPH2<<(*g)[Partition.at(k)->at(t)]._index<<" [label="<<(*g)[Partition.at(k)->at(t)]._weight<<color.at(k)<<std::endl;
+				}
+			}
+		}else{
+			for(uint k=0; k<num_vertices(*g); k++){
+				GRAPH2<<(*g)[k]._index<<" [label="<<(*g)[k]._index<<", weight="<<(*g)[k]._weight<<"];"<<std::endl;
+			}
+		}
+
+		GRAPH2<<"}";	
+		GRAPH2.close();
+	}else{
+		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
+	}
+}
+
+void Plot_OrientedGraph_All(OrientedGraph *go, const EntiersEntiers &Partition, const char* text, bool Color){
+	edge_to e1;
+	bool found;
+	
+	if(Partition.size()<16){
+		std::vector<std::string> color;
+		color.push_back("[color=blue2, fontcolor=blue2];");
+		color.push_back("[color=red, fontcolor=red];");
+		color.push_back("[color=green, fontcolor=green];");
+		color.push_back("[color=turquoise, fontcolor=turquoise];");
+		color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
+		color.push_back("[color=indigo, fontcolor=indigo];");
+		color.push_back("[color=yellow, fontcolor=yellow2];");
+		color.push_back("[color=orange, fontcolor=orange];");
+		color.push_back("[color=olivedrab, fontcolor=olivedrab];");
+		color.push_back("[color=gold, fontcolor=gold];");
+		color.push_back("[color=slateblue2, fontcolor=slateblue2];");
+		color.push_back("[color=dimgrey, fontcolor=dimgrey];");
+		color.push_back("[color=cyan, fontcolor=cyan];");
+		color.push_back("[color=purple1, fontcolor=purpule1];");
+		color.push_back("[color=crimson, fontcolor=crimson];");
+		color.push_back("[color=black, fontcolor=black];");
+		
+		std::ofstream fichier2 (text, std::ios::out);
+	    fichier2<<"digraph G {"<<std::endl;   
+	    tie(vertexIto, vertexEndo) = vertices(*go);
+	    for (; vertexIto != vertexEndo; ++vertexIto) {
+	    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+	    			*go);
+	    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+					tie(e1,found)=edge(vertex(*vertexIto,*go),vertex(*neighbourIto,*go),*go);
+					fichier2<<(*go)[*vertexIto]._index<<" -> "<<(*go)[*neighbourIto]._index<<" [label="<<(*go)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;
+	    	}
+		}
+	    
+	    if(Color == true){
+			for(uint k=0; k<Partition.size(); k++){
+				for(uint j=0; j<Partition.at(k)->size(); j++)
+				{
+					fichier2<<Partition.at(k)->at(j)<<color.at(k)<<std::endl;
+				}
+			}  
+		} 
+	    
+		fichier2<<"}";	
+		fichier2.close();
+		
+	}else{
+		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
+	}
+}
+
+
+void Affichage_OrientedGraph(OrientedGraph *go){
+	tie(vertexIto, vertexEndo) = vertices(*go);
+    for (; vertexIto != vertexEndo; ++vertexIto) {
+    	std::cout<<(*go)[*vertexIto]._index<<" -> ";
+    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+    			*go);
+    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+    		std::cout<<(*go)[*neighbourIto]._index<<" ";	
+    	}
+    	std::cout<<std::endl;
+    }
+	std::cout<<std::endl;
+}
+
+void Affichage_UnorientedGraph(UnorientedGraph *g){
+	tie(vertexIt, vertexEnd) = vertices(*g);
+    for (; vertexIt != vertexEnd; ++vertexIt) {
+    	std::cout<<(*g)[*vertexIt]._index<<" -> ";
+    	tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+    			*g);
+    	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+    		std::cout<<(*g)[*neighbourIt]._index<<" ";	
+    	}
+    	std::cout<<std::endl;
+    }
+	std::cout<<std::endl;
+}
+
+double Total_weight_edges(UnorientedGraph *g){
+	double Sum_weight_edges = 0.;
+	edge_t e1;
+	bool found;
+	
+	tie(vertexIt, vertexEnd) = vertices(*g);
+	for (; vertexIt != vertexEnd; ++vertexIt) {
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
+				tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
+				Sum_weight_edges += (*g)[e1]._weight;
+				}
+		}
+	}
+	
+	return Sum_weight_edges;
+}
+
+void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2, std::vector<std::pair<int,int>> &connection, std::vector<double> &connection_weight){
+	edge_to e1;
+	bool found;
+	
+	int nbr_go1 = num_vertices(*go1);
+	int nbr_go2 = num_vertices(*go2);
+	
+	/*** Fusion ***/
+	if(nbr_go1 >= nbr_go2){
+		tie(vertexIto, vertexEndo) = vertices(*go2);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			vertex_to v0 = boost::add_vertex(*go1);
+			(*go1)[v0] = VertexProperties((*go2)[*vertexIto]._index, (*go2)[*vertexIto]._weight, NORMAL_PIXEL);
+		}	
+		
+		tie(vertexIto, vertexEndo) = vertices(*go2);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,*go2);
+			for (; neighbourIto != neighbourEndo; ++neighbourIto){
+				tie(e1,found)=edge(vertex(*vertexIto,*go2),vertex(*neighbourIto,*go2),*go2);
+				add_edge(*vertexIto + nbr_go1, *neighbourIto + nbr_go1, (*go2)[e1]._weight, *go1);
+			}
+		}
+		
+		/*** Connection ***/
+		/* Fonctionne si l'ordre de nomation respecte l'ordre boost sinon possibilité d'identification par nom*/
+		for(uint i = 0; i < connection.size(); i++){
+			add_edge(connection.at(i).first, connection.at(i).second, connection_weight.at(i) , *go1);
+		} 
+		
+	}else{
+		tie(vertexIto, vertexEndo) = vertices(*go1);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			vertex_to v0 = boost::add_vertex(*go2);
+			(*go2)[v0] = VertexProperties((*go1)[*vertexIto]._index, (*go1)[*vertexIto]._weight, NORMAL_PIXEL);
+		}	
+		
+		tie(vertexIto, vertexEndo) = vertices(*go1);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,*go1);
+			for (; neighbourIto != neighbourEndo; ++neighbourIto){
+				tie(e1,found)=edge(vertex(*vertexIto,*go1),vertex(*neighbourIto,*go1),*go1);
+				add_edge(*vertexIto + nbr_go2, *neighbourIto + nbr_go2, (*go1)[e1]._weight, *go2);
+			}
+		}
+		
+		/*** Connection ***/
+		/* Fonctionne si l'ordre de nomation respecte l'ordre boost sinon possibilité d'identification par nom*/
+		for(uint i = 0; i < connection.size(); i++){
+			add_edge(connection.at(i).first, connection.at(i).second, connection_weight.at(i) , *go2);
+		}
+		 
+	}	
 	
 	
 }
 }
 
 

+ 145 - 41
src/tests/boost_graph/partitioning/utils.hpp

@@ -28,102 +28,206 @@
 #define TESTS_BOOST_GRAPH_PARTITIONING_UTILS_H 1
 #define TESTS_BOOST_GRAPH_PARTITIONING_UTILS_H 1
 
 
 #include <tests/boost_graph/partitioning/defs.hpp>
 #include <tests/boost_graph/partitioning/defs.hpp>
+#include <boost/graph/copy.hpp>
 
 
 namespace paradevs { namespace tests { namespace boost_graph {
 namespace paradevs { namespace tests { namespace boost_graph {
 
 
 void Global_Neigh_community(UnorientedGraph *g,
 void Global_Neigh_community(UnorientedGraph *g,
-                            const EntiersEntiers &Partition,
-                            Entiers *community, int vertex, int comm_in);
+                        const EntiersEntiers &Partition,
+                        Entiers *community, int vertex, 
+						int comm_in);
 
 
 OrientedGraphs Graph_Partition(const EntiersEntiers &Partition,
 OrientedGraphs Graph_Partition(const EntiersEntiers &Partition,
-                               OrientedGraph *go,
-                               UnorientedGraph *g,
-                               OutputEdgeList &outputedgelist,
-                               InputEdgeList &inputedgelist,
-                               Connections &connections);
+                        OrientedGraph *go,
+                        UnorientedGraph *g,
+                        OutputEdgeList &outputedgelist,
+                        InputEdgeList &inputedgelist,
+                        Connections &connections);
 
 
-void List_edge_partie(Entiers *Partie, OrientedGraph *go, Edges &edge_partie,
-                      OutputEdges &outputedgespartie);
+void List_edge_partie(Entiers *Partie, OrientedGraph *go, 
+						Edges &edge_partie,
+                        OutputEdges &outputedgespartie);
 
 
 void construire_graph(UnorientedGraph *g, OrientedGraph *graph);
 void construire_graph(UnorientedGraph *g, OrientedGraph *graph);
 
 
-double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g, double &vol, std::string name);
+double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g,
+						double &vol, std::string name);
 
 
-std::vector<double> modif_cut_tmp(UnorientedGraph *g, EntiersEntiers &Partition,
-                             std::vector<std::vector<double> > tabe_cut,
-                                  int vertexs,
-                             int comm_in, Entiers community, double cut,
-                             std::string name);
+std::vector<double> modif_cut_tmp(UnorientedGraph *g,
+						EntiersEntiers &Partition,
+                        std::vector<std::vector<double> > tabe_cut,
+                        int vertexs, int comm_in, Entiers community,
+                        double cut, std::string name);
 
 
 double Calcul_poids(Entiers *partie, UnorientedGraph *g);
 double Calcul_poids(Entiers *partie, UnorientedGraph *g);
 
 
-bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition, Entiers &part);
+bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition,
+						Entiers &part);
 
 
-void Affinage_equilibrage_charge(UnorientedGraph *g, EntiersEntiers &Partition);
+void Affinage_equilibrage_charge(UnorientedGraph *g, 
+						EntiersEntiers &Partition);
 
 
 Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition,
 Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition,
                         int vertex, int comm_in);
                         int vertex, int comm_in);
 
 
 void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
 void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
-                             Entiers &community, int val, double &cut,
-                             std::string name);
+                        Entiers &community, int val, double &cut,
+                        std::string name);
 
 
 void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition,
 void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition,
-                               double &cut, std::string name);
+                        double &cut, std::string name);
 
 
 void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit);
 void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit);
 
 
 bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg,
 bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg,
-                     ListEntiersEntiers &liste_corr, int val_reduc,
-                     int &val_cpt);
+						ListEntiersEntiers &liste_corr, int val_reduc,
+						int &val_cpt);
+						
+bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, 
+						ListEntiersEntiers &liste_corr, int val_reduc, 
+						int &val_cpt);
+						
+bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg, 
+						ListEntiersEntiers &liste_corr, int val_reduc, 
+						int &val_cpt);
+
+bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg,
+						ListEntiersEntiers &liste_corr, 
+						int val_reduc, int &val_cpt);
+						
 bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg,
 bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg,
-                                ListEntiersEntiers &liste_corr, int val_reduc,
-                                int &val_cpt);
-
+                        ListEntiersEntiers &liste_corr, 
+                        int val_reduc,
+                        int &val_cpt);
+                        
 Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,
 Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,
                         const Entiers &random_vertices);
                         const Entiers &random_vertices);
-
+                        
 int rand_fini(int a, int b);
 int rand_fini(int a, int b);
+
 int recherche_val2(const std::vector<float> &tab,float val);
 int recherche_val2(const std::vector<float> &tab,float val);
+
 int recherche_val_double(const std::vector<double> &tab,double val);
 int recherche_val_double(const std::vector<double> &tab,double val);
+
 int recherche_val(const std::vector<int> &tab,int val);
 int recherche_val(const std::vector<int> &tab,int val);
+
 int dichotomie(const Entiers &tab,int i);
 int dichotomie(const Entiers &tab,int i);
+
 void suprim_val(Entiers &tab,int i);
 void suprim_val(Entiers &tab,int i);
+
 bool In_tab(const Entiers &tab, int val);
 bool In_tab(const Entiers &tab, int val);
+
 bool In_tab_dichotomie(const Entiers &tab, int val);
 bool In_tab_dichotomie(const Entiers &tab, int val);
+
 double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,
 double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,
-                   std::string name);
+						std::string name);
 void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
 void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
-                             int community_out,int community_in,int val,
-                             double &cut);
+                        int community_out,int community_in,int val,
+                        double &cut);
+
 void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g);
 void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g);
+
 int Cout_coupe(Entiers P,int val, UnorientedGraph &g);
 int Cout_coupe(Entiers P,int val, UnorientedGraph &g);
+
 double Cout_coupe_pond(Entiers P,int val, UnorientedGraph &g);
 double Cout_coupe_pond(Entiers P,int val, UnorientedGraph &g);
+
 int In_community_dichotomie(const EntiersEntiers &part, int val);
 int In_community_dichotomie(const EntiersEntiers &part, int val);
+
 double Degree(UnorientedGraph &g , int node);
 double Degree(UnorientedGraph &g , int node);
+
 double Cluster_Degree(UnorientedGraph &g , const Entiers &cluster);
 double Cluster_Degree(UnorientedGraph &g , const Entiers &cluster);
 
 
 void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& uog);
 void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& uog);
 
 
 void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g);
 void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g);
 
 
-double modif_Cout_coupe(const Entiers &P, int val, double cut, UnorientedGraph *g);
+double modif_Cout_coupe(const Entiers &P, int val, double cut, 
+						UnorientedGraph *g);
+
 double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster);
 double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster);
-double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, Entiers *cluster2, int index_cluster1, UnorientedGraph &g,std::string name);
+
+double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, 
+						Entiers *cluster2, int index_cluster1, 
+						UnorientedGraph &g,std::string name);
 
 
 void Text_generator_graph(const char *texte, OrientedGraph *go);
 void Text_generator_graph(const char *texte, OrientedGraph *go);
+
 void Graph_constructor_txt(const char* text, OrientedGraph * Og);
 void Graph_constructor_txt(const char* text, OrientedGraph * Og);
+
 int decimal(int valeur);
 int decimal(int valeur);
-double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, int partie, int node, std::string name);
-std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, std::string name);
-void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name, double poids_moy);
-void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, std::vector<std::vector<int>> &Diff_vector, int recalcul1, int recalcul2, std::string name);
-double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, int in, int out, int node, double ratio);
-std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Partition, std::string name);
-void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Partition, std::vector<int> &Diff_vector, int node, std::string name);
-void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name, double poids_moy);
-double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, int node, double ratio);
-double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part, int node, std::string name);
+
+double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, 
+						int partie, int node, std::string name);
+
+std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g,
+						const EntiersEntiers &Partition, std::string name);
+
+void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, 
+						double &cut, std::string name, double poids_moy);
+
+void Modif_vector_diff_cut_ratio(UnorientedGraph *g,
+						const EntiersEntiers &Partition, 
+						std::vector<std::vector<int>> &Diff_vector, 
+						int recalcul1, int recalcul2, std::string name);
+
+double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, 
+						int in, int out, int node, double ratio);
+
+std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g, 
+						const EntiersEntiers &Partition, std::string name);
+
+void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, 
+						const EntiersEntiers &Partition, 
+						std::vector<int> &Diff_vector, int node, std::string name);
+
+void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition, 
+						double &cut, std::string name, double poids_moy);
+
+double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, 
+						int node, double ratio);
+
+double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part, 
+						int node, std::string name);
+
+EntiersEntiers Spectral_Partition(const char* text);
+
+void Adjacent_Matrix_Txt(UnorientedGraph *g, const char* text);
+
+void Weight_Matrix_Txt(UnorientedGraph *g, const char* text);
+
+void Plot_UnorientedGraph(UnorientedGraph *g, 
+						const EntiersEntiers &Partition, 
+						const char* text, bool Color);
+
+void Plot_OrientedGraph(OrientedGraph *g, const EntiersEntiers &Partition, 
+						const char* text, bool Color);
+
+void Affichage_OrientedGraph(OrientedGraph *go);
+
+void Affichage_UnorientedGraph(UnorientedGraph *g);
+
+Entiers Liste_adjacence_tests(UnorientedGraph &g, int vertexs,
+						const Entiers &Index_Vertex);
+
+void Plot_UnorientedGraph_All(UnorientedGraph *g, 
+						const EntiersEntiers &Partition, 
+						const char* text, bool Color);
+						
+void Plot_OrientedGraph_All(OrientedGraph *go, 
+						const EntiersEntiers &Partition, 
+						const char* text, bool Color);
+						
+double Total_weight_edges(UnorientedGraph *g);
+
+bool Est_voisin(UnorientedGraph *g, int vertex, int vertex_select);
+
+double In_modularity(UnorientedGraph *g , const Entiers &cluster);
+double Modularity(UnorientedGraph *g,const EntiersEntiers &part);
+
+bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt);
+
+void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2, std::vector<std::pair<int,int>> &connection, std::vector<double> &connection_weight);
+
 } } } // namespace paradevs tests boost_graph
 } } } // namespace paradevs tests boost_graph
 
 
 #endif
 #endif

+ 79 - 19
src/tests/boost_graph/tests.cpp

@@ -147,7 +147,7 @@ void test(double duration, std::string partitioning_method_name,
           GraphGenerator& g)
           GraphGenerator& g)
 {
 {
     boost::timer t;
     boost::timer t;
-	int nbr_ite = 20;
+	int nbr_ite = 10;
 	
 	
     log_file << "==== " << partitioning_method_name << " with ";
     log_file << "==== " << partitioning_method_name << " with ";
     if (contraction_coef_flag) {
     if (contraction_coef_flag) {
@@ -315,26 +315,27 @@ void test_flat_random()
 
 
 void test_partitioning_random()
 void test_partitioning_random()
 {
 {
-    std::vector < int > levels = { 5, 4, 3, 2  };
-    int nbr_sommets = 6000;
+    std::vector < int > levels = {/*5,4,*/ 3, 2  };
+    int nbr_sommets = 200;
     int sources = nbr_sommets/100*1;
     int sources = nbr_sommets/100*1;
+    
     RandomGraphGenerator g(nbr_sommets, levels, sources, 2, 3);
     RandomGraphGenerator g(nbr_sommets, levels, sources, 2, 3);
 
 
-    /*test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 32, 2,
-                                  false, true, 5, true, g);*/
-    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 50, 2,
+    /*test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 200, 2,
+                                  false, true, 5, true, g);
+    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 200, 2,
                                   false, true, 10, true, g);
                                   false, true, 10, true, g);
-    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 50, 2,
+    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 200, 2,
                                   false, true, 20, true, g);
                                   false, true, 20, true, g);
-    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 50, 2,
+    test < RandomGraphGenerator >(duration_random, "gggp_pond", 42, 42, 2,
                                   false, true, 40, true, g);
                                   false, true, 40, true, g);
     test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 50, 2,
     test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 50, 2,
-                                  false, true, 60, true, g);
-    /*test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 32, 2,
-                                  false, true, 80, true, g);   
-    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 32, 2,
+                                  false, true, 60, true, g);*/
+    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 200, 2,
+                                  false, true, 1 , true, g);   
+   /* test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 32, 2,
                                   false, true, 100, true, g);
                                   false, true, 100, true, g);
-    /*test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 30, 2,
+    test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 30, 2,
                                   false, true, 200, true, g);*/
                                   false, true, 200, true, g);*/
 
 
     /*test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 32, 2,
     /*test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 32, 2,
@@ -399,7 +400,60 @@ void test_partitioning_random()
 
 
 }
 }
 
 
-const double duration_random_linked = 0;
+const double duration_random_grid = 40;
+
+void test_flat_random_grid()
+{
+    boost::timer t;
+    int nbr_ite = 10;
+
+    log_file << "== Random Graph ==" << std::endl;
+    log_file << "flat graph with heap = ";
+    for (unsigned int i = 0; i < nbr_ite; ++i) {
+        flat_heap_test< RandomGridFlatGraphBuilder >(duration_random_grid);
+    }
+
+    double t2 = t.elapsed();
+
+    /*log_file << t2 / 10 << std::endl;
+
+    log_file << "flat graph with vector = ";
+    for (unsigned int i = 0; i < 10; ++i) {
+        flat_vector_test< FlatGraphBuilder >(duration_random);
+    }
+
+    double t3 = t.elapsed();*/
+
+    //log_file << (t3 - t2) / 10 << std::endl;
+    log_file << t2 / nbr_ite << std::endl;
+}
+
+void test_partitioning_random_grid()
+{
+	unsigned int side = 90;
+	std::vector<std::pair<int,int>> vertex_selection;
+	std::pair<int,int> tmp;
+	tmp.first = 0;
+	tmp.second = 3;
+	vertex_selection.push_back(tmp);
+	Entiers weight_vertex;
+	weight_vertex.push_back(1);
+	const char *edge_weight;
+	edge_weight = "../../sortie_graphe/tests_grid.txt";
+	bool rec = false;
+        
+    RandomGridGraphGenerator g(side, vertex_selection,  weight_vertex, edge_weight, rec);
+
+    test < RandomGridGraphGenerator >(duration_random_grid, "gggp_pond", 2, 100, 2,
+                                  false, true, 80 , true, g); 
+                                  
+    test < RandomGridGraphGenerator >(duration_random_grid, "gggp_pond", 2, 100, 2,
+                                  false, true, 40 , true, g);   
+
+
+}
+
+const double duration_random_linked = 30;
 
 
 void test_flat_random_linked()
 void test_flat_random_linked()
 {
 {
@@ -430,7 +484,7 @@ void test_flat_random_linked()
 void test_partitioning_random_linked()
 void test_partitioning_random_linked()
 {
 {
     unsigned int levels = 60;
     unsigned int levels = 60;
-    int nbr_sommets = 6000;
+    int nbr_sommets = 5000;
     RandomLinkedGraphGenerator g(nbr_sommets, levels, 2, 3);
     RandomLinkedGraphGenerator g(nbr_sommets, levels, 2, 3);
 
 
 	// gggp
 	// gggp
@@ -595,6 +649,12 @@ void test_random_linked()
     test_partitioning_random_linked();
     test_partitioning_random_linked();
 }
 }
 
 
+void test_random_grid()
+{
+    test_flat_random_grid();
+    test_partitioning_random_grid();
+}
+
 int main()
 int main()
 {
 {
     srand(7262);
     srand(7262);
@@ -604,10 +664,10 @@ int main()
     //std::cout<<std::endl;
     //std::cout<<std::endl;
     //std::cout<<"Simulation pour graphe RANDOM 4000"<<std::endl;
     //std::cout<<"Simulation pour graphe RANDOM 4000"<<std::endl;
     //test_random();
     //test_random();
-    std::cout<<"Simulation pour graphe RANDOM_TREE 6000"<<std::endl;
-    test_random();
-    std::cout<<"Simulation pour graphe RANDOM_LINKED 6000"<<std::endl;
-    test_random_linked();
+    std::cout<<"Simulation pour graphe RANDOM_TREE 200"<<std::endl;
+    test_random_grid();
+    //std::cout<<"Simulation pour graphe RANDOM_LINKED 6000"<<std::endl;
+    //test_random_linked();
     //std::cout<<std::endl;
     //std::cout<<std::endl;
     //std::cout<<"Simulation pour graphe CORSEN"<<std::endl;
     //std::cout<<"Simulation pour graphe CORSEN"<<std::endl;
     //test_corsen();
     //test_corsen();