ソースを参照

détection des sommets de format TOP dans la fonction de génération des graphes aléatoires suivant une structure d'arbre

totofeh 11 年 前
コミット
e904681f9f

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

@@ -68,18 +68,18 @@ public:
         if (contraction_coef_flag) {
             graphs = Multiniveau(num_vertices(*g) / contraction_coef,
                                  g, &graph_origin, &go,
-                                 cluster_number,25, "HEM",
+                                 cluster_number,10, "HEM",
                                  partitioning_method_name,
                                  "cut", "ratio", edge_partie ,
                                  output_edges, input_edges,
-                                 parent_connections, Cut);
+                                 parent_connections, Cut/*,3*/);
         } else {
             graphs = Multiniveau(contraction_coef, g, &graph_origin, &go,
-                                 cluster_number,25, "HEM",
+                                 cluster_number,10, "HEM",
                                  partitioning_method_name,
                                  "cut", "ratio", edge_partie ,
                                  output_edges, input_edges,
-                                 parent_connections, Cut);
+                                 parent_connections, Cut/*,3*/);
         }
 
         // std::cout << "*********************************" << std::endl;

+ 14 - 13
src/tests/boost_graph/partitioning/gggp.cpp

@@ -55,7 +55,8 @@ void ggp(UnorientedGraph *g, Entiers *sommetsSource,
         for(uint i=0; i<Partition.size();i++){
             if(Partition.at(i)->size()==tmp)
             {
-                ggp(g,Partition[i],sommetsDestination,Partition,rand_fini(0,Partition.at(i)->size()), distance);
+                ggp(g, Partition[i], sommetsDestination, Partition, rand_fini(0,Partition.at(i)->size()),
+					distance);
                 return;
             }
         }
@@ -699,7 +700,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
 		double best_cut = Cut_cluster(Partition,copy_graph,type_cut);
 		Cut.push_back(best_cut);
 		//std::cout<<"Meilleur coût de coupe : "<<best_cut<<std::endl;
-		std::cout<<std::endl;
+		//std::cout<<std::endl;
     }
     else
     	Partition = Random_partitioning(baseg.at(baseg.size()-1),nbr_parties);
@@ -723,9 +724,9 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     		projection(Partition,lit);
     		// std::cout<<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;
-    		std::cout<<std::endl;
-    		std::cout<<"Affinage "<<std::endl;
+    		//std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
+    		//std::cout<<std::endl;
+    		//std::cout<<"Affinage "<<std::endl;
     		if(choix_affinage=="charge")
     			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
     		else
@@ -734,7 +735,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     		lit--;
     	}
     	else{
-    		std::cout<<"Pas de projection "<<std::endl;
+    		//std::cout<<"Pas de projection "<<std::endl;
     		// std::cout<<std::endl;
 
     		/*if(nbr_parties != num_vertices(*g)){
@@ -774,7 +775,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     color.push_back("[color=crimson, fontcolor=crimson];");
     color.push_back("[color=black, fontcolor=black];");
     
-   std::ofstream fichier2 ("../../sortie_graphe/graph_partition_38_4_1.txt", std::ios::out);
+   /*std::ofstream fichier2 ("../../sortie_graphe/graph_partition_38_4_1.txt", std::ios::out);
    fichier2<<"digraph G {"<<std::endl;   
    tie(vertexIto, vertexEndo) = vertices(*go);
    for (; vertexIto != vertexEndo; ++vertexIto) {
@@ -795,7 +796,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     }   
     
 	fichier2<<"}";	
-	fichier2.close();
+	fichier2.close();*/
 
 	//double cut = Cut_cluster(Partition,*graph_origin,"cut");
 	// std::cout<<"Cout de coupe engendré par le partitionnement: "<<cut<<std::endl;
@@ -960,7 +961,7 @@ void Optimisation_method_neighbour_distance(UnorientedGraph *g, EntiersEntiers &
 		tirage_distance(g, *Iter, vertex_list, distance);
 		}
 		else{	
-			std::cout<<"Tous les sommets sont verrouillés"<<std::endl;
+			//std::cout<<"Tous les sommets sont verrouillés"<<std::endl;
 			break;
 		}
 		
@@ -996,7 +997,7 @@ void Optimisation_method_neighbour_distance(UnorientedGraph *g, EntiersEntiers &
 		
 		new_cut = Best_Cut_cluster(Partition, tmp_part, part2, index_partition, *g,name_cut);
 
-		std::cout<<"Cout de coupe : "<<new_cut<<std::endl;
+		//std::cout<<"Cout de coupe : "<<new_cut<<std::endl;
 		
 		if(new_cut<cut){ //conservation de l'information en cas d'amélioration de la contrainte
 			cut = new_cut;
@@ -1021,9 +1022,9 @@ void Optimisation_method_neighbour_distance(UnorientedGraph *g, EntiersEntiers &
 	Partition.at(index_partition)=part_cour_cons;
 	Partition.push_back(part2_cons);
 	
-	std::cout<<std::endl;
+	/*std::cout<<std::endl;
 	std::cout<<"Bissection réalisé"<<std::endl;
-	std::cout<<std::endl;
+	std::cout<<std::endl;*/
 }
 
 void tirage_distance(UnorientedGraph *g, int tirage, std::list<int> &vertex_list, int distance){
@@ -1047,7 +1048,7 @@ void tirage_distance(UnorientedGraph *g, int tirage, std::list<int> &vertex_list
 		liste_tmp.unique();
 		vertex_delete.push_back(liste_tmp);
 	}
-	std::cout<<std::endl;
+	//std::cout<<std::endl;
 		
 	/*for(int i =0; i<vertex_delete.size(); i++){
 		std::list<int>::iterator Ite_tmp;

+ 39 - 6
src/tests/boost_graph/partitioning/graph_build.cpp

@@ -371,7 +371,7 @@ void brhtg_source(OrientedGraph *go,int nbr_vertex, int nbr_source, int nbr_v_mi
 			}
 		}
 
-		for(int i =0; i<branche.size()-1; i++){
+		/*for(int i =0; i<branche.size()-1; i++){
 			for(int j = branche.at(i)+nbr_source; j<branche.at(i+1); j++){
 				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
 			}
@@ -381,7 +381,7 @@ void brhtg_source(OrientedGraph *go,int nbr_vertex, int nbr_source, int nbr_v_mi
 			for(int j = branche.at(i); j<branche.at(i)+nbr_source; j++){
 				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, TOP_PIXEL);
 			}
-		}
+		}*/
 
 		Ram.push_back((niv_tot+b)*nbr_npb);
 		Exu.push_back(branche.at(branche.size()-1)-1);
@@ -502,11 +502,11 @@ void brhtg_ramification(OrientedGraph *go, int nbr_vertex, int nbr_v_min, int nb
 			Ram.push_back((niv_tot+b)*nbr_npb);
 			Exu.push_back(branche.at(b).at(branche.at(b).size()-1)-1);
 
-			for(int y =0; y<branche.at(b).size()-1; y++){
+			/*for(int y =0; y<branche.at(b).size()-1; y++){
 				for(int x = branche.at(b).at(y); x<branche.at(b).at(y+1); x++){
 					(*go)[Vertexs.at(x)] = VertexProperties(x, 1, NORMAL_PIXEL);
 				}
-			}
+			}*/
 		}
 
 		Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
@@ -551,7 +551,7 @@ void brhtg_exutoire(OrientedGraph *go,int nbr_vertex,int nbr_v_min, int nbr_v_ma
 	for(int i =0; i<Ram.size()-1;i++){
 		for(int j = Ram.at(i); j<Ram.at(i+1); j++){
 			if(j==Ram.at(Ram.size()-1)-1){
-				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+				//(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
 				break;
 			}
 			else{
@@ -592,7 +592,7 @@ void brhtg_exutoire(OrientedGraph *go,int nbr_vertex,int nbr_v_min, int nbr_v_ma
 				}
 
 			}
-			(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+			//(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
 		}
 	}
 }
@@ -648,6 +648,39 @@ void build_generator_graph(OrientedGraph *go, int nbr_vertex, int nbr_source, in
 	} else {
 			brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
 	}
+	
+	std::vector < int > dg_in_vertex_list;
+	std::vector <vertex_to> dg_vertex_list;
+	OrientedGraph::vertex_iterator it_dg, end_dg;
+
+	tie(it_dg, end_dg) = vertices(*go);
+	for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+		dg_in_vertex_list.push_back(0);
+		dg_vertex_list.push_back(*it_dg);
+	}
+
+	tie(it_dg, end_dg) = vertices(*go);
+	for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+		OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+		tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, *go);
+		for (; neighbour_it != neighbour_end; ++neighbour_it) {
+			uint index = 0;
+
+			while (dg_vertex_list[index] != *neighbour_it) {
+				++index;
+			}
+			++dg_in_vertex_list[index];
+		}
+	}
+	
+	for(uint i = 0; i<num_vertices(*go); i++){
+		if(dg_in_vertex_list.at(i) == 0){
+			(*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
+		}else{
+			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
+		}
+	}
 
 }
 

+ 15 - 6
src/tests/boost_graph/tests.cpp

@@ -234,7 +234,7 @@ void test(double duration, std::string partitioning_method_name,
 
 /* 38 nodes graph */
 
-const double duration_38 = 1000;
+const double duration_38 = 20;
 
 void test_flat_38()
 {
@@ -265,10 +265,13 @@ void test_partitioning_38()
     ArtificialGraphGenerator g(38);
 
     for (int i = 1; i <= 2; ++i) {
-        test < ArtificialGraphGenerator >(duration_38, "ggp", 2, 16, 2,
-                                          true, true, i, true, g);
+		std::cout<<"Méthode ggp"<<std::endl;
+        /*test < ArtificialGraphGenerator >(duration_38, "ggp", 2, 16, 2,
+                                          true, true, i, true, g);*/
+        std::cout<<"Méthode gggp"<<std::endl;
         test < ArtificialGraphGenerator >(duration_38, "gggp_pond", 2, 16, 2,
                                           true, true, i, true, g);
+        std::cout<<"Méthode random"<<std::endl;
         test < ArtificialGraphGenerator >(duration_38, "random", 2, 16, 2,
                                           true, true, i, true, g);
     }
@@ -281,7 +284,7 @@ void test_partitioning_38()
 
 /* random graph */
 
-const double duration_random = 20;
+const double duration_random = 10;
 
 void test_flat_random()
 {
@@ -310,7 +313,7 @@ void test_flat_random()
 void test_partitioning_random()
 {
     std::vector < int > levels = { 4, 3, 2  };
-    RandomGraphGenerator g(2000, levels, 5, 2, 4);
+    RandomGraphGenerator g(3000, levels, 5, 2, 4);
 
     test < RandomGraphGenerator >(duration_random, "gggp_pond", 2, 32, 2,
                                   false, true, 5, true, g);
@@ -505,8 +508,14 @@ int main()
 {
     srand(7262);
 
+	std::cout<<"Simulation pour graphe 38"<<std::endl;
     test_38();
-    test_corsen();
+    std::cout<<std::endl;
+    std::cout<<"Simulation pour graphe RANDOM 4000"<<std::endl;
     test_random();
+    std::cout<<std::endl;
+    std::cout<<"Simulation pour graphe CORSEN"<<std::endl;
+    test_corsen();
+
     return 0;
 }