From: Jean-Baptiste Hervé Date: Mon, 30 Jul 2012 12:18:26 +0000 (+0200) Subject: Platform generation : add a function to compute distance between two nodes X-Git-Tag: v3_8~253 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/44480183884d6b451563acf89a07741f7684d752 Platform generation : add a function to compute distance between two nodes --- diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index a0367701ad..9fa2ec06b5 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -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); } +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; diff --git a/src/surf/platf_generator_private.h b/src/surf/platf_generator_private.h index a1a430f47c..80a3390891 100644 --- a/src/surf/platf_generator_private.h +++ b/src/surf/platf_generator_private.h @@ -14,6 +14,8 @@ void platf_graph_init(unsigned long node_count); 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 */