10 #ifndef WRENCH_DAGOFTASKS_H
11 #define WRENCH_DAGOFTASKS_H
13 #include <boost/graph/adjacency_list.hpp>
14 #include <boost/graph/breadth_first_search.hpp>
17 #include "wrench/workflow/WorkflowTask.h"
30 struct VertexProperties {
34 const WorkflowTask *task;
40 typedef boost::adjacency_list<boost::listS, boost::vecS, boost::bidirectionalS, VertexProperties> DAG;
45 typedef unsigned long vertex_t;
54 void addVertex(
const WorkflowTask *task);
56 void removeVertex(WorkflowTask *task);
58 void addEdge(WorkflowTask *src, WorkflowTask *dst);
60 void removeEdge(WorkflowTask *src, WorkflowTask *dst);
62 bool doesPathExist(
const WorkflowTask *src,
const WorkflowTask *dst);
63 bool doesEdgeExist(
const WorkflowTask *src,
const WorkflowTask *dst);
65 long getNumberOfChildren(
const WorkflowTask *task);
67 std::vector<WorkflowTask *> getChildren(
const WorkflowTask *task);
69 long getNumberOfParents(
const WorkflowTask *task);
71 std::vector<WorkflowTask *> getParents(
const WorkflowTask *task);
78 class custom_bfs_visitor :
public boost::default_bfs_visitor {
81 const WorkflowTask *target_task;
83 explicit custom_bfs_visitor(
const WorkflowTask *target_task) : boost::default_bfs_visitor() {
84 this->target_task = target_task;
87 template<
typename Vertex,
typename Graph>
88 void discover_vertex(Vertex u, Graph &g) {
89 if (g[u].task == target_task) {
90 throw std::runtime_error(
"path found");
95 std::vector<const WorkflowTask*> task_list;
96 std::unordered_map<const WorkflowTask *, unsigned long> task_map;
109 #endif //WRENCH_DAGOFTASKS_H