#include "graphviz.hpp" #include "workflow_graph.hpp" namespace xios { CGraphviz::CGraphviz() { } /*! * */ void CGraphviz::buildWorkflowGraphDot() TRY { if (CWorkflowGraph::mapFieldToFilters_ptr_with_info !=0 && !CWorkflowGraph::mapFieldToFilters_ptr_with_info->empty()) { CWorkflowGraph::buildStaticWorkflow(); typedef boost::property EdgeProperty; typedef boost::adjacency_list Graph; // Input 1: nodes (=filters) vector& nodes = CWorkflowGraph::filters; const int nbNodes = nodes.size(); // Input 2: edges (=fields) vector& edges = CWorkflowGraph::fields; // Input 3: nodes to edges connectivity vector >& nodesToEdges = CWorkflowGraph::fieldsToFilters; const int nbEdges = nodesToEdges.size(); // Declare a graph object, adding the edges and edge properties Graph g(nbNodes); for (int j = 0; j < nbEdges; ++j) { graph_traits::edge_descriptor e; bool inserted; boost::tie(e, inserted) = boost::add_edge(nodesToEdges[j].first, nodesToEdges[j].second, edges[j], g); } std::for_each(vertices(g).first, vertices(g).second, exercise_vertex(g)); std::map graph_attr, vertex_attr, edge_attr; graph_attr["size"] = "5,5"; graph_attr["rankdir"] = "LR"; graph_attr["ratio"] = "fill"; vertex_attr["shape"] = "record"; vertex_attr["width"] = "2.2"; vertex_attr["fontsize"] = "16"; const std::string filename = "graph.dot"; std::ofstream file (filename.c_str()); boost::write_graphviz(file, g, boost::make_label_writer(&nodes[0]), boost::make_label_writer(get(edge_name, g)), boost::make_graph_attributes_writer(graph_attr, vertex_attr, edge_attr)); } } CATCH void CGraphviz::buildWorkflowGraphVisjs_with_info() TRY { if (CWorkflowGraph::mapFilters_ptr_with_info !=0 && !CWorkflowGraph::mapFilters_ptr_with_info->empty()) { CWorkflowGraph::buildStaticWorkflow_with_info(); int nbGraphContext = CWorkflowGraph::mapContext_ptr->size(); StdString color_table[7] = {"black", "red", "blue", "green", "purple", "yellow", "gray"}; std::ofstream fs_json[nbGraphContext]; for (std::unordered_map::const_iterator it = CWorkflowGraph::mapContext_ptr->begin(); it != CWorkflowGraph::mapContext_ptr->end(); ++it) { fs_json[it->second].open ("graph_data_"+it->first+".json", std::fstream::out); fs_json[it->second] << "{\"nodes\":["<begin(); it != CWorkflowGraph::mapFilters_ptr_with_info->end(); it++) { int index = (*CWorkflowGraph::mapContext_ptr)[it->second.node_context_id]; if(firstnodes[index]) { fs_json[index] << "{\"id\": "<first +1<<", "<first +1<<", "<second.filter_class == 1) // source filter fs_json[index] << " \"label\": \""<second.filter_name<<"\\n("<second.field_id<<")\", "<second.filter_name<<"\", "<second.filter_class<<", "<second.filter_filled<<", "<second.transform_type<<"\", "<second.expected_entry_nb<<", "<second.inputs_complete<<", "<second.filter_tag<<", "<second.clusterID<<", "<second.distance<<", "<second.node_context_id<<"\", "<second.attributes<<"\"}"<begin(); it != CWorkflowGraph::mapFieldToFilters_ptr_with_info->end(); it++) { int index = (*CWorkflowGraph::mapContext_ptr)[it->second.edge_context_id]; if(firstedges[index]) { fs_json[index] << "{\"id\": "<first +1<<", "<first +1<<", "<second.from+1<<", "<second.to+1<<", "<second.field_id<<"\\n"<second.date<<"\", "<second.field_id<<"\", "<second.field_name<<"\", "<second.grid_id<<"\", "<second.date<<"\", "<second.edge_context_id<<"\", "<"<second.attributes<<"\"}"<