pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.33k stars 3.66k forks source link

Check the duplicated edges in the graph #9654

Closed guanshaoheng closed 1 month ago

guanshaoheng commented 1 month ago

🚀 The feature, motivation and pitch

Before removing duplicate edges, we can use this function to extract and inspect all the duplicates. This is particularly useful for designing the graph network and for debugging, as edges can easily become duplicated when selected by nodes. In calculations, these duplicate edges can impact the network’s predictions…

Alternatives

No response

Additional context

No response

guanshaoheng commented 1 month ago

maybe making some modifications to the function torch_geometric.utils.coalesce can work

rachitk commented 1 month ago

There is a transform RemoveDuplicatedEdges that should in theory do this - is there additional functionality that you'd need?

https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.transforms.RemoveDuplicatedEdges.html

As you mentioned, the transform just calls coalesce: https://pytorch-geometric.readthedocs.io/en/latest/modules/utils.html#torch_geometric.utils.coalesce