I want to convert from a heterogeneous graph to a homogeneous graph while maintaining edata.
I referred to the two documents below.
However, it failed to pass the edata together.
>>> g = dgl.heterograph({
... ('drug', 'interacts', 'drug'): (th.tensor([0, 1]), th.tensor([1, 2])),
... ('drug', 'treats', 'disease'): (th.tensor([1]), th.tensor([2]))})
>>> g.nodes['drug'].data['hv'] = th.zeros(3, 1)
>>> g.nodes['disease'].data['hv'] = th.ones(3, 1)
>>> g.edges['interacts'].data['he'] = th.zeros(2, 1)
>>> hg = dgl.to_homogeneous(g, edata=['he'])
>>> hg.edata
{'_ID': tensor([0, 1, 0]), '_TYPE': tensor([0, 0, 1])} # there is no edata['he']
However, it is possible to pass ndata.
>>> hg = dgl.to_homogeneous(g, ndata=['hv'])
>>> hg.ndata
{'hv': tensor([[1.],
[1.],
[1.],
[0.],
[0.],
[0.]]), '_ID': tensor([0, 1, 2, 0, 1, 2]), '_TYPE': tensor([0, 0, 0, 1, 1, 1])}
How can I solve it?
https://docs.dgl.ai/en/latest/generated/dgl.to_homogeneous.html?highlight=to_homogeneous
https://docs.dgl.ai/en/latest/guide/graph-heterogeneous.html?highlight=to_homogeneous