Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : Add some debug
[simgrid.git] / src / surf / platf_generator.c
index c8f4937..3a2e44b 100644 (file)
@@ -9,6 +9,14 @@ static xbt_graph_t platform_graph = NULL;
 
 static RngStream rng_stream = NULL;
 
+static unsigned long last_link_id = 0;
+
+xbt_graph_t platf_graph_get(void) {
+  // We need some debug, so let's add this function
+  // WARNING : shold be removed when it becomes useless
+  return platform_graph;
+}
+
 void platf_random_seed(unsigned long seed[6]) {
 
   if(rng_stream == NULL) {
@@ -20,8 +28,8 @@ void platf_random_seed(unsigned long seed[6]) {
   }
 }
 
-void platf_graph_init(int node_count) {
-  int i;
+void platf_graph_init(unsigned long node_count) {
+  unsigned long i;
   platform_graph = xbt_graph_new_graph(FALSE, NULL);
   if(rng_stream == NULL) {
     rng_stream = RngStream_CreateStream(NULL);
@@ -30,12 +38,16 @@ void platf_graph_init(int node_count) {
   for(i=0 ; i<node_count ; i++) {
     context_node_t node_data = NULL;
     node_data = xbt_new(s_context_node_t, 1);
+    node_data->id = i+1;
     node_data->x = 0;
     node_data->y = 0;
     node_data->degree = 0;
     node_data->kind = ROUTER;
     xbt_graph_new_node(platform_graph, (void*) node_data);
   }
+
+  last_link_id = 0;
+
 }
 
 void platf_node_connect(xbt_node_t node1, xbt_node_t node2) {
@@ -45,10 +57,14 @@ void platf_node_connect(xbt_node_t node1, xbt_node_t node2) {
   node2_data = (context_node_t) xbt_graph_node_get_data(node2);
   node1_data->degree++;
   node2_data->degree++;
-  xbt_graph_new_edge(platform_graph, node1, node2, NULL);
+
+  unsigned long *link_id = xbt_new(unsigned long, 1);
+  *link_id = ++last_link_id;
+
+  xbt_graph_new_edge(platform_graph, node1, node2, (void*)link_id);
 }
 
-void platf_graph_uniform(int node_count) {
+void platf_graph_uniform(unsigned long node_count) {
   xbt_dynar_t dynar_nodes = NULL;
   xbt_node_t graph_node = NULL;
   context_node_t node_data = NULL;