I was running the following exercise code in the document :
import dgl
import torch as th
g_list = []
for _ in range(3): # Create three graphs, each with #nodes 4
g = dgl.DGLGraph()
g.add_nodes(4)
g.add_edges([0,1,2,3], [1,2,3,0])
g.ndata[‘h’] = th.rand(4, 3)
g_list.append(g)
bg = dgl.batch(g_list)
print(bg.ndata)
print(bg.batch_size)
print(bg.batch_num_nodes)
print(bg.batch_num_edges)
bg.flatten()
print(bg.batch_size)
print(bg.batch_num_nodes)
print(bg.batch_num_edges)
bg.remove_nodes([1,3,5,7,9,11])
print(bg.ndata)
and the error came: AttributeError: ‘BatchedDGLGraph’ object has no attribute ‘flatten’
Did that mean the function ‘flatten’ had the problem if used in a batched graph? Or there’s
something wrong with the exercise code