19namespace GraphDrawing {
24 std::stringstream dotStringLabels;
26 std::stringstream dotStringGraph;
30 dotStringLabels <<
"\t" << leaf->fCounter <<
" [label=\"" << leaf->fName <<
"\", style=\"filled\", fillcolor=\""
31 << leaf->fColor <<
"\", shape=\"" << leaf->fShape <<
"\"];\n";
32 if (leaf->fPrevNode) {
33 dotStringGraph <<
"\t" << leaf->fPrevNode->fCounter <<
" -> " << leaf->fCounter <<
";\n";
35 leaf = leaf->fPrevNode;
38 return "digraph {\n" + dotStringLabels.str() + dotStringGraph.str() +
"}";
44 std::stringstream dotStringLabels;
46 std::stringstream dotStringGraph;
48 for (
auto leaf : leaves) {
49 while (leaf && !leaf->fIsExplored) {
50 dotStringLabels <<
"\t" << leaf->fCounter <<
" [label=\"" << leaf->fName
51 <<
"\", style=\"filled\", fillcolor=\"" << leaf->fColor <<
"\", shape=\"" << leaf->fShape
53 if (leaf->fPrevNode) {
54 dotStringGraph <<
"\t" << leaf->fPrevNode->fCounter <<
" -> " << leaf->fCounter <<
";\n";
57 leaf->fIsExplored =
true;
58 leaf = leaf->fPrevNode;
61 return "digraph {\n" + dotStringLabels.str() + dotStringGraph.str() +
"}";
78 std::vector<std::shared_ptr<GraphNode>> nodes;
79 nodes.reserve(actions.size() + edges.size());
81 for (
auto *action : actions)
82 nodes.emplace_back(action->GetGraph());
83 for (
auto *edge : edges)
84 nodes.emplace_back(edge->GetGraph());
89std::shared_ptr<GraphNode>
95 auto duplicateDefineIt = sColumnsMap.find(columnPtr);
96 if (duplicateDefineIt != sColumnsMap.end()) {
97 auto duplicateDefine = duplicateDefineIt->second.lock();
98 return duplicateDefine;
101 auto node = std::make_shared<GraphNode>(
"Define\n" + columnName);
104 sColumnsMap[columnPtr] = node;
112 auto duplicateFilterIt = sFiltersMap.find(filterPtr);
113 if (duplicateFilterIt != sFiltersMap.end()) {
114 auto duplicateFilter = duplicateFilterIt->second.lock();
115 duplicateFilter->SetIsNew(
false);
116 return duplicateFilter;
118 auto filterName = (filterPtr->
HasName() ? filterPtr->
GetName() :
"Filter");
119 auto node = std::make_shared<GraphNode>(filterName);
121 sFiltersMap[filterPtr] = node;
130 auto duplicateRangeIt = sRangesMap.find(rangePtr);
131 if (duplicateRangeIt != sRangesMap.end()) {
132 auto duplicateRange = duplicateRangeIt->second.lock();
133 duplicateRange->SetIsNew(
false);
134 return duplicateRange;
136 auto node = std::make_shared<GraphNode>(
"Range");
139 sRangesMap[rangePtr] = node;
144 const std::vector<std::string> &prevNodeDefines)
146 auto upmostNode = node;
147 const auto &defineNames = colRegister.
GetNames();
148 const auto &defineMap = colRegister.
GetColumns();
149 for (
auto i =
int(defineNames.size()) - 1; i >= 0; --i) {
150 const auto colName = defineNames[i];
151 const bool isAlias = defineMap.find(colName) == defineMap.end();
154 const bool isANewDefine =
155 std::find(prevNodeDefines.begin(), prevNodeDefines.end(), colName) == prevNodeDefines.end();
161 upmostNode->SetPrevNode(defineNode);
162 upmostNode = defineNode;
std::string GetName() const
The head node of a RDF computation graph.
std::vector< RDFInternal::RActionBase * > GetAllActions() const
Return all actions, either booked or already run.
std::vector< RNodeBase * > GetGraphEdges() const
Return all graph edges known to RLoopManager This includes Filters and Ranges but not Defines.
void Jit()
Add RDF nodes that require just-in-time compilation to the computation graph.
static FiltersNodesMap_t & GetStaticFiltersMap()
Stores the filters defined and which node in the graph defined them.
static DefinesNodesMap_t & GetStaticColumnsMap()
Stores the columns defined and which node in the graph defined them.
std::string FromGraphLeafToDot(std::shared_ptr< GraphNode > leaf)
Starting from any leaf (Action, Filter, Range) it draws the dot representation of the branch.
std::string FromGraphActionsToDot(std::vector< std::shared_ptr< GraphNode > > leaves)
Starting by an array of leaves, it draws the entire graph.
std::string RepresentGraph(ROOT::RDataFrame &rDataFrame)
Starting from the root node, prints the entire graph.
static RangesNodesMap_t & GetStaticRangesMap()
Stores the ranges defined and which node in the graph defined them.
A binder for user-defined columns and aliases.
const DefinesMap_t & GetColumns() const
Returns a map of pointers to the defined columns.
ColumnNames_t GetNames() const
Returns the list of the names of the defined columns (Defines + Aliases).
RLoopManager * GetLoopManager() const
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
std::shared_ptr< GraphNode > CreateDefineNode(const std::string &columnName, const ROOT::Detail::RDF::RDefineBase *columnPtr)
std::shared_ptr< GraphNode > CreateRangeNode(const ROOT::Detail::RDF::RRangeBase *rangePtr)
std::shared_ptr< GraphNode > AddDefinesToGraph(std::shared_ptr< GraphNode > node, const RColumnRegister &colRegister, const std::vector< std::string > &prevNodeDefines)
Add the Defines that have been added between this node and the previous to the graph.
std::shared_ptr< GraphNode > CreateFilterNode(const ROOT::Detail::RDF::RFilterBase *filterPtr)
bool IsInternalColumn(std::string_view colName)
Whether custom column with name colName is an "internal" column such as rdfentry_ or rdfslot_.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...