-
Notifications
You must be signed in to change notification settings - Fork 0
/
TaskGraph.h
65 lines (47 loc) · 1.11 KB
/
TaskGraph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// Created by hejia on 8/22/19.
//
#ifndef WECOOK_ACTIONGRAPH_H
#define WECOOK_ACTIONGRAPH_H
#include "ActionNode.h"
#include "PrimitiveTaskGraph.h"
namespace wecook {
class TaskGraph {
public:
TaskGraph(const std::vector<Action> &actionSeq) {
int i = 0;
for (auto &action : actionSeq) {
i += 1;
if (i == 6) {
addNode(action, true);
} else {
addNode(action);
}
}
}
virtual ~TaskGraph() {
for (auto node : m_nodes) {
delete(node);
}
}
void addNode(const Action& action, bool ifEnd=false);
void addArc();
void visualize();
inline std::vector<ActionNode *> getNodes() {
return m_nodes;
}
inline std::vector<ActionNode *> getHeads() {
return m_heads;
}
inline ActionNode * getHeadNode(const std::string &pid) {
return m_headMap[pid];
}
void merge();
private:
ActionNode *findFatherNode(const std::string &pid);
std::vector<ActionNode *> m_heads;
std::vector<ActionNode *> m_nodes;
std::map<std::string, ActionNode *> m_headMap; // head action node for every agent
};
}
#endif //WECOOK_ACTIONGRAPH_H