# RDataFrame SaveGraph root node

**URL:** <https://root-forum.cern.ch/t/rdataframe-savegraph-root-node/32821>\
**Category:** Newbie\
**Tags:** rdataframe, python\
**Created:** [February 20, 2019, 2:25pm UTC](https://root-forum.cern.ch/t/rdataframe-savegraph-root-node/32821 "2019-02-20T14:25:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwiel](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/ea666f/32.png) [@cwiel](https://root-forum.cern.ch/u/cwiel)\
**Post date:** [February 20, 2019, 2:25pm UTC](https://root-forum.cern.ch/t/rdataframe-savegraph-root-node/32821/1 "2019-02-20T14:25:11Z")

</div>

Hi,

I am very happy about the new RDataFrame and am using it frequently.

I am using `RDataFrame` with PyROOT in version `6.16.00`.

I want to apply some Filters to the RDataFrame and then visualize all filter nodes with the `ROOT.RDF.SaveGraph()` function.

From the documentation I get, that for this I have to call the function on the head node. But by doing this I get only an empty `.dot` file. Calling the function on a daughter node on the other hand produces the expected (sub)graph.

I am using the following code to get this result:

```auto
import ROOT
import numpy as np

def fill_tree(treeName, fileName):
    ROOT.gRandom.SetSeed(1)
    tdf = ROOT.ROOT.RDataFrame(100)
    tdf.Define("b1", "gRandom->Gaus()")\
       .Define("b2", "gRandom->Gaus()")\
       .Define("b3", "gRandom->Gaus()")\
       .Define("b4", "gRandom->Gaus()")\
       .Snapshot(treeName, fileName)

def fslice(frame, binedges, varname):
    if binedges == ():
        return ()

    left, right = np.array_split(binedges, 2)

    if len(left) == 0:
        return ()

    splitval = left[-1]
    
    if len(left) == 1:
        return (
            frame.Filter(
                "{1} < {0}".format(splitval, varname), 
                "{1} < {0}".format(splitval, varname)), 
            frame.Filter(
                "{1} > {0}".format(splitval, varname), 
                "{1} > {0}".format(splitval, varname))
            )
    else:
        return fslice(
            frame.Filter(
                "{1} < {0}".format(splitval, varname), 
                "{1} < {0}".format(splitval, varname)),
            left[:-1],
            varname
            ) + fslice(
            frame.Filter(
                "{1} > {0}".format(splitval, varname), 
                "{1} > {0}".format(splitval, varname)),
            right,
            varname)

treeName = 'tree'
fileName = treeName+".root"
fill_tree(treeName, treeName+".root")

f = ROOT.ROOT.RDataFrame(treeName, fileName)
ROOT.RDF.SaveGraph(f, "graph.dot")

frames = fslice(f, np.linspace(-1,1,6), "b1")

ROOT.RDF.SaveGraph(frames[-1], "graph1.dot")
ROOT.RDF.SaveGraph(f, "graph2.dot")

```

Even with a very simple

```auto
f = ROOT.ROOT.RDataFrame(treeName, fileName)
f2 = f.Filter("b2 > 2.")
ROOT.RDF.SaveGraph(f, "graph.dot")

```

I get only a empty graph.dot file with:

```auto
digraph {
}

```

Can somebody help me getting the complete graphs?

Cheers,  
Christian

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [February 20, 2019, 3:46pm UTC](https://root-forum.cern.ch/t/rdataframe-savegraph-root-node/32821/2 "2019-02-20T15:46:32Z")

</div>

Hi Christian,  
this is a bug! I filed a ticket at [https://sft.its.cern.ch/jira/browse/ROOT-9977](https://sft.its.cern.ch/jira/browse/ROOT-9977) , please follow the development there. And please feel free to ping us there if you don’t see any movement in a few weeks.

Cheers,  
Enrico
