How to add nodes to graphs in loaded dataset #8924
-
What would be the most canonical way to add nodes to a dataset that is imported through For instance, I am loading the reddit binary dataset like this: reddit = torch_geometric.datasets.TUDataset("/tmp/reddit-b", name="REDDIT-BINARY") This yields a dataset which contains 2000 graphs. Now I would like to add a number of nodes to each graph. I only figured out how to do this using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can modify graphs in data.edge_index = torch.cat([data.edge_index, torch.tensor(new_edges)], dim=1)
data.x = torch.cat([data.x, new_features], dim=0) |
Beta Was this translation helpful? Give feedback.
You can modify graphs in
Dataset
through thetransform
/pre_transform
interface. For how to add new nodes, take a look at, e.g., theVirtualNode
transform. In general, it is as simple as