18 #include <flecsi-config.h> 22 #if defined(FLECSI_ENABLE_GRAPHVIZ) 23 #include "flecsi/util/graphviz.hh" 42 template<
typename NodePolicy>
43 struct node : NodePolicy, std::list<node<NodePolicy> const *> {
45 template<
typename... Args>
46 node(std::string
const & label, Args &&... args)
47 : NodePolicy(std::forward<Args>(args)...), label_(label) {
48 const void * address =
static_cast<const void *
>(
this);
51 identifier_ = ss.str();
54 std::string
const & identifier()
const {
58 std::string
const & label()
const {
63 std::string identifier_;
73 template<
typename NodePolicy>
74 struct dag : std::vector<dag_impl::node<NodePolicy> *> {
78 dag(
const char * label =
"empty") : label_(label) {}
84 std::string
const &
label()
const {
94 std::vector<node_type const *>
sort() {
95 std::vector<node_type const *> sorted;
98 std::list<node_type *> nodes;
106 std::queue<node_type *> q;
107 for(
auto n = nodes.begin(); n != nodes.end();) {
108 if((*n)->size() == 0) {
119 const auto root = q.front();
120 sorted.push_back(root);
123 for(
auto n = nodes.begin(); n != nodes.end();) {
124 auto it = std::find_if((*n)->begin(),
126 [&root](
const auto p) {
return root == p; });
128 if(it != (*n)->end()) {
144 flog_assert(count == this->size(),
"sorting failed. This is not a DAG!!!");
149 #if defined(FLECSI_ENABLE_GRAPHVIZ) 155 std::map<uintptr_t, Agnode_t *> node_map;
157 for(
auto n : *
this) {
159 auto * node = gv.add_node(n->identifier().c_str(), n->label().c_str());
160 node_map[uintptr_t(n)] = node;
162 gv.set_node_attribute(node,
"color",
"black");
163 gv.set_node_attribute(node,
"style",
"filled");
164 gv.set_node_attribute(node,
"fillcolor",
color);
167 for(
auto n : *
this) {
170 gv.add_edge(node_map[uintptr_t(e)], node_map[uintptr_t(n)]);
171 gv.set_edge_attribute(edge,
"penwidth",
"1.5");
176 #endif // FLECSI_ENABLE_GRAPHVIZ Definition: graphviz.hh:91
#define flog_assert(test, message)
Definition: flog.hh:411
std::string const & label() const
Definition: dag.hh:84
size_t color()
Definition: execution.hh:326
std::vector< node_type const * > sort()
Definition: dag.hh:94
Definition: control.hh:31