From e93baa98dc235c0aee125a6a2ad7c300fb92645c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Baptiste=20Herv=C3=A9?= Date: Mon, 6 Aug 2012 09:33:08 +0200 Subject: [PATCH] Platform generation : add a function to check if the graph is connected --- include/simgrid/platf_generator.h | 2 ++ src/surf/platf_generator.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/simgrid/platf_generator.h b/include/simgrid/platf_generator.h index 38476fc0d7..963603d34e 100644 --- a/include/simgrid/platf_generator.h +++ b/include/simgrid/platf_generator.h @@ -55,6 +55,8 @@ XBT_PUBLIC(void) platf_graph_interconnect_zegura(double alpha, double beta, doub XBT_PUBLIC(void) platf_graph_interconnect_waxman(double alpha, double beta); XBT_PUBLIC(void) platf_graph_interconnect_barabasi(void); +XBT_PUBLIC(int) platf_graph_is_connected(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 1726e963b2..90047bbb35 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -302,6 +302,21 @@ void platf_graph_interconnect_barabasi(void) { } } +int platf_graph_is_connected(void) { + xbt_dynar_t dynar_nodes = NULL; + xbt_node_t graph_node = NULL; + context_node_t node_data = NULL; + unsigned int i; + 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); + if(node_data->degree==0) { + return FALSE; + } + } + return TRUE; +} + 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