Can I make a random edge_index by the given node list? #9370
-
|
Greetings, I have a question about the generation of random edges by the given node list for the transductive setting. nodes
#tensor([ 28, 38, 48, 85, 114, 144, 190, 219, 228,
# 255, 362, 386, 387, 420, 516, 529, 614, 773, ...])
result
#tensor([[387, 228, ..., 362, 3905, 6254],
# [420, 7315, 8018, ..., 28, 529]])I tried to use |
Beta Was this translation helpful? Give feedback.
Answered by
EdisonLeeeee
May 29, 2024
Replies: 1 comment 1 reply
-
|
Does that work for you? import torch
num_nodes = 100
num_edges = 100
row = torch.randint(0, num_nodes, (num_edges,))
col = torch.randint(0, num_nodes, (num_edges,))
edge_index = torch.stack([row, col], dim=0)
edge_index = edge_index[:, row < col] # make directed |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
songsong0425
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does that work for you?