The assignment behavior of DGLGraph.dstdata is wrong in some cases
- Dominant language
- Python
- Stars
- 14.3k
- Forks
- 3.1k
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug
## To Reproduce
Steps to reproduce the behavior:
```python
import dgl
from openhgnn.dataset.gtn_dataset import ACM4GTNDataset
graph = dgl.to_block(ACM4GTNDataset()[0])
print(graph)
print(graph.dstdata["label"])
graph.dstdata["label_copy"] = graph.dstdata["label"]
print(graph.dstdata["label_copy"])
print(graph.srcdata["label_copy"])
graph.dstnodes["paper"].data["label_copy"] = next(iter(graph.dstdata["label"].values()))
print(graph.dstdata["label_copy"])
```
## Expected behavior
You can see that the attribute directly assigned to dstdata can't be found by querying dstdata. On the contrary, it is amazing to find this attribute in srcdata. I checked the code of HeteroNodeDataView and found that, The ntid used by self._graph._set_n_repr is through self._graph.get_ntype_id(ntype), but in get_ntype_id, ntid = self. _ srctypes _ invmap.get (ntype, Self. _ dsttypes _ invmap.get (ntype, none)), that is to say, the obtained ntid gives priority to srctypes, so this bug will be triggered if ntype appears in both the source node and the destination node.
## Environment
- DGL Version : 2.2.1
- Backend Library & Version : Pytorch 2.3.0
- OpenHGNN Version: 0.4.2
- OS : Linux
- How you installed DGL : conda
- Python version: 3.12.3
- CUDA/cuDNN version (if applicable): 11.8
- GPU models and configuration : nvidia 3090
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.