Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modernize cycle detection in DAGs
[simgrid.git] / src / simdag / sd_dotloader.cpp
index f671c63..cfecfe6 100644 (file)
@@ -120,6 +120,12 @@ std::vector<ActivityPtr> create_DAG_from_dot(const std::string& filename)
   agclose(dag_dot);
   fclose(in_file);
 
+  if (not check_for_cycle(dag)) {
+    std::string base = simgrid::xbt::Path(filename).get_base_name();
+    XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.", base.c_str());
+    dag.clear();
+  }
+
   return dag;
 }
 
@@ -350,8 +356,8 @@ std::vector<ActivityPtr> create_DAG_from_dot(const std::string& filename)
   xbt_die("create_DAG_from_dot() is not usable because graphviz was not found.\n"
           "Please install graphviz, graphviz-dev, and libgraphviz-dev (and erase CMakeCache.txt) before recompiling.");
 }
-// namespace s4u
-// namespace simgrid
+// namespace s4u
+// namespace simgrid
 
 xbt_dynar_t SD_dotload(const char *filename) {
   xbt_die("SD_dotload_generic() is not usable because graphviz was not found.\n"