Questions about remove_self_loop

the remove_self_loop function only creates a new graph with only the information of edge index and node conectivity. Those ndata and edata are both dropped after this function.
But I only want to discard the selp_loop edges and the relative edata while preserving other informations.
How could I do it?
remove_self_loop: https://docs.dgl.ai/_modules/dgl/transform.html#remove_self_loop

I have modified the original remove_self_loop code, and it works.

def remove_self_loop(g):
src, dst = g.all_edges(order=“eid”)
self_loop_eid = torch.nonzero(src==dst).squeeze()
g.readonly(False)
g.remove_edges(self_loop_eid)
g.readonly(True)
return g

I want to dismiss the self_loop data while doing the reduce function with node.mailbox['feats'], Is it a proper way to remove self_loop of graph first, like what I did above ?

Please checkout our remove_self_loop in the master branch (or see the latest version of documentation: https://docs.dgl.ai/en/latest/generated/dgl.transform.remove_self_loop.html#dgl.transform.remove_self_loop), the ndata and edata are preserved.

my dgl version is 0.5a200710, after using dgl.remove_self_loop(), the ndata and edata are discarded. I downloaded the dgl package by pip download --pre dgl-cu102 on July 29. It seems that I am not using the master branch?

HI,

Sorry for the problem. Our nightly build was broken during the past month and it’s fixed now. Could you try pip install --upgrade --pre dgl-cuXX again?

Thanks for your answer. hahaha. I will re-download the latest version.

It raises an error AttributeError: 'DGLGraph' object has no attribute 'to_canonical_etype' when I run dgl.remove_self_loop after reinstalling the nightly build.
Current dgl version is 0.5a200804.
Now while passing the graph into dgl.sampling.NodeDataLoader, an error named AttibuteError:'DGLGraph' object has no attribute 'ntypes' is raised whiling the code is running at the point of init function of NodeCollator.

Hi, what dataset you are using?
I think removing the cached data in the disk would help.

Hi,

The cached file is at ~/.dgl folder

The graph was built and stored while I am using 0.5a200710. I have known that in 0.5a200804DGLGraph and HeteroGraph have been merged into a new kind of data structure. I tested on a small and newly built graph and it works. So I think the only answer is to re-build the graph.

Yes you are right, we have merged HeteroGraph and DGLGraph, if you have cached graph on the disk, its type would be old DGLGraph thus not compatible with latest version of DGL.