Question about adj values in cluster.py #2779
-
I using ClusterGCN for node classification, and I want to get degree of one node in the adjacent matrix, however, I find that the adj is defined in cluster.py as follows, I do not understand why you set value to torch.arange(E, device=data.edge_index.device) instead of torch.ones(E), I want to calculate degree by adj.sum(0) but I can not do this in this adj, I wonder if this definition is necessary or if you have any suggestions for me to calculate degree in this sparse adj? adj = SparseTensor( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you want to get the node degree of nodes in your graph, you can utilize |
Beta Was this translation helpful? Give feedback.
adj
is just an internal storage of theClusterData
, which means that you probably shouldn't operate on it. We save atorch.arange
vector in there as value in order to determine the original ID of edges when creating subgraphs (in order to filter edge features).If you want to get the node degree of nodes in your graph, you can utilize
torch_geometric.utils.degree
, either on the originaledge_index
, or on the subgraph datadata.edge_index
returned by theClusterData
/ClusterLoader
.