From 5f7c51482a19d278ce0afc1924d1c55b41d2f8a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Baptiste=20Herv=C3=A9?= Date: Mon, 6 Aug 2012 11:23:00 +0200 Subject: [PATCH] Platform generation : Add a function to remove links in the graph --- include/simgrid/platf_generator.h | 2 ++ src/surf/platf_generator.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/simgrid/platf_generator.h b/include/simgrid/platf_generator.h index 963603d34e..3d831573bc 100644 --- a/include/simgrid/platf_generator.h +++ b/include/simgrid/platf_generator.h @@ -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); diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index 90047bbb35..1eb8843557 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -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)); -- 2.20.1