Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : add a function to check if the graph is connected
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Mon, 6 Aug 2012 07:33:08 +0000 (09:33 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Mon, 6 Aug 2012 07:33:08 +0000 (09:33 +0200)
include/simgrid/platf_generator.h
src/surf/platf_generator.c

index 38476fc..963603d 100644 (file)
@@ -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);
 
index 1726e96..90047bb 100644 (file)
@@ -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));