Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : add the "ring" topology
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 27 Jul 2012 10:04:39 +0000 (12:04 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 27 Jul 2012 10:04:39 +0000 (12:04 +0200)
include/simgrid/platf_generator.h
src/surf/platf_generator.c

index 3b89513..178f61a 100644 (file)
@@ -25,6 +25,7 @@ XBT_PUBLIC(void) platf_graph_heavytailed(unsigned long node_count);
 
 XBT_PUBLIC(void) platf_graph_interconnect_star(void);
 XBT_PUBLIC(void) platf_graph_interconnect_line(void);
+XBT_PUBLIC(void) platf_graph_interconnect_ring(void);
 
 // WARNING : Only for debbugging ; should be removed when platform
 // generation works correctly
index 693e169..1612a80 100644 (file)
@@ -128,6 +128,29 @@ void platf_graph_interconnect_line(void) {
   }
 }
 
+void platf_graph_interconnect_ring(void) {
+  /* Create a simple topology where all nodes are connected along a ring */
+  xbt_dynar_t dynar_nodes = NULL;
+  xbt_node_t graph_node = NULL;
+  xbt_node_t old_node = NULL;
+  xbt_node_t first_node = NULL;
+  unsigned int i;
+
+  dynar_nodes = xbt_graph_get_nodes(platform_graph);
+  xbt_dynar_foreach(dynar_nodes, i, graph_node) {
+    if(i == 0) {
+      // this is the first node, let's keep it somewhere
+      first_node = graph_node;
+    } else {
+      //connect each node to the previous one
+      platf_node_connect(graph_node, old_node);
+    }
+    old_node = graph_node;
+  }
+  //we still have to connect the first and the last node together
+  platf_node_connect(first_node, graph_node);
+}
+
 
 
 /* Functions used to generate interesting random values */