Parcourir la source

Fix: wring copy of graph

Eric Ramat il y a 10 ans
Parent
commit
ff1edce1c8

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

@@ -53,18 +53,18 @@ public:
         UnorientedGraph graph_origin;
 
         // internal examples
-        {
-            build_graph(*g, go);
-            boost::copy_graph(*g, graph_origin);
-        }
-
-        // corsen examples
         // {
-        //     build_corsen_graph(go);
-        //     make_unoriented_graph(go, *g);
+        //     build_graph(*g, go);
         //     boost::copy_graph(*g, graph_origin);
         // }
 
+        // corsen examples
+        {
+            build_corsen_graph(go);
+            make_unoriented_graph(go, *g);
+            boost::copy_graph(*g, graph_origin);
+        }
+
         Edges edge_partie;
         Connections connections;
 
@@ -87,58 +87,58 @@ public:
                                  parent_connections);
         }
 
-        std::cout << "*********************************" << std::endl;
-        std::cout << "Graphs:" << std::endl;
-        for (unsigned int i = 0; i < graphs.size(); ++i) {
-            std::cout << "graph[" << i << "]:" << std::endl;
-            const OrientedGraph& og = graphs[i];
-            OrientedGraph::vertex_iterator it_og, end_og;
-
-            tie(it_og, end_og) = vertices(og);
-            for (; it_og != end_og; ++it_og) {
-                OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
-
-                std::cout << og[*it_og]._index << " -> { ";
-                tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og,
-                                                                     og);
-                for (; neighbour_it != neighbour_end; ++neighbour_it) {
-                    std::cout << og[*neighbour_it]._index << " ";
-                }
-                std::cout << "}" << std::endl;
-            }
-        }
-        {
-            unsigned int i = 0;
-
-            std::cout << "Input edges:" << std::endl;
-            for (InputEdgeList::const_iterator it = input_edges.begin();
-                 it != input_edges.end(); ++it, ++i) {
-                std::cout << "S" << i << " = {";
-                for (InputEdges::const_iterator it2 = it->begin();
-                     it2 != it->end(); ++it2) {
-                    std::cout << " ( " << it2->first << " -> " << it2->second
-                              << " )";
-                }
-                std::cout << " }" << std::endl;;
-            }
-        }
-        {
-            unsigned int i = 0;
-
-            std::cout << "Output edges:" << std::endl;
-            for (OutputEdgeList::const_iterator it = output_edges.begin();
-                 it != output_edges.end(); ++it, ++i) {
-                std::cout << "S" << i << " = {";
-                for (OutputEdges::const_iterator it2 = it->begin();
-                     it2 != it->end(); ++it2) {
-                    std::cout << " ( " << it2->first << " -> " << it2->second
-                              << " )";
-                }
-                std::cout << " }" << std::endl;;
-            }
-        }
+        // std::cout << "*********************************" << std::endl;
+        // std::cout << "Graphs:" << std::endl;
+        // for (unsigned int i = 0; i < graphs.size(); ++i) {
+        //     std::cout << "graph[" << i << "]:" << std::endl;
+        //     const OrientedGraph& og = graphs[i];
+        //     OrientedGraph::vertex_iterator it_og, end_og;
+
+        //     tie(it_og, end_og) = vertices(og);
+        //     for (; it_og != end_og; ++it_og) {
+        //         OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+        //         std::cout << og[*it_og]._index << " -> { ";
+        //         tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og,
+        //                                                              og);
+        //         for (; neighbour_it != neighbour_end; ++neighbour_it) {
+        //             std::cout << og[*neighbour_it]._index << " ";
+        //         }
+        //         std::cout << "}" << std::endl;
+        //     }
+        // }
+        // {
+        //     unsigned int i = 0;
+
+        //     std::cout << "Input edges:" << std::endl;
+        //     for (InputEdgeList::const_iterator it = input_edges.begin();
+        //          it != input_edges.end(); ++it, ++i) {
+        //         std::cout << "S" << i << " = {";
+        //         for (InputEdges::const_iterator it2 = it->begin();
+        //              it2 != it->end(); ++it2) {
+        //             std::cout << " ( " << it2->first << " -> " << it2->second
+        //                       << " )";
+        //         }
+        //         std::cout << " }" << std::endl;;
+        //     }
+        // }
+        // {
+        //     unsigned int i = 0;
+
+        //     std::cout << "Output edges:" << std::endl;
+        //     for (OutputEdgeList::const_iterator it = output_edges.begin();
+        //          it != output_edges.end(); ++it, ++i) {
+        //         std::cout << "S" << i << " = {";
+        //         for (OutputEdges::const_iterator it2 = it->begin();
+        //              it2 != it->end(); ++it2) {
+        //             std::cout << " ( " << it2->first << " -> " << it2->second
+        //                       << " )";
+        //         }
+        //         std::cout << " }" << std::endl;;
+        //     }
+        // }
 
-        std::cout << "*********************************" << std::endl;
+        // std::cout << "*********************************" << std::endl;
 
     }
 

+ 0 - 7
src/tests/boost_graph/models.hpp

@@ -33,8 +33,6 @@
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
-int N;
-
 struct TopPixelParameters
 { };
 
@@ -59,8 +57,6 @@ public:
         // std::cout << TopPixel < SchedulerHandle >::get_name() << " at "
         //           << t << ": dint" << std::endl;
 
-        N++;
-
     }
 
     virtual typename common::DoubleTime::type start(
@@ -142,9 +138,6 @@ public:
                 }
                 ++_received;
                 if (_received == _neighbour_number) {
-
-                    N++;
-
                     _phase = SEND;
                 }
             }

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

@@ -893,7 +893,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
 
     }
 
-    OrientedGraphs Graphes = Graph_Partition(Partition, go, g, outputedgelist,
+    OrientedGraphs Graphes = Graph_Partition(Partition, go, graph_origin, outputedgelist,
                                              inputedgelist, connections);
 
     // std::cout<<std::endl;

+ 22 - 31
src/tests/boost_graph/tests.cpp

@@ -197,18 +197,10 @@ void test(double duration, std::string partitioning_method_name,
                 double t1 = t.elapsed();
 
                 for (unsigned int i = 0; i < 20; ++i) {
-
-                    N = 0;
-
-                    std::cout << "********************" << std::endl;
-
                     partitionning_heap_test(duration, n,
                                             partitioning_method_name,
                                             contraction_coef,
                                             contraction_coef_flag);
-
-                    std::cout << "N=" << N << std::endl;
-
                 }
 
                 double t2 = t.elapsed();
@@ -292,22 +284,23 @@ void test_flat_38()
     std::cout << (t3 - t2) / 20 << std::endl;
 }
 
+const double duration_38 = -1;
+
 void test_partiotining_38()
 {
+    for (int i = 1; i <= 2; ++i) {
+        test(duration_38, "ggp", 2, 16, 2, true, true, i, true);
+        test(duration_38, "gggp_pond", 2, 16, 2, true, true, i, true);
+        test(duration_38, "random", 2, 16, 2, true, true, i, true);
+    }
 
-    test(0, "gggp_pond", 4, 4, 2, false, true, 1, true);
-
-    // for (int i = 1; i <= 2; ++i) {
-    //     test(10000, "ggp", 2, 16, 2, true, true, i, true);
-    //     test(10000, "gggp_pond", 2, 16, 2, true, true, i, true);
-    //     test(10000, "random", 2, 16, 2, true, true, i, true);
-    // }
-
-    // for (int i = 2; i <= 8; i += 2) {
-    //     test(10000, "gggp_pond", 0, 0, 0, true, true, i, false);
-    // }
+    for (int i = 2; i <= 8; i += 2) {
+        test(duration_38, "gggp_pond", 0, 0, 0, true, true, i, false);
+    }
 }
 
+const double corsen_duration = 20;
+
 void test_flat_corsen()
 {
     boost::timer t;
@@ -315,25 +308,23 @@ void test_flat_corsen()
     std::cout << "== CORSEN == " << std::endl;
     std::cout << "flat graph with heap = ";
     for (unsigned int i = 0; i < 20; ++i) {
-        flat_heap_test< CorsenFlatGraphBuilder >(10);
+        flat_heap_test< CorsenFlatGraphBuilder >(corsen_duration);
     }
 
     double t2 = t.elapsed();
 
     std::cout << t2 / 20 << std::endl;
 
-    std::cout << "flat graph with vector = ";
-    for (unsigned int i = 0; i < 20; ++i) {
-        flat_vector_test< CorsenFlatGraphBuilder >(10);
-    }
+    // std::cout << "flat graph with vector = ";
+    // for (unsigned int i = 0; i < 20; ++i) {
+    //     flat_vector_test< CorsenFlatGraphBuilder >(corsen_duration);
+    // }
 
-    double t3 = t.elapsed();
+    // double t3 = t.elapsed();
 
-    std::cout << (t3 - t2) / 20 << std::endl;
+    // std::cout << (t3 - t2) / 20 << std::endl;
 }
 
-const double corsen_duration = 10;
-
 void test_partitioning_corsen()
 {
     test(corsen_duration, "gggp_pond", 2, 32, 2, false, true, 10, true);
@@ -378,10 +369,10 @@ int main()
     srand(7262);
 
     // test_flat_38();
-    test_partiotining_38();
+    // test_partiotining_38();
 
-    // test_flat_corsen();
-    // test_partitioning_corsen();
+    test_flat_corsen();
+    test_partitioning_corsen();
 
     return 0;
 }

+ 1 - 16
src/tests/corsen/tests.cpp

@@ -24,22 +24,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <boost/timer.hpp>
-
-#include <common/RootCoordinator.hpp>
-
 #include "lib/Corsen.hpp"
 
-// #include <tests/boost_graph/models.hpp>
-// #include <tests/boost_graph/graph_builder.hpp>
-// #include <tests/boost_graph/graph_manager.hpp>
-// #include <tests/boost_graph/graph_partitioning.hpp>
-
-// using namespace paradevs::common;
-// using namespace paradevs::common::scheduler;
-// using namespace paradevs::pdevs;
-// using namespace paradevs::tests::boost_graph;
-
 /**
  * \fn void modifyFilesPath(string & absolutePath, vector<string *> & files)
  * \brief Modifie le chemin par défaut des fichiers.
@@ -104,7 +90,6 @@ int main(int argc, char** argv)
                     exit(0);
                 }
                 contextFile.clear();
-                //contextFile.append("data/");
                 contextFile.append(argv[i++]);
                 std::vector<std::string *>context;
                 context.push_back(&contextFile);
@@ -124,7 +109,7 @@ int main(int argc, char** argv)
         Corsen c;
         c.read(files, absolutePath);
         c.buildGraph();
-        // c.display();
+        c.display();
     } catch(std::exception & e) {
         std::cout<<e.what()<<std::endl;
     }