Pytorch_geometric: Remove isolated nodes

Created on 22 Jul 2019  ·  3Comments  ·  Source: rusty1s/pytorch_geometric

is there any function to remove isolated nodes?
i find that modelNet40 containes much more ioslated nodes

feature

Most helpful comment

Added to master.

All 3 comments

There currently is no such functionality in PyTorch Geometric, although this is a good feature request. In the meantime, you can remove isolated nodes by yourself, e.g., with the following (untested) code:

mask = torch.zeros(num_nodes, dtype=torch.uint8)
mask[edge_index.flatten()] = 1

assoc = torch.full((num_nodes, ), -1, dtype=torch.long))
assoc[mask] = torch.arange(mask.sum())

new_edge_index = assoc[edge_index]
new_x = x[mask]
new_pos = pos[mask]

Added to master.

And a transform :)

Was this page helpful?
0 / 5 - 0 ratings