How to sort Planetoid dataset based on the degree values of nodes? #2952
Answered
by
rusty1s
OliverSummers
asked this question in
Q&A
-
The Cora dataset has the following attributes:
What I want to do is to sort the dataset based on the degree value of nodes. I code as follows:
One thing missing in my code is rearranging data.edge_index as well. So based on the body of "sort_dataset" I shared above, how do I rearrange data.edge_index? Thank you. |
Beta Was this translation helpful? Give feedback.
Answered by
rusty1s
Aug 9, 2021
Replies: 1 comment 5 replies
-
deg = degree(edge_index[1], num_nodes, dtype=torch.long)
perm = deg.argsort()
x = x[perm]
edge_index = perm[edge_index] should give you the desired result. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
OliverSummers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
should give you the desired result.