Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Fat Trees] Function generating dot files should be working,
authorStéphane Castelli <stephane.castelli@loria.fr>
Wed, 16 Apr 2014 07:47:06 +0000 (09:47 +0200)
committerStéphane Castelli <stephane.castelli@loria.fr>
Wed, 16 Apr 2014 07:47:06 +0000 (09:47 +0200)
yet to be tested
FatTreeLink got its members public

src/surf/surf_routing_cluster_fat_tree.cpp
src/surf/surf_routing_cluster_fat_tree.hpp

index f852c36..44fa45b 100644 (file)
@@ -134,25 +134,24 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t
 void AsClusterFatTree::generateDotFile(string filename) {
   ofstream file;
   /* Maybe should we get directly a char*, as open takes strings only beginning
-   * with c++11...
+   * with C++11...
    */
   file.open(filename.c_str(), ios::out | ios::trunc); 
   
   if(file.is_open()) {
-    /* TODO : Iterate through a map takes 10 chars with c++11, 100 with c++98.
-     * All I have to do is write it down...
-     */
-
-    // file << "graph AsClusterFatTree {\n";
-    // for (std::map<std::pair<int,int>, FatTreeLink*>::iterator link = this->links.begin() ; link != this->links.end() ; link++ ) {
-    //   for (int j = 0 ; j < link->ports ; j++) {
-    //   file << this->links[i]->source.id 
-    //        << " -- " this->links[i]->destination.id
-    //        << ";\n";
-    //   }
-    // }
-    // file << "}";
-    // file.close();
+    // That could also be greatly clarified with C++11
+    std::map<std::pair<int,int>,FatTreeLink*>::iterator iter;
+    file << "graph AsClusterFatTree {\n";
+    for (iter = this->links.begin() ; iter != this->links.end() ; iter++ ) {
+      for (int j = 0 ; j < iter->second->ports ; j++) {
+        file << iter->second->source.id 
+             << " -- " 
+             << iter->second->destination.id
+             << ";\n";
+      }
+    }
+    file << "}";
+    file.close();
   }
   else {
     std::cerr << "Unable to open file " << filename << std::endl;
index 96ba5c9..1c8a865 100644 (file)
@@ -34,15 +34,13 @@ public:
 };
 
 class FatTreeLink {
-private:
+public:
   unsigned int ports;
   std::vector<NetworkLink> linksUp; // From source to destination
   std::vector<NetworkLink> linksDown; // From destination to source
   FatTreeNode source;
   FatTreeNode destination;
-public:
   FatTreeLink(int source, int destination, unsigned int ports = 0);
-  NetworkLink getLink(int number = 0) const;
 };
 
 class AsClusterFatTree : public AsCluster {