def tree1(idtype):
    """Generate a tree
         0
        / \
       1   2
      / \
     3   4
    Edges are from leaves to root.
    """
    g = dgl.graph(([], [])).astype(idtype).to(F.ctx())
    g.add_nodes(5)
    g.add_edges(3, 1)
    g.add_edges(4, 1)
    g.add_edges(1, 0)
    g.add_edges(2, 0)
    g.ndata["h"] = F.tensor([0, 1, 2, 3, 4])
    g.edata["h"] = F.randn((4, 10))
    return g
Generate a tree
         0
        /        1   2
      /      3   4
    Edges are from leaves to root.
    
tests/python/common/test_batch-graph.py