AttributeError: 'DGLGraph' object has no attribute 'adj_external'

I have a DGLGraph obeject g, which comes from:

g = DglNodePropPredDataset(name='ogbn-mag')[0]

and print g:

Graph(num_nodes={'author': 1134649, 'field_of_study': 59965, 'institution': 8740, 'paper': 736389},
      num_edges={('author', 'affiliated_with', 'institution'): 1043998, ('author', 'writes', 'paper'): 7145660, ('paper', 'cites', 'paper'): 5416271, ('paper', 'has_topic', 'field_of_study'): 7505078},
      metagraph=[('author', 'institution', 'affiliated_with'), ('author', 'paper', 'writes'), ('paper', 'paper', 'cites'), ('paper', 'field_of_study', 'has_topic')]), {'paper': tensor([[246],
        [131],
        [189],
        ...,
        [266],
        [289],
        [  1]])})

the result shows that g is a Graph object indeed. But when I call g.adj_external(etype='writes'), it raises AttributeError.
My dgl version is 1.0.0+cu113.

Change g = DglNodePropPredDataset(name='ogbn-mag')[0] to g, _ = DglNodePropPredDataset(name="ogbn-mag")[0]

Example:

dataset = DglNodePropPredDataset(name="ogbn-mag")
g, labels = dataset[0]
# or: g, _ = DglNodePropPredDataset(name="ogbn-mag")[0]
a = g.adj_external(etype='writes')
print(a)

Output:

tensor(indices=tensor([[      0,       0,       0,  ..., 1134647, 1134648,
                        1134648],
                       [  19703,  289285,  311768,  ...,  657395,  671118,
                         719594]]),
       values=tensor([1., 1., 1.,  ..., 1., 1., 1.]),
       size=(1134649, 736389), nnz=7145660, layout=torch.sparse_coo)

I follow your instruction to modify my code:

g, _ = dataset[0]
a = g.adj_external(etype='writes')
print(a)

but still get the same error.

AttributeError: 'DGLGraph' object has no attribute 'adj_external'

my dgl version is 1.0.0+cu113.

Ops, I call g.adj(etype='writes'), it works.
I think 1.0.0+cu113 this dgl version is different from 1.0.0.

Thanks for your help!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.