Преглед на файлове

ajout d'un graphe proche d'un parcellaire à deux mode mono et multiple utilisant une notion de distance entre point

totofeh преди 9 години
родител
ревизия
bf8089c462

+ 11 - 4
src/tests/boost_graph/file_generator.cpp

@@ -26,6 +26,7 @@
 
 #include <boost/format.hpp>
 #include <fstream>
+#include <boost/timer.hpp>
 
 //#include <tests/boost_graph/partitioning/graph_build.hpp>
 #include <tests/boost_graph/graph_generator.hpp>
@@ -35,6 +36,7 @@ using namespace paradevs::tests::boost_graph;
 
 int main()
 {
+	boost::timer t;
 	srand((unsigned)time(NULL));
 	/** Grid **/
 	/*int side = floor(sqrt(4900));
@@ -58,14 +60,17 @@ int main()
 	
 	/** Linked **/
 	//OrientedGraph gtmp;
-	int nbr_sommets = 10000;
-	int nbr_couches = 60;
-	RandomLinkedGraphGenerator generator(nbr_sommets, nbr_couches, 2, 3);
+	//int nbr_sommets = 10000;
+	//int nbr_couches = 60;
+	//RandomLinkedGraphGenerator generator(nbr_sommets, nbr_couches, 2, 3);
 	//generator.generate(gtmp);
 	//Text_generator_graph("file/data_base/linked/linked_10000.txt", &gtmp);
 	
 	//ArtificialGraphGenerator generator(38);
 	
+	ParcelGraphGenerator generator(10000, "mono");
+	std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
+	
 	OrientedGraph::vertex_iterator vertexIt, vertexEnd;
 	
 	/*UnorientedGraph gi;
@@ -108,7 +113,7 @@ int main()
 	 * ggp
 	 * rand
 	 **/
-    PartitioningGraphBuilder graph_builder(2, "gggp", 200,
+    PartitioningGraphBuilder graph_builder(4, "gggp", 200,
                                            false, generator);
                                            
     OrientedGraphs graphs;
@@ -118,6 +123,8 @@ int main()
 
     graph_builder.build(graphs, input_edges, output_edges,
                         parent_connections);
+                        
+    std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
     
     /*std::vector<const char*> name;
     name.push_back("../../sortie_graphe/Tests/Graphes/Multiniveau/txt/partie_0.txt");

+ 21 - 0
src/tests/boost_graph/graph_builder.hpp

@@ -419,6 +419,27 @@ public:
 
 };
 
+//créationd de la classe ParcelFlatGraphBuilder
+class ParcelFlatGraphBuilder
+{
+public:
+    ParcelFlatGraphBuilder()
+    { }
+
+    void build(OrientedGraphs& graphs, InputEdgeList& ,
+               OutputEdgeList& ,
+               Connections& )
+    {
+        
+        OrientedGraph graph;
+        uint size_max = 1000;
+        std::string name = "mono";
+        
+		build_parcellaire_graph(&graph, size_max, name);
+        graphs.push_back(graph);
+    }
+
+};
 
 } } } // namespace paradevs tests boost_graph
 

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

@@ -149,6 +149,29 @@ private:
     unsigned int edge_number;
 };
 
+class ParcelGraphGenerator : public GraphGenerator
+{
+public:
+    ParcelGraphGenerator(uint size_max,
+                         std::string name) :
+        size_max(size_max), name(name)
+    { }
+
+    virtual void generate(OrientedGraph& go)
+    {
+		//const char *texte = new const char();
+        //texte = "file/data_base/HO_models.txt";
+        //texte = "file/data_base/linked/linked10000.txt";
+        //Graph_constructor_txt(texte,&go);
+        
+		build_parcellaire_graph(&go, size_max, name);
+    }
+
+private:
+    uint size_max;
+    std::string name;
+};
+
 class CorsenGraphGenerator : public GraphGenerator
 {
 public:

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

@@ -80,7 +80,7 @@ public:
             graphs = Multiniveau(&go, numeric_parameters,
                                  parameters, edge_partie ,
                                  output_edges, input_edges,
-                                 parent_connections, true, 2);
+                                 parent_connections, false, 2);
         } else {
 			uint nbr_tirage = 10;
 			std::vector<uint> numeric_parameters = {contraction_coef ,
@@ -90,7 +90,7 @@ public:
             graphs = Multiniveau(&go, numeric_parameters,
                                  parameters, edge_partie ,
                                  output_edges, input_edges,
-                                 parent_connections, true, 2);
+                                 parent_connections, false, 2);
         }
 
         // std::cout << "*********************************" << std::endl;

+ 1 - 1
src/tests/boost_graph/partitioning/CMakeLists.txt

@@ -9,7 +9,7 @@ LINK_DIRECTORIES(
   ${GLIBMM_LIBRARY_DIRS}
   ${LIBXML_LIBRARY_DIR})
 
-SET(PARTITIONING_HPP utils.hpp gggp.hpp graph_build.hpp)
+SET(PARTITIONING_HPP utils.hpp gggp.hpp graph_build.hpp) 
 
 SET(PARTITIONING_CPP utils.cpp gggp.cpp graph_build.cpp)
 

+ 3 - 0
src/tests/boost_graph/partitioning/gggp.cpp

@@ -832,6 +832,9 @@ OrientedGraphs Multiniveau(OrientedGraph *go,
     int val_cpt = num_vertices(*g);
     bool time = true;
     
+    /*Eigen::MatrixXd Madj = adjacence_matrix(g);
+	std::cout << Madj << std::endl << std::endl;*/
+    
     if(numeric_parameters.at(0) != val_cpt && parameters.at(1) != "rand" && parameters.at(1) != "rande"){
 		
 		Coarsening_Phase(baseg, liste_corr, numeric_parameters.at(0), val_cpt, parameters.at(0));

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

@@ -1074,6 +1074,357 @@ void build_graph_grid(OrientedGraph *go, int side, const std::vector<std::pair<i
 	
 }
 
+void build_example_ligne(OrientedGraph& og)
+{
+	vertex_to v0 = boost::add_vertex(og);
+	vertex_to v1 = boost::add_vertex(og);
+	vertex_to v2 = boost::add_vertex(og);
+	vertex_to v3 = boost::add_vertex(og);
+	vertex_to v4 = boost::add_vertex(og);
+	vertex_to v5 = boost::add_vertex(og);
+	vertex_to v6 = boost::add_vertex(og);
+	vertex_to v7 = boost::add_vertex(og);
+
+	add_edge(v0, v1, EdgeProperties(1.), og);
+	add_edge(v1, v2, EdgeProperties(1.), og);
+	add_edge(v2, v3, EdgeProperties(1.), og);
+	add_edge(v3, v4, EdgeProperties(1.), og);
+	add_edge(v4, v5, EdgeProperties(1.), og);
+	add_edge(v5, v6, EdgeProperties(1.), og);
+	add_edge(v6, v7, EdgeProperties(1.), og);
+
+	og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
+	og[v0] = VertexProperties(0, 1, TOP_PIXEL);
+	og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+	og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+	og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+	og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+	og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+	og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);	
+}
+
+void build_example_grid(OrientedGraph& og)
+{
+	vertex_to v0 = boost::add_vertex(og);
+	vertex_to v1 = boost::add_vertex(og);
+	vertex_to v2 = boost::add_vertex(og);
+	vertex_to v3 = boost::add_vertex(og);
+	vertex_to v4 = boost::add_vertex(og);
+	vertex_to v5 = boost::add_vertex(og);
+	vertex_to v6 = boost::add_vertex(og);
+	vertex_to v7 = boost::add_vertex(og);
+
+	add_edge(v0, v1, EdgeProperties(0.9), og);
+	add_edge(v0, v2, EdgeProperties(0.9), og);
+	add_edge(v0, v3, EdgeProperties(0.1), og);
+	add_edge(v1, v2, EdgeProperties(0.1), og);
+	add_edge(v1, v3, EdgeProperties(0.9), og);
+	add_edge(v2, v3, EdgeProperties(0.9), og);
+	add_edge(v2, v4, EdgeProperties(0.9), og);
+	add_edge(v2, v5, EdgeProperties(0.1), og);
+	add_edge(v3, v4, EdgeProperties(0.1), og);
+	add_edge(v3, v5, EdgeProperties(0.9), og);
+	add_edge(v4, v5, EdgeProperties(0.9), og);
+	add_edge(v4, v6, EdgeProperties(0.9), og);
+	add_edge(v4, v7, EdgeProperties(0.1), og);
+	add_edge(v5, v6, EdgeProperties(0.1), og);
+	add_edge(v5, v7, EdgeProperties(0.9), og);
+	add_edge(v6, v7, EdgeProperties(0.9), og);
+
+	og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
+	og[v0] = VertexProperties(0, 1, TOP_PIXEL);
+	og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+	og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+	og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+	og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+	og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+	og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
+}	
+
+void build_parcellaire_graph(OrientedGraph *go, uint size_max, std::string name)
+{
+	std::vector<std::pair<double,double> > point;
+	OrientedGraph::in_edge_iterator ei, edge_end;
+	double max_distance =  3000;//sqrt(2)*5*size_max/50;
+	double crit = sqrt(2)*5*size_max/1000;
+	
+	std::cout << "distance max : " << max_distance << std::endl;
+	std::cout << "crit : " << crit << std::endl;
+	for(uint i = 0; i < size_max; i++)
+	{	
+		std::pair<double,double> p;
+		p.first = rand()%(size_max*5-0) + 0;
+		p.second = rand()%(size_max*5-0) + 0;
+		point.push_back(p);
+	} 
+	
+	//std::cout << std::endl;
+	sort(point.begin(),point.end());
+	std::vector<std::vector<std::pair<double,uint> > > save_point_distance;
+	
+	for(uint id = 0 ; id < point.size() - 1; id++)
+	{
+		std::vector<std::pair<double,uint> > point_distance, point_distance_sort;
+		//if(name != "multi"){
+			for(uint i = id +1 ; i < point.size(); i++)
+			{
+				std::pair<double,uint> pd;
+				pd.first = distance_t(point.at(id),point.at(i));
+				pd.second = i;
+				point_distance.push_back(pd);
+			}
+		/*}else{
+			for(uint i = 0 ; i < point.size(); i++)
+			{
+				std::pair<double,uint> pd;
+				pd.first = distance_t(point.at(id),point.at(i));
+				pd.second = i;
+				point_distance.push_back(pd);
+			}
+		}*/
+		
+		point_distance_sort = point_distance;
+		
+		sort(point_distance_sort.begin(), point_distance_sort.end());
+		std::vector<uint> deleted;
+		uint t;
+		
+		
+		
+		if(point_distance_sort.size() > 50)
+			t = point_distance_sort.size()/2;
+		else
+			t = point_distance_sort.size();
+		
+		/*if(name != "multi"){*/
+			for(uint i = 0 ; i < t; i++)
+			{
+				if(point_distance_sort.at(i).first < crit)
+					deleted.push_back(point_distance_sort.at(i).second);
+				//std::cout << point_distance_sort.at(i).second << " " << point_distance_sort.at(i).first <<std::endl;
+			}
+		/*}else{
+			for(uint i = 0 ; i < t; i++)
+			{
+				if(point_distance_sort.at(i).first < crit & point_distance_sort.at(i).first != 0)
+					deleted.push_back(point_distance_sort.at(i).second);
+				//std::cout << point_distance_sort.at(i).second << " " << point_distance_sort.at(i).first <<std::endl;
+			}
+		}*/
+		//std::cout<<std::endl;
+		
+		sort(deleted.begin(), deleted.end());
+		std::reverse(deleted.begin(), deleted.end());
+		
+		/*for(uint k = 0 ; k < deleted.size(); k++)
+			std::cout << deleted.at(k) << " " ;
+		std::cout<< std::endl << std::endl;*/
+		
+		/*std::cout << "A : " << std::endl;
+		for(uint pp = 0; pp < point_distance.size(); pp++)
+			std::cout << point_distance.at(pp).second << " ";
+			
+		std::cout<< std::endl << std::endl;*/
+		
+		if(deleted.size() > 1)
+		{
+			//std::cout<<"Deleted"<<std::endl;
+			for(uint del = 0 ; del < deleted.size(); del++)
+			{
+				//std::cout << deleted.at(del) << " ";
+				for(uint idp = 0; idp < point_distance.size(); idp++)
+				{
+					if(point_distance.at(idp).second == deleted.at(del))
+					{
+						//std::cout << idp + id + 1 << std::endl;
+						/*if(name != "multi")
+						{*/
+							point.erase(point.begin() + idp + id + 1);
+							point_distance.erase(point_distance.begin() + idp);
+							for(uint pp = 0; pp < id ; pp++)
+							{
+								save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+								for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+									save_point_distance.at(pp).at(j).second -=1;
+
+							}
+							for(uint j = idp; j < point_distance.size(); j++)
+								point_distance.at(j).second -= 1;
+						/*}else
+						{
+							point.erase(point.begin() + idp);
+							point_distance.erase(point_distance.begin() + idp);
+							for(uint pp = 0; pp < id ; pp++)
+							{
+								save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+								for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+									save_point_distance.at(pp).at(j).second -=1;
+
+							}
+							for(uint j = idp; j < point_distance.size(); j++)
+								point_distance.at(j).second -= 1;
+						}*/
+						break;
+					}
+				}
+			}
+			//std::cout << std::endl;
+		}else if(deleted.size() == 1)
+		{
+			//std::cout<<"Deleted 2"<<std::endl;
+			//std::cout << deleted.at(0) << " ";
+			for(uint idp = 0; idp < point_distance.size(); idp++)
+			{
+				
+				if(point_distance.at(idp).second == deleted.at(0))
+				{
+					/*if(name != "multi")
+					{*/
+						//std::cout << idp + id + 1 << std::endl;
+						point.erase(point.begin() + idp + id + 1);
+						point_distance.erase(point_distance.begin() + idp);
+						for(uint pp = 0; pp < id ; pp++)
+							{
+								save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+								for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+									save_point_distance.at(pp).at(j).second -=1;
+
+							}
+						for(uint j = idp; j < point_distance.size(); j++)
+							point_distance.at(j).second -= 1;
+						//std::cout << " toto " << std::endl;
+						
+					/*}else{
+						point.erase(point.begin() + idp);
+						point_distance.erase(point_distance.begin() + idp);
+						for(uint pp = 0; pp < id  ; pp++)
+						{
+							save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+							for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+								save_point_distance.at(pp).at(j).second -=1;
+						}
+						for(uint j = idp; j < point_distance.size(); j++)
+							point_distance.at(j).second -= 1;
+					}*/
+					break;
+				}
+			}
+			//std::cout << std::endl;
+		}
+		/*std::cout << " B : " << std::endl;
+		for(uint pp = 0; pp < point_distance.size(); pp++)
+			std::cout << point_distance.at(pp).second << " ";
+			
+		std::cout << std::endl << std::endl;*/
+		
+		//sort(point_distance.begin(), point_distance.end());
+		save_point_distance.push_back(point_distance);
+		//std::cout << std::endl;
+	}
+	std::cout << "nombre de sommet" << point.size() << std::endl;
+	
+	
+	for(uint xt = 0; xt < save_point_distance.size(); xt++){
+		//std::cout << "** " << xt << " ** : ";
+		sort(save_point_distance.at(xt).begin(), save_point_distance.at(xt).end());
+		/*for(uint yt = 0; yt < save_point_distance.at(xt).size(); yt++){
+			std::cout << save_point_distance.at(xt).at(yt).first << " ";
+		}
+		std::cout << std::endl;*/
+	}
+	
+	
+	std::vector<vertex_to> Vertexs;
+	for(int i = 0; i < point.size(); i++){
+		vertex_to vo = boost::add_vertex(*go);
+		Vertexs.push_back(vo);
+	}
+	
+	//std::cout << point.size() << std::endl;
+	for(int i = 0; i < point.size() -1; i++){
+		//std::cout << i << std::endl;
+		double dist = 0.;
+		uint xi;
+		
+		//if(name != "multi")
+			xi = 0;
+		/*else
+			xi = 1;*/
+			
+		while(dist < max_distance & xi < save_point_distance.at(i).size())
+		{
+			dist = save_point_distance.at(i).at(xi).first;
+			if(name != "multi")
+				add_edge(Vertexs.at(i), Vertexs.at(save_point_distance.at(i).at(xi).second), EdgeProperties(1.), *go);
+			else{
+				add_edge(Vertexs.at(i), Vertexs.at(save_point_distance.at(i).at(xi).second), EdgeProperties(1.), *go);
+				add_edge(Vertexs.at(save_point_distance.at(i).at(xi).second),Vertexs.at(i), EdgeProperties(1.), *go);
+			}
+			xi++;
+		}
+		(*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
+	}
+	
+	(*go)[Vertexs.at(point.size()-1)] = VertexProperties(point.size()-1, 1., NORMAL_PIXEL);
+	
+	/*std::cout << "ok"<< point.size() << std::endl;
+	for(int i = 0; i < (point.size() - arcs_max); i++)
+	{
+		std::cout << "ok"<< i << " "<< point.size() <<std::endl;
+		Entiers tmp_vector = Random_Sort_Vector2(i+1, point.size());
+		int ac = rand_fini(arcs_min, arcs_max);
+		std::cout << "! " << ac <<std::endl;
+		Entiers arcs;
+		for(uint p = 0; p < ac; p++)
+			arcs.push_back(tmp_vector.at(p));
+		
+		//sort(arcs.begin(),arcs.end());
+		
+		for(uint j = 0; j < arcs.size(); j++)
+			add_edge(Vertexs.at(i), Vertexs.at(arcs.at(j)), EdgeProperties(1.), *go);
+		
+		(*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
+	}
+	
+	std::cout << "ok1"<<std::endl;
+	for(int i = point.size() - arcs_max; i < point.size() - 2; i++)
+	{
+		Entiers tmp_vector = Random_Sort_Vector2(i+1,point.size());
+		int ac = rand_fini(1, 2);
+		Entiers arcs;
+		for(uint p = 0; p < ac; p++)
+			arcs.push_back(tmp_vector.at(p));
+			
+		sort(arcs.begin(),arcs.end());
+		
+		for(uint j = 0; j < arcs.size(); j++)
+			add_edge(Vertexs.at(i), Vertexs.at(arcs.at(j)), EdgeProperties(1.), *go);
+		
+		(*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
+	}
+	std::cout << "ok2"<<std::endl;
+	
+	add_edge(Vertexs.at(point.size()-2), Vertexs.at(point.size()-1), EdgeProperties(1.), *go);
+	(*go)[Vertexs.at(point.size()-2)] = VertexProperties(point.size()-2, 1., NORMAL_PIXEL);
+	(*go)[Vertexs.at(point.size()-1)] = VertexProperties(point.size()-1, 1., NORMAL_PIXEL);*/
+	
+	for(uint i = 0; i< point.size(); i++){
+		bool indic = false;
+		for(tie(ei,edge_end) = in_edges(i,*go); ei != edge_end; ++ei){
+			indic = true;
+			break;
+		}
+		if(indic == false){
+			(*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
+		}else{
+			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
+		}
+		//std::cout<<(*go)[i]._index<<" "<<indic<<" -> "<<(*go)[i]._type<<std::endl;
+	}
+	
+	
+}
+
 /*void build_graph_grid_center(OrientedGraph *go, int side, const std::vector<std::pair<int,int>> &vertex_selection, const Entiers &weight_vertex,const char *edge_weight, bool rec){
 	int nbr_vertex = side*side;
 	std::vector<vertex_to> Vertexs;

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

@@ -48,7 +48,14 @@ void build_graph_grid(OrientedGraph *go, int side,
 				const std::vector<std::pair<int,int>> &vertex_selection,
 				const Entiers &weight_vertex, const char *edge_weight, 
 				bool rec);
+				
 void build_example_linked9(OrientedGraph& og);
+
+void build_example_ligne(OrientedGraph& og);
+
+void build_example_grid(OrientedGraph& og);
+
+void build_parcellaire_graph(OrientedGraph *go, uint size_max, std::string name);
 				
 //void build_corsen_graph(OrientedGraph& graph);
 

+ 10 - 6
src/tests/boost_graph/partitioning/main.cpp

@@ -48,7 +48,7 @@ int main()
 	/*** Génération du graphe ***/
 	
     OrientedGraph *go = new OrientedGraph();
-    std::string type_graph = "linked";
+    std::string type_graph = "parcellaire";
     std::pair<bool,bool> Spectrale = {false,false};
     
     if(type_graph == "grid"){
@@ -81,8 +81,13 @@ int main()
 		//build_generator_graph_linked(go, nbr_sommets, nbr_couches , 2, 3);
 		//Text_generator_graph("file/data_base/linked/linked_50.txt",go);
 		Plot_OrientedGraph(go,"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/grid_500.txt");
-	}else{
-		build_graph(*go, 38);
+	}else if(type_graph == "parcellaire")
+	{
+		build_parcellaire_graph(go, 10000, "mono");
+	}
+	else{
+		build_example_grid(*go);
+		//build_graph(*go, 11);
 	}
 	
 	/*** Comparaison des méthodes par étude du ratio de coupe ***/
@@ -102,11 +107,10 @@ int main()
 	}
 
 	/*** Paramétrage du Multiniveau ***/
-	std::vector<uint> numeric_parameters = {num_vertices(*go), 4, 10};
+	std::vector<uint> numeric_parameters = {num_vertices(*go)/50, 4, 10};
 	std::vector<std::string> parameters = {"HEM", "gggp", "diff", "ratio"};
 	
 	uint nbr_tirage = 1;
-
 	
 	for(uint i = 0 ; i < nbr_tirage ; i++){
 		Edges edge_partie;
@@ -126,7 +130,7 @@ int main()
 			OrientedGraphs graphs = Multiniveau(go, numeric_parameters,
 												parameters, edge_partie ,
 												outputedgeslist, inputedgelist,
-												connections,true, 2);  	
+												connections,false, 2);  	
 												std::cout<<std::endl;
 		}else{
 			OrientedGraphs graphs = Multiniveau(go, numeric_parameters,

+ 25 - 1
src/tests/boost_graph/partitioning/utils.cpp

@@ -3351,7 +3351,7 @@ Entiers Random_Sort_Vector(uint size){
 	Entiers random_order;
 	for (uint i = 0 ; i<  size ; i++)
 		random_order.push_back(i);
-	for (uint j=0 ; j < size-1 ; j++) {
+	for (uint j=0 ; j < random_order.size()-1 ; j++) {
 		int rand_pos = rand()%(size-j)+j;
 		int tmp      = random_order.at(j);
 		random_order.at(j) = random_order.at(rand_pos);
@@ -3361,4 +3361,28 @@ Entiers Random_Sort_Vector(uint size){
 	return random_order;
 }
 
+Entiers Random_Sort_Vector2(uint min, uint size){
+	
+	Entiers random_order;
+	for (uint i = min ; i<  size ; i++)
+		random_order.push_back(i);
+	for (uint j = 0 ; j < random_order.size()-1 ; j++) {
+		int rand_pos = rand()%(random_order.size()-j)+j;
+		int tmp      = random_order.at(j);
+		random_order.at(j) = random_order.at(rand_pos);
+		random_order.at(rand_pos) = tmp;
+	}
+	
+	return random_order;
+}
+
+double distance_t(std::pair<double,double> x, std::pair<double,double> y)
+{	
+	double total = (x.first - y.first) * (x.first - y.first) ;
+	double diff2 = (x.second - y.second) * (x.second - y.second);
+	total +=  diff2;
+	
+	return sqrt(total);
+}
+
 } } } // namespace paradevs tests boost_graph

+ 4 - 0
src/tests/boost_graph/partitioning/utils.hpp

@@ -230,6 +230,10 @@ void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2,
 						std::vector<double> &connection_weight);
 
 Entiers Random_Sort_Vector(uint size);
+Entiers Random_Sort_Vector2(uint min, uint size);
+
+double distance_t(std::pair<double,double> x, std::pair<double,double> y);
+
 } } } // namespace paradevs tests boost_graph
 
 #endif