Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : add a function to compute distance between two nodes
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Mon, 30 Jul 2012 12:18:26 +0000 (14:18 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Mon, 30 Jul 2012 12:18:26 +0000 (14:18 +0200)
src/surf/platf_generator.c
src/surf/platf_generator_private.h

index a036770..9fa2ec0 100644 (file)
@@ -65,6 +65,20 @@ void platf_node_connect(xbt_node_t node1, xbt_node_t node2) {
   xbt_graph_new_edge(platform_graph, node1, node2, (void*)link_id);
 }
 
   xbt_graph_new_edge(platform_graph, node1, node2, (void*)link_id);
 }
 
+double platf_node_distance(xbt_node_t node1, xbt_node_t node2) {
+  context_node_t node1_data;
+  context_node_t node2_data;
+  double delta_x;
+  double delta_y;
+  double distance;
+  node1_data = (context_node_t) xbt_graph_node_get_data(node1);
+  node2_data = (context_node_t) xbt_graph_node_get_data(node2);
+  delta_x = node1_data->x - node2_data->x;
+  delta_y = node1_data->y - node2_data->y;
+  distance = sqrt(delta_x*delta_x + delta_y*delta_y);
+  return distance;
+}
+
 void platf_graph_uniform(unsigned long node_count) {
   xbt_dynar_t dynar_nodes = NULL;
   xbt_node_t graph_node = NULL;
 void platf_graph_uniform(unsigned long node_count) {
   xbt_dynar_t dynar_nodes = NULL;
   xbt_node_t graph_node = NULL;
index a1a430f..80a3390 100644 (file)
@@ -14,6 +14,8 @@ void platf_graph_init(unsigned long node_count);
 
 void platf_node_connect(xbt_node_t node1, xbt_node_t node2);
 
 
 void platf_node_connect(xbt_node_t node1, xbt_node_t node2);
 
+double platf_node_distance(xbt_node_t node1, xbt_node_t node2);
+
 double random_pareto(double min, double max, double K, double P, double ALPHA);
 
 #endif      /* SG_PLATF_GEN_PRIVATE_H */
 double random_pareto(double min, double max, double K, double P, double ALPHA);
 
 #endif      /* SG_PLATF_GEN_PRIVATE_H */