Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : Add a function to remove links in the graph
[simgrid.git] / src / surf / platf_generator.c
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));