Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : Add a function to remove links in the graph
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Mon, 6 Aug 2012 09:23:00 +0000 (11:23 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Mon, 6 Aug 2012 09:23:00 +0000 (11:23 +0200)
include/simgrid/platf_generator.h
src/surf/platf_generator.c

index 963603d..3d83157 100644 (file)
@@ -57,6 +57,8 @@ XBT_PUBLIC(void) platf_graph_interconnect_barabasi(void);
 
 XBT_PUBLIC(int) platf_graph_is_connected(void);
 
+XBT_PUBLIC(void) platf_graph_clear_links(void);
+
 XBT_PUBLIC(void) platf_graph_promote_to_host(context_node_t node, sg_platf_host_cbarg_t parameters);
 XBT_PUBLIC(void) platf_graph_promote_to_cluster(context_node_t node, sg_platf_cluster_cbarg_t parameters);
 
index 90047bb..1eb8843 100644 (file)
@@ -317,6 +317,28 @@ int platf_graph_is_connected(void) {
   return TRUE;
 }
 
+void platf_graph_clear_links(void) {
+  xbt_dynar_t dynar_nodes = NULL;
+  xbt_dynar_t dynar_edges = NULL;
+  xbt_node_t graph_node = NULL;
+  xbt_edge_t graph_edge = NULL;
+  context_node_t node_data = NULL;
+  unsigned int i;
+
+  //Delete edges from the graph
+  dynar_edges = xbt_graph_get_edges(platform_graph);
+  xbt_dynar_foreach(dynar_edges, i, graph_edge) {
+    xbt_graph_free_edge(platform_graph, graph_edge, xbt_free);
+  }
+
+  //All the nodes will be of degree 0
+  dynar_nodes = xbt_graph_get_nodes(platform_graph);
+  xbt_dynar_foreach(dynar_nodes, i, graph_node) {
+    node_data = xbt_graph_node_get_data(graph_node);
+    node_data->degree = 0;
+  }
+}
+
 void platf_graph_promote_to_host(context_node_t node, sg_platf_host_cbarg_t parameters) {
   node->kind = HOST;
   memcpy(&(node->host_parameters), parameters, sizeof(s_sg_platf_host_cbarg_t));